Exemplo n.º 1
0
    private static void Connect(byte Index, NetIncomingMessage Data)
    {
        // Lê os Data
        string User     = Data.ReadString().Trim();
        string Password = Data.ReadString();

        // Check if everything is okay
        if (User.Length < Game.Min_Character || User.Length > Game.Max_Character || Password.Length < Game.Min_Character || Password.Length > Game.Max_Character)
        {
            Sending.Alert(Index, "The user name and password must contain " + Game.Min_Character + " and" + Game.Max_Character + " characters.");
            return;
        }
        if (!File.Exists(Directories.Accounts.FullName + User + Directories.Format))
        {
            Sending.Alert(Index, "This username is not registered.");
            return;
        }
        if (Player.MultipleAccounts(User))
        {
            Sending.Alert(Index, "There's already someone connected to that account.");
            return;
        }
        else if (Password != Read.Player_Password(User))
        {
            Sending.Alert(Index, "The password is incorrect.");
            return;
        }

        // Carrega os Data do Player
        Read.Player(Index, User);

        // Envia os Data das classes
        Sending.Classes(Index);

        // Se o Player não tiver nenhum Character então abrir o painel de criação de Character
        if (!Player.PossuiCharacters(Index))
        {
            Sending.CreateCharacter(Index);
            return;
        }

        // Abre a janela de seleção de personagens
        Sending.Characters(Index);
        Sending.Conectar(Index);
    }
Exemplo n.º 2
0
    private static void Character_Delete(byte Index, NetIncomingMessage Data)
    {
        byte   Character = Data.ReadByte();
        string Name      = Lists.Player[Index].Character[Character].Name;

        // Verifica se o Character existe
        if (string.IsNullOrEmpty(Name))
        {
            return;
        }

        // Deleta o Character
        Sending.Alert(Index, "The character '" + Name + "' has been deleted.", false);
        Write.Characters(Read.Characters_Names().Replace(":;" + Name + ":", ":"));
        Clean.Player_Character(Index, Character);

        // Salva o Character
        Sending.Characters(Index);
        Write.Player(Index);
    }