SA-MP Forums Archive
Dialog doesn't show up after logging in. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dialog doesn't show up after logging in. (/showthread.php?tid=521823)



Dialog doesn't show up after logging in. - AMouldyLemon - 24.06.2014

pawn Код:
forward MasterAccountLogin(playerid, password[]); // Login to an existing master account.
public MasterAccountLogin(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountExists(playerid))
        {
            if(strlen(password) >= 1 && strlen(password) <= 20)
            {
                if(MasterAccount[playerid][mLoggedIn])
                {
                    new rows, fields;
                    new value[128];
                    new query[128];
                    format(query, sizeof(query), "SELECT * FROM `MasterAccount` WHERE `username` = '%s' AND `mPassword` = '%s'", MasterAccount[playerid][mOriginalUsername] , MasterAccount[playerid][mPassword]);
                    cache_get_data(rows, fields);
                    if(rows >=1)
                    {
                        SetPlayerColor(playerid, COLOR_LIGHTGREEN);
                        MasterAccount[playerid][mLoggedIn] = true;
                        cache_get_field_content(0, "password", MasterAccount[playerid][mPassword], 20);
                        cache_get_field_content(0, "email_address", MasterAccount[playerid][mEmailAddress], 30);
                        cache_get_field_content(0, "ip_address", MasterAccount[playerid][mOld_IP], 20);
                        cache_get_field_content(0, "super_admin", value, 5); MasterAccount[playerid][mSuperAdmin] = strval(value);
                        cache_get_field_content(0, "id", value, 15); MasterAccount[playerid][mID] = strval(value);
                        ShowMenuDialog(playerid);
                        printf("Password: %s, Email Address: %s, Last IP Used: %s, Super Admin: %d, ID: %d.", MasterAccount[playerid][mPassword],  MasterAccount[playerid][mEmailAddress],  MasterAccount[playerid][mOld_IP], MasterAccount[playerid][mSuperAdmin], MasterAccount[playerid][mID]);
                        return true;
                    }
                    else
                    {
                        SetPVarInt(playerid, "LOGIN_ATTEMPTS", GetPVarInt(playerid, "LOGIN_ATTEMPTS") + 1);
                        switch(GetPVarInt(playerid, "LOGIN_ATTEMPTS"))
                        {
                            case 1: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 2: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 3: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 4: Kick(playerid);
                        }
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
            }
        }
    }
    return false;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER_PASSWORD:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= 20)
                {
                    SetPVarString(playerid,"TEMP_PASSWORD",inputtext);
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_EMAIL,DIALOG_STYLE_INPUT,"Master Account Registration - Step Two","Email Address:\n( No more or less than 25 characters )","Finish","Cancel");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_PASSWORD,DIALOG_STYLE_PASSWORD,"Master Account Registration - Step One","Password:\n( No more or less than 20 characters )","Continue","Cancel");
                }
            }
            else
            {
                Kick(playerid);
            }
        }
        case DIALOG_REGISTER_EMAIL:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= 30)
                {
                    SetPVarString(playerid,"TEMP_EMAIL",inputtext);
                    if(MasterAccountRegister(playerid))
                    {
                        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "ERROR.");
                        Kick(playerid);
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_EMAIL,DIALOG_STYLE_INPUT,"Master Account Registration - Step Two","Email Address:\n( No more or less than 25 characters )","Finish","Cancel");
                }
            }
            else
            {
                Kick(playerid);
            }
        }
        case DIALOG_LOGIN:
        {
            if(response)
            {
                MasterAccountLogin(playerid, inputtext);
            }
        }
        case DIALOG_MAIN_MENU:
        {
            if(response)
            {
                new count = PlayerCharacterCount(playerid);
                if(count == 0)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "[I:] No characters available to spawn with.");
                    ShowMenuDialog(playerid);
                }
                else
                {
                    LoadCharacter(playerid, InsertPlayerUnderscoreString(GetMenuDialogCharacterOrder(playerid, listitem+1)));
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
        case DIALOG_MAIN_MENU_OPTIONS:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0: // Create New Character
                    {
                        if(PlayerCharacterCount(playerid) < MAX_CHARACTER_SLOTS)
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
                        }
                        else
                        {
                            ShowMenuDialog(playerid);
                            SendClientMessage(playerid, COLOR_RED, "[I:] You have exceeded your character limit, and cannot create anymore.");
                        }
                    }
                    case 1: // Delete Character
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                    case 2: // Change Password
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHANGE_PASSWORD,DIALOG_STYLE_INPUT,"Master Account - Change Password","Type your new desired password:","Change","Go Back");
                    }
                    case 3: // Disconnect
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "[I:] You have safely disconnected.");
                        Kick(playerid);
                    }
                }
            }
            else
            {
                ShowMenuDialog(playerid);
            }
        }
        case DIALOG_MAIN_MENU_CHARACTER_DELETE:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1)
                {
                    if(CharacterExists(inputtext)) //2457
                    {
                        new escapedstring[50];
                        mysql_real_escape_string(InsertPlayerUnderscoreString(inputtext), escapedstring);
                        if(PlayerOwnsCharacter_Name(playerid, escapedstring)) //2461
                        {
                            new query[128];
                            format(query, sizeof(query), "DELETE FROM `Character` WHERE `cName` = '%s'", InsertPlayerUnderscoreString(inputtext)); //(InsertPlayerUnderscoreString(inputtext) //2464
                           
                            format(query, sizeof(query), "[I:] You have successfully deleted character: %s.", inputtext);
                            SendClientMessage(playerid, COLOR_YELLOW, query);
                            ShowMenuDialog(playerid);
                        }
                        else //2470
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                        }
                    }
                    else
                    {
                         ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                }
                else
                {
                     ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
        case DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME:
        {
            new firstname[MAX_PLAYER_NAME], lastname[MAX_PLAYER_NAME];
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= MAX_PLAYER_NAME)
                {
                    if(!CharacterExists(InsertPlayerUnderscoreString(inputtext)))
                    {
                        if(RPName(InsertPlayerUnderscoreString(inputtext), firstname, lastname))
                        {
                            SetPVarString(playerid,"TEMP_C_NAME",InsertPlayerUnderscoreString(inputtext)); //2501
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","The character name you entered is not a valid roleplay name.\n(Firstname Lastname format).","Continue","Go Back");
                        }
                    }
                    else
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","A character with that name is already registered, please choose another name.\n(Firstname Lastname format).","Continue","Go Back");
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
                }
                //CreateCharacter(playerid, //2526
                CreateCharacter(playerid, inputtext, Character[playerid][cCash], Character[playerid][cBank], Character[playerid][cSkin]),
                GetPVarStringEx(playerid, "TEMP_C_NAME"),
               
               
                DeletePVar(playerid, "TEMP_C_NAME");
                ShowMenuDialog(playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
            }   // Go back.
        }
    } //2540
    return 1;
}



Re: Dialog doesn't show up after logging in. - AMouldyLemon - 24.06.2014

Anyone? I'm completely lost.