private static void Character_Delete(byte Index, NetIncomingMessage Data) { byte Character = Data.ReadByte(); string Name = Lists.Player[Index].Character[Character].Name; // Verifica se o personagem existe if (string.IsNullOrEmpty(Name)) { return; } // Deleta o personagem Send.Alert(Index, "The character '" + Name + "' has been deleted.", false); Write.Characters(Read.Characters_Name().Replace(":;" + Name + ":", ":")); Clear.Player_Character(Index, Character); // Salva o personagem Send.Characters(Index); Write.Player(Index); }
private static void CreateCharacter(byte Index, NetIncomingMessage Data) { byte Character = Player.FindCharacter(Index, string.Empty); // Lê os dados string Name = Data.ReadString().Trim(); // Verifica se está tudo certo if (Name.Length < Game.Min_Name_Length || Name.Length > Game.Max_Name_Length) { Send.Alert(Index, "The character name must contain between " + Game.Min_Name_Length + " and " + Game.Max_Name_Length + " characters.", false); return; } if (Name.Contains(";") || Name.Contains(":")) { Send.Alert(Index, "Can't contain ';' and ':' in the character name.", false); return; } if (Read.Characters_Name().Contains(";" + Name + ":")) { Send.Alert(Index, "A character with this name already exists", false); return; } // Define o personagem que será usado Lists.Temp_Player[Index].Using = Character; // Define os valores iniciais do personagem Player.Character(Index).Name = Name; Player.Character(Index).Level = 1; Player.Character(Index).Class = Data.ReadByte(); Lists.Structures.Class Class = Lists.Class[Player.Character(Index).Class]; Player.Character(Index).Genre = Data.ReadBoolean(); if (Player.Character(Index).Genre) { Player.Character(Index).Texture_Num = Class.Tex_Male[Data.ReadByte()]; } else { Player.Character(Index).Texture_Num = Class.Tex_Female[Data.ReadByte()]; } Player.Character(Index).Attribute = Class.Attribute; Player.Character(Index).Map = Class.Spawn_Map; Player.Character(Index).Direction = (Game.Directions)Class.Spawn_Direction; Player.Character(Index).X = Class.Spawn_X; Player.Character(Index).Y = Class.Spawn_Y; for (byte i = 0; i < (byte)Game.Vitals.Count; i++) { Player.Character(Index).Vital[i] = Player.Character(Index).MaxVital(i); } for (byte i = 0; i < (byte)Class.Item.Length; i++) { if (Lists.Item[Class.Item[i].Item1].Type == (byte)Game.Items.Equipment && Player.Character(Index).Equipment[Lists.Item[Class.Item[i].Item1].Equip_Type] == 0) { Player.Character(Index).Equipment[Lists.Item[Class.Item[i].Item1].Equip_Type] = Class.Item[i].Item1; } else { Player.GiveItem(Index, Class.Item[i].Item1, Class.Item[i].Item2); } } // Salva a conta Write.Character(Name); Write.Player(Index); // Entra no jogo Player.Join(Index); }