public static CustomTimer CreateTimer(Action callback, float interval) { CustomTimer timer = new CustomTimer(interval, callback); ListTimers.Add(timer); return(timer); }
public static void DestroyTimer(CustomTimer timer, bool execute = false) { if (ListTimers.Contains(timer)) { if (execute == true) { timer.Callback(); } ListTimers.Remove(timer); } }
public static void SendMessage(string message) { int currentTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; float offsetTime = 1f; if (currentTime <= lastChatMessageTime) { offsetTime = lastChatMessageTime - currentTime + offsetTime; lastChatMessageTime = currentTime + (int)offsetTime; } else { lastChatMessageTime = currentTime + (int)offsetTime; } CustomTimer.CreateTimer(() => Game.ExecuteCommand("say " + message), offsetTime); }