Example #1
0
 public static void ActivatePlayer(SkillPlayer player, int index)
 {
     lock (players)
     {
         players[index] = player;
     }
 }
Example #2
0
        public static SkillPlayer LoadPlayer(TSPlayer player)
        {
            var         list = LoadSkills(player.UserAccountName);
            SkillPlayer ply  = new SkillPlayer(player, list);

            return(ply);
        }
Example #3
0
 public SkillPlayer(SkillPlayer old)
 {
     lock (old.acquiredSkills)
     {
         Player         = old.Player;
         AccountName    = old.Player.UserAccountName;
         acquiredSkills = old.acquiredSkills;
     }
 }
Example #4
0
 public static void SavePlayer(SkillPlayer player)
 {
     try
     {
         database.Query("REPLACE INTO PlayerSkills (UserAccountName, SkillInformation) VALUES (@0, @1)", player.AccountName,
                        JsonConvert.SerializeObject(player.Skills()));
     }
     catch (Exception e)
     {
         TShockAPI.Log.ConsoleError("Failed to save player: {0}", e.Message);
     }
 }
Example #5
0
        private void HandlePlayerLogin(TShockAPI.Hooks.PlayerPostLoginEventArgs args)
        {
            try
            {
                SkillPlayer ply = PlayerManager.GetPlayer(args.Player.Index);
                PlayerManager.SavePlayer(ply);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            var player = PlayerManager.LoadPlayer(args.Player);

            PlayerManager.ActivatePlayer(player, player.Player.Index);
        }
Example #6
0
        public static void RemovePlayer(int index)
        {
            SkillPlayer player = null;

            lock (players)
            {
                if (players[index] != null)
                {
                    player = new SkillPlayer(players[index]);
                }

                players[index] = null;
            }

            if (player != null)
            {
                SavePlayer(player);
            }
        }