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

            return(ply);
        }
Ejemplo n.º 3
0
 public SkillPlayer(SkillPlayer old)
 {
     lock (old.acquiredSkills)
     {
         Player         = old.Player;
         AccountName    = old.Player.UserAccountName;
         acquiredSkills = old.acquiredSkills;
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }