Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            Commands.ChatCommands.Add(new Command("stat.check", StatCommand, "stat"));
            Commands.ChatCommands.Add(new Command("stat.boss", BossCommand, "battle", "boss"));
            Commands.ChatCommands.Add(new Command("stat.encounter", EncountersCommand, "bosses", "events"));
            Commands.ChatCommands.Add(new Command("stat.invasion", InvasionCommand, "event", "invasion"));
            Commands.ChatCommands.Add(new Command("stat.sub", SubCommand, "sub", "subscribe"));
            Commands.ChatCommands.Add(new Command("stat.sub", UnsubCommand, "unsub", "unsubscribe"));
            Commands.ChatCommands.Add(new Command("stat.ttm", TtmCommand, "ttm"));
            Commands.ChatCommands.Add(new Command("stat.ttn", TtnCommand, "ttn"));
            Commands.ChatCommands.Add(new Command("stat.admin", WaveCommand, "wave"));

                        #if DEBUG
            Commands.ChatCommands.Add(new Command(Debug, "statdebug"));
                        #endif

            StatDB.SetupDB();
            dayTimer.Elapsed += new ElapsedEventHandler(DayTimerTick);
            dayTimer.Start();
            UpdateTimer.Elapsed += UpdateTimerTick;
            UpdateTimer.Start();
            ServerApi.Hooks.ServerJoin.Register(this, OnJoin);
            ServerApi.Hooks.NetGetData.Register(this, OnGetData);
            ServerApi.Hooks.NetSendData.Register(this, OnSendData);
            ServerApi.Hooks.ServerLeave.Register(this, OnLeave);

            //PlayerHooks.PlayerPostLogin += new PlayerHooks.PlayerPostLoginD(OnPlayerLogin);
        }
Ejemplo n.º 3
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);
             }
         }
     }
 }
Ejemplo n.º 4
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;
            }
        }