SA-MP Forums Archive
Dialog Inputtext - 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 Inputtext (/showthread.php?tid=476590)



Dialog Inputtext - Day_Jons - 19.11.2013

Hello, I need help, you need to make so that inputtext contained in the dialogue and the letters and numbers alphabet if inputtext sodrzhit only numbers or letters but not only numbers and letters that I get an error SendClientMessage (playerid, -1, "Your password must contain numbers and letters ");


Re: Dialog Inputtext - Voxel - 19.11.2013

Put this at the bottom of your script
pawn Код:
stock IsValidPassword(const password[])
{
    for(new i = 0; password[i] != EOS; ++i)
    {
        switch(password[i])
        {
            case '0'..'9', 'A'..'Z', 'a'..'z': continue;
            default: return 0;
        }
    }
    return 1;
}
Put this under your register dialog (under your if(response) of u have one):
pawn Код:
if(!IsValidPassword(inputtext))
            {
                SendClientMessage(playerid, -1, ""COL_RED"The password is invalid, Valid characters are: A-Z, a-z, 0-9");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Register pannel", "Please register to play on "COL_BLUE"Survival Games Zombie Mode\n"COL_WHITE"Enter a "COL_BLUE"password"COL_WHITE":", "Register", "Exit");
                return 1;
            }
            if(strlen(inputtext) < 3 || strlen(inputtext) > 24)
            {
                SendClientMessage(playerid, -1, ""COL_RED"The password is invalid, Its lenght should be 3-24 characters");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, ""COL_BLUE"SGZM"COL_WHITE" Register pannel", "Please register to play on "COL_BLUE"Survival Games Zombie Mode\n"COL_WHITE"Enter a "COL_BLUE"password"COL_WHITE":", "Register", "Exit");
                return 1;
            }
You will need to change the color defines to yours.
goodluck!