25.03.2014, 16:04
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 1: //login dialog
{
if(!response) Kick(playerid);
new hpass[129];
new query[100];
WP_Hash(hpass, 129, inputtext);
if(!strcmp(hpass, pInfo[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
else
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
}
}
case 2: //register dialog
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
new query[300];
WP_Hash(pInfo[playerid][Password], 129, inputtext); //hashing inputtext
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`) VALUES ('%e', '%s', '%s')", Name[playerid], pInfo[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
}
}
return 1;
}