Пример #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);
             }
         }
     }
 }
Пример #3
0
        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;
            }
        }