static void DoTask(SchedulerTask task, PlayerExtList list, Action <string[]> callback) { List <string> lines = list.AllLines(); foreach (string line in lines) { string[] args = line.SplitSpaces(); if (args.Length < 4) { continue; } long expiry; if (!long.TryParse(args[3], out expiry)) { continue; } if (DateTime.UtcNow < expiry.FromUnixTime()) { continue; } callback(args); } task.Delay = NextRun(list); }
static TimeSpan NextRun(PlayerExtList list) { DateTime nextRun = DateTime.MaxValue.AddYears(-1); // Lock because we want to ensure list not modified from under us lock (list.locker) { List <string> lines = list.AllLines(); // Line format: name assigner assigntime expiretime [whatever other data, we don't care] foreach (string line in lines) { string[] args = line.SplitSpaces(); if (args.Length < 4) { continue; } long expiry; if (!long.TryParse(args[3], out expiry)) { continue; } DateTime expireTime = expiry.FromUnixTime(); if (expireTime < nextRun) { nextRun = expireTime; } } } return(nextRun - DateTime.UtcNow); }
public static int amount = 5; // The amount given to the player public override void Load(bool startup) { dailyList = PlayerExtList.Load("text/dailybonus.txt"); // Load the list so we can start using it if (AutoReward) { OnPlayerConnectEvent.Register(HandlePlayerConnect, Priority.High); } else { Command.Register(new CmdDailyBonus()); } }
public override void Load(bool startup) { Command.Register(new CmdAccept()); Command.Register(new CmdDeny()); Command.Register(new CmdDivorce()); Command.Register(new CmdMarry()); marriages = PlayerExtList.Load("extra/marriages.txt"); onlineLine = (p, who) => FormatMarriedTo(p, who.name); offlineLine = (p, who) => FormatMarriedTo(p, who.Name); OnlineStat.Stats.Add(onlineLine); OfflineStat.Stats.Add(offlineLine); }
public override void Load(bool startup) { if (!Directory.Exists("plugins/DiscordVerify")) { Directory.CreateDirectory("plugins/DiscordVerify"); } // If the directory does not exist, then we will just create it. if (!File.Exists("plugins/DiscordVerify/verified.txt")) { File.Create("plugins/DiscordVerify/verified.txt"); } // If the file does not exist, then we will also create that file. We don't want our user to do it manually. verified = PlayerExtList.Load("plugins/DiscordVerify/verified.txt"); // Purpose is not to have it break. OnChannelMessageEvent.Register(HandleDiscordMessage, Priority.High); Command.Register(new CmdVerify()); }
public static void LoadTeams() { Teams = PlayerExtList.Load("teams.txt"); teamsLoaded = true; }
static void CalcNextRun(SchedulerTask task, PlayerExtList list) { task.Delay = NextRun(list); task.NextRun = DateTime.UtcNow.Add(task.Delay); Server.MainScheduler.Recheck(); }
public override void Load(bool startup) { list = PlayerExtList.Load("text/rewardtimes.txt"); cmd = new CmdReward(); Command.Register(cmd); }