void OnLeave(LeaveEventArgs e) { lock (this) { Player plr = players[e.Who]; if (TShock.Players[e.Who] == null || plr == null) { return; } if (!TShock.Players[e.Who].IsLoggedIn) { players[e.Who] = null; return; } if (StatDB.PlayerExists(plr.Name)) { StatDB.UpdatePlayer(plr); } else { StatDB.AddPlayer(plr); } players[e.Who] = null; } }
void UpdateTimerTick(object sender, ElapsedEventArgs e) { foreach (Player player in players) { if (player != null && TShock.Players[player.Index] != null && TShock.Players[player.Index].IsLoggedIn) { if (StatDB.PlayerExists(player.Name)) { StatDB.UpdatePlayer(player); } else { StatDB.AddPlayer(player); } } } }
void OnJoin(JoinEventArgs e) { lock (this) { TSPlayer ply = TShock.Players[e.Who]; if (ply == null) { return; } Player plr; if (StatDB.PlayerExists(ply.Name)) { plr = StatDB.PullPlayer(ply.Name); } else { plr = new Player(e.Who, ply.Name); } players[e.Who] = plr; } }