SA-MP Forums Archive
Help with a dialog response problem - 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: Help with a dialog response problem (/showthread.php?tid=440782)



Help with a dialog response problem - Finn707 - 31.05.2013

I've got this code:

This is using EasyDialog, it's basically the OnDialogResponse.
pawn Код:
Dialog:Login_Dialog(playerid, response, listitem, inputtext[])
{
    if(strlen(inputtext) == 0)
    {
        new Log_String[81];
        format(Log_String, sizeof(Log_String), "Welcome, %s\n\nTo login, please enter your password.", GetNameEx(playerid));
        ShowDialog(playerid, Show:Login_Dialog, DIALOG_STYLE_PASSWORD , "Login", Log_String, "Login", "Quit");
    }
    else
    {
        new EscapedText[25], Query[150];
        mysql_real_escape_string(inputtext, EscapedText);
        format(Query,sizeof(Query),"SELECT * FROM `---` WHERE `---` = '%s' AND `---` = '%s'",GetName(playerid),EscapedText);
        mysql_function_query(Connect_Handle, Query, true, "InitPlayerLogin", "ds", playerid, EscapedText);
    }
    return 1;
}
Here's my InitPlayerLogin:
pawn Код:
forward InitPlayerLogin(playerid, EscapedText);
public InitPlayerLogin(playerid, EscapedText)
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(!rows)
    {
        new Log_String[81];
        TimesAttempted[playerid] += 1;
        format(Log_String, sizeof(Log_String), "Welcome, %s\n{D62B2B}Incorrect Password\n{A9C4E4}To login, please enter your password.", GetNameEx(playerid));
        ShowDialog(playerid, Show:Login_Dialog, DIALOG_STYLE_PASSWORD , "Login", Log_String, "Login", "Quit");
        if(TimesAttempted[playerid] == 1)
        {
            SendClientMessage(playerid, Col_Red, "You entered an incorrect password. Two login attempts left.");           
        }
        else if(TimesAttempted[playerid] == 2)
        {
            SendClientMessage(playerid, Col_Red, "You entered an incorrect password. One login attempt left.");
        }
        else if(TimesAttempted[playerid] == 3)
        {
            KickWithMessage(playerid, Col_White, "You reached the max login attempts.");
        }
    }
    else
    {
        //Log user in here, load stats
        SendClientMessage(playerid, Col_Green, "Logged in");
    }
}
The problem I'm having is, when I test this, when I enter nothing in the login dialog, it doesn't do what it should on the OnDialogResponse part, but instead it just does the "Incorrect password" stuff, how can I fix this?


AW: Help with a dialog response problem - Nero_3D - 31.05.2013

Thats because how zcmd or easydialog passes the string, you need to use isnull
pawn Код:
if(isnull(inputtext)) // instead of if(strlen(inputtext) == 0)



Re: AW: Help with a dialog response problem - Finn707 - 31.05.2013

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Thats because how zcmd or easydialog passes the string, you need to use isnull
pawn Код:
if(isnull(inputtext)) // instead of if(strlen(inputtext) == 0)
Ahh thanks mate, I wasn't aware.