示例#1
0
        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;
            }
        }
示例#2
0
 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);
             }
         }
     }
 }