CopyCharacter() public méthode

Copies a characters data to this object
public CopyCharacter ( TShockAPI.TSPlayer player ) : void
player TShockAPI.TSPlayer
Résultat void
Exemple #1
0
 /// <summary>
 /// Saves the player's inventory to SSC
 /// </summary>
 /// <returns>bool - True/false if it saved successfully</returns>
 public bool SaveServerCharacter()
 {
     if (!Main.ServerSideCharacter)
     {
         return(false);
     }
     try
     {
         if (HasPermission(Permissions.bypassssc))
         {
             TShock.Log.ConsoleInfo("Skipping SSC Backup for " + User.Name);                     // Debug Code
             return(true);
         }
         PlayerData.CopyCharacter(this);
         TShock.CharacterDB.InsertPlayerData(this);
         return(true);
     }
     catch (Exception e)
     {
         TShock.Log.Error(e.Message);
         return(false);
     }
 }
        private void CMDinvsee(CommandArgs args)
        {
            if (!TShock.Config.ServerSideCharacter)
            {
                args.Player.SendErrorMessage("Server Side Character must be enabled.");
                return;
            }
            if (args.Parameters.Count < 1)
            {
                args.Player.SendErrorMessage("Usage: /invsee <player name / -restore>");
                return;
            }
            var ePly = esPlayers[args.Player.Index];
            if (args.Parameters.Count == 1 && args.Parameters[0].ToLower() == "-restore")
            {
                if (ePly.InvSee == null)
                {
                    args.Player.SendErrorMessage("You are not viewing another player's inventory.");
                    return;
                }
                ePly.InvSee.RestoreCharacter(args.Player);
                ePly.InvSee = null;
                args.Player.SendSuccessMessage("Restored your inventory.");
                return;
            }
            var PlayersFound = TShock.Utils.FindPlayer(string.Join(" ", args.Parameters));
            if (PlayersFound.Count != 1)
            {
                args.Player.SendErrorMessage(PlayersFound.Count < 1 ? "No Players matched." : "More than one player matched.");
                return;
            }

            var PlayerChar = new PlayerData(args.Player);
            PlayerChar.CopyCharacter(args.Player);
            if (ePly.InvSee == null)
            {
                ePly.InvSee = PlayerChar;
            }

            var CopyChar = new PlayerData(PlayersFound[0]);
            CopyChar.CopyCharacter(PlayersFound[0]);
            CopyChar.health = PlayerChar.health;
            CopyChar.maxHealth = PlayerChar.maxHealth;
            CopyChar.mana = PlayerChar.mana;
            CopyChar.maxMana = PlayerChar.maxMana;
            CopyChar.spawnX = PlayerChar.spawnX;
            CopyChar.spawnY = PlayerChar.spawnY;
            CopyChar.RestoreCharacter(args.Player);

            args.Player.SendSuccessMessage("Copied {0}'s inventory", PlayersFound[0].Name);
        }