Example #1
0
        public void LoadPlayerInfo(TSPlayer ply)
        {
            if (ply == null)
            {
                return;
            }

            using (QueryResult result = db.QueryReader("SELECT * FROM Users WHERE Name=@0", ply.Name))
            {
                while (result.Read())
                {
                    //TShock.Log.ConsoleInfo("USER FOUND IN DB!");
                    PTime playTime = new PTime();
                    playTime.RawSeconds = result.Get <int>("PlayTime");
                    playTime.Update();
                    HelperBot.players.Add(new PlayerInfo()
                    {
                        Player    = ply,
                        Kills     = result.Get <int>("Kills"),
                        Deaths    = result.Get <int>("Deaths"),
                        PlayTime  = playTime,
                        Biography = result.Get <string>("Biography")
                    });
                    return;
                }
            }

            //TShock.Log.ConsoleInfo("USER NOT FOUND IN DB! CREATING IT!");
            PTime ptime = new PTime()
            {
                Hours      = 0,
                Minutes    = 0,
                Seconds    = 0,
                RawSeconds = 0
            };

            PlayerInfo pinf = new PlayerInfo()
            {
                Player    = ply,
                Deaths    = 0,
                Kills     = 0,
                Biography = "",
                PlayTime  = ptime
            };

            CreatePlayerInfo(pinf);
            HelperBot.players.Add(pinf);
        }
Example #2
0
 public PlayerInfo GetPlayerInfo(string name)
 {
     using (QueryResult result = db.QueryReader("SELECT * FROM Users WHERE Name=@0", name))
     {
         while (result.Read())
         {
             PTime playTime = new PTime();
             playTime.RawSeconds = result.Get <int>("PlayTime");
             PlayerInfo pinf = new PlayerInfo()
             {
                 Kills     = result.Get <int>("Kills"),
                 Deaths    = result.Get <int>("Deaths"),
                 PlayTime  = playTime,
                 Biography = result.Get <string>("Biography")
             };
             pinf.PlayTime.Update();
             return(pinf);
         }
     }
     return(null);
 }