public override void Load(bool startup) { Command.Register(new CmdReloadEffects()); Command.Register(new CmdEffect()); Command.Register(new CmdSpawner()); rnd = new Random(); LoadEffects(); DefineEffectsAll(); playerEffects = PlayerExtList.Load("extra/playereffects.txt"); OnPlayerMoveEvent.Register(OnPlayerMove, Priority.Low); OnPlayerFinishConnectingEvent.Register(OnPlayerFinishConnecting, Priority.Low); OnLevelLoadedEvent.Register(OnLevelLoaded, Priority.Low); OnLevelUnloadEvent.Register(OnLevelUnload, Priority.Low); OnLevelDeletedEvent.Register(OnLevelDeleted, Priority.Low); OnLevelCopiedEvent.Register(OnLevelCopied, Priority.Low); OnLevelRenamedEvent.Register(OnLevelRenamed, Priority.Low); SpawnersFile.cache = new ThreadSafeCache(); if (!Directory.Exists(SpawnersFile.spawnerDirectory)) { Directory.CreateDirectory(SpawnersFile.spawnerDirectory); } Level[] levels = LevelInfo.Loaded.Items; foreach (Level level in levels) { SpawnersFile.Load(level); } spawnerAccum = 0; ActivateSpawners(); }
public override void Unload(bool shutdown) { Command.Unregister(Command.Find("ReloadEffects")); Command.Unregister(Command.Find("Effect")); Command.Unregister(Command.Find("Spawner")); OnPlayerFinishConnectingEvent.Unregister(OnPlayerFinishConnecting); OnLevelLoadedEvent.Unregister(OnLevelLoaded); OnLevelUnloadEvent.Unregister(OnLevelUnload); OnLevelDeletedEvent.Unregister(OnLevelDeleted); OnLevelCopiedEvent.Unregister(OnLevelCopied); OnLevelRenamedEvent.Unregister(OnLevelRenamed); spawnersAtLevel.Clear(); instance.Cancel(tickSpawners); }
void CompleteLoginProcess() { Player clone = null; OnPlayerFinishConnectingEvent.Call(this); if (cancelconnecting) { cancelconnecting = false; return; } lock (PlayerInfo.Online.locker) { // Check if any players online have same name Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.truename == truename) { clone = pl; break; } } // Remove clone from list (hold lock for as short time as possible) if (clone != null && Server.Config.VerifyNames) { PlayerInfo.Online.Remove(clone); } id = NextFreeId(); PlayerInfo.Online.Add(this); } if (clone != null && Server.Config.VerifyNames) { string reason = ip == clone.ip ? "(Reconnecting)" : "(Reconnecting from a different IP)"; clone.Leave(reason); } else if (clone != null) { Leave(null, "Already logged in!", true); return; } SendRawMap(null, level); if (Socket.Disconnected) { return; } loggedIn = true; SessionStartTime = DateTime.UtcNow; LastLogin = DateTime.Now; TotalTime = TimeSpan.FromSeconds(1); GetPlayerStats(); ShowWelcome(); Server.Background.QueueOnce(ShowAltsTask, name, TimeSpan.Zero); CheckState(); PlayerDB.LoadNick(this); Game.Team = Team.TeamIn(this); SetPrefix(); LoadCpeData(); if (Server.noEmotes.Contains(name)) { parseEmotes = !Server.Config.ParseEmotes; } hideRank = Rank; hidden = CanUse("Hide") && Server.hidden.Contains(name); if (hidden) { Message("&8Reminder: You are still hidden."); } if (Chat.AdminchatPerms.UsableBy(Rank) && Server.Config.AdminsJoinSilently) { hidden = true; adminchat = true; } OnPlayerConnectEvent.Call(this); if (cancellogin) { cancellogin = false; return; } string joinMsg = "&a+ λFULL &S" + PlayerDB.GetLoginMessage(this); if (hidden) { joinMsg = "&8(hidden)" + joinMsg; } if (Server.Config.GuestJoinsNotify || Rank > LevelPermission.Guest) { Chat.MessageFrom(ChatScope.All, this, joinMsg, null, Chat.FilterVisible(this), !hidden); } if (Server.Config.AgreeToRulesOnEntry && Rank == LevelPermission.Guest && !Server.agreed.Contains(name)) { Message("&9You must read the &c/Rules &9and &c/Agree &9to them before you can build and use commands!"); agreed = false; } CheckIsUnverified(); if (CanUse("Inbox") && Database.TableExists("Inbox" + name)) { int count = Database.CountRows("Inbox" + name); if (count > 0) { Message("You have &a" + count + " &Smessages in &T/Inbox"); } } if (Server.Config.PositionUpdateInterval > 1000) { Message("Lowlag mode is currently &aON."); } if (String.IsNullOrEmpty(appName)) { Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", truename, IP); } else { Logger.Log(LogType.UserActivity, "{0} [{1}] connected using {2}.", truename, IP, appName); } PlayerActions.PostSentMap(this, null, level, false); Loading = false; }