31.05.2013, 09:46
I've got this code:
This is using EasyDialog, it's basically the OnDialogResponse.
Here's my InitPlayerLogin:
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?
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;
}
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");
}
}