private void StartEventTimer() { if (configData.Options.EnableAutomaticEvents) { if (configData.Options.EventTimers.UseRandomTimer) { var random = GetRandom(configData.Options.EventTimers.RandomTimerMin, configData.Options.EventTimers.RandomTimerMax); EventTimer = timer.Once(random, () => { StartRandomOnMap(); StartEventTimer(); }); } else EventTimer = timer.Repeat(configData.Options.EventTimers.EventInterval, 0, () => StartRandomOnMap()); } }
/// <summary> /// Destroys a timer, returns the instance to the pool and sets the variable to null /// </summary> /// <param name="timer"></param> public void Destroy(ref Timer timer) { timer?.DestroyToPool(); timer = null; }
private void cmdEndWar(BasePlayer player, string command, string[] args) { if (!canExecute(player)) return; if (cmdTimer != null) { cmdTimer.Destroy(); cmdTimer = null; } endwar(); PrintToChat(Config["SuccessfulEndWar"].ToString()); }
void Unloaded() { if (cmdTimer != null) { cmdTimer.Destroy(); cmdTimer = null; } }
private void cmdStartWar(BasePlayer player, string command, string[] args) { if (!canExecute(player)) return; startwar(); cmdTimer = timer.Repeat((int)Config["WarInterval"], 1000, () => startwar()); var message = string.Format(Config["SuccessfulStartWar"].ToString() + " {0}", player.displayName); PrintToChat(message); }
void Loaded() { _timer = timer.Every(20, () => Messages()); _timer = timer.Every(30, () => TOD_Sky.Instance.Cycle.Hour = 12); /*_timer = timer.Every(3600, () => { BaseEntity entity = GameManager.server.CreateEntity("Assets/Prefabs/NPC/Patrol Helicopter/PatrolHelicopter.prefab", new Vector3(), new Quaternion(), true); if (entity != null) { entity.GetComponent<PatrolHelicopterAI>().SetInitialDestination(new Vector3(0, 100, 0)); entity.Spawn(true); } });*/ _timer = timer.Every(1, () => { if (scoreboardRefresh <= 0) { UpdateScoreboard(); scoreboardRefresh = 20; } }); _timer = timer.Every(1, () => scoreboardRefresh = scoreboardRefresh - 1); storedData = Interface.GetMod().DataFileSystem.ReadObject<StoredData>("KillStats"); }
private void OnServerInitialized() { // List initialization UnreadyList = new List <string>(); RedTeam = new List <ulong>(); BlueTeam = new List <ulong>(); RedReady = new List <ulong>(); BlueReady = new List <ulong>(); RedParty = RelationshipManager.Instance.CreateTeam(); BlueParty = RelationshipManager.Instance.CreateTeam(); VoteKickDcty = new Dictionary <string, List <string> >(); rnd = new Random(); AlternativeMessage = 0; message = timer.Repeat(15, -1, () => { if (!GameStarted) { ++AlternativeMessage; if (AlternativeMessage % 2 == 0) { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, "Please pick a team with /join and get ready with /ready."); } } else { foreach (BasePlayer x in BasePlayer.activePlayerList) { if (!RedReady.Contains(x.userID) && !BlueReady.Contains(x.userID)) { UnreadyList.Add(x.displayName); } } foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, "Players unready : {0}", string.Join(",", UnreadyList)); } UnreadyList.Clear(); } } }); if (OnlyDay) { TimeCheck = timer.Repeat(60, -1, () => { TOD_Sky.Instance.Cycle.Hour = 12; }); } LoadCraftTime(); DefaultHostName = ConVar.Server.hostname; int Consume = 1440 / ConsumeRate; covalence.Server.Command("decay.upkeep_period_minutes " + Consume); covalence.Server.Command("decay.scale " + ConsumeRate); covalence.Server.Command("decay.tick " + DecayTickRate); RefreshServerName(); INIT = true; }
private void BeginGame() { GameStarted = true; timer.Destroy(ref message); Timer killCountdown = timer.Once(2, () => { if (GameStarted) { foreach (BasePlayer x in BasePlayer.activePlayerList) { x.Hurt(1000); } // debug plz BasePlayer.sleepingPlayerList.ForEach(x => x.Kill(BaseNetworkable.DestroyMode.None)); } RemoveAll(); } ); TimeLeft = timer.Once(PreparationTime, () => { if (!GameStarted) { return; } PreparationUp = true; foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentTimeUp); } if (!CupBoardBlue && !CupBoardRed) { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentDraw); } ClearGame(); } else if (!CupBoardBlue) { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentNoTC, CurrentBlueUpper, CurrentRedLower); } ClearGame(); } else if (!CupBoardRed) { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentNoTC, CurrentRedUpper, CurrentBlueLower); } ClearGame(); } } ); Timer before60 = timer.Once(PreparationTime - 60, () => { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentRemaining, "60"); } } ); Timer before30 = timer.Once(PreparationTime - 30, () => { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentRemaining, "30"); } } ); Timer before15 = timer.Once(PreparationTime - 15, () => { foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentRemaining, "15"); } } ); foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentGameStart, PreparationTime); } RefreshServerName(); }