public static void ActivatePlayer(SkillPlayer player, int index) { lock (players) { players[index] = player; } }
public static SkillPlayer LoadPlayer(TSPlayer player) { var list = LoadSkills(player.UserAccountName); SkillPlayer ply = new SkillPlayer(player, list); return(ply); }
public SkillPlayer(SkillPlayer old) { lock (old.acquiredSkills) { Player = old.Player; AccountName = old.Player.UserAccountName; acquiredSkills = old.acquiredSkills; } }
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); } }
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); }
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); } }