public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_LOG:
{
if(!response) return Kick(playerid);
new hPass[129];
new query[100];
WP_Hash(hPass, 129, inputtext);
if(strcmp(hPass, pData[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", GPName(playerid));
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
else
{
MaxLoginAmount[playerid] ++;
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "Invalid Password.", "The password you have entered for this account is invalid. \nPlease enter the password below:", "Login", "Quit");
}
if(MaxLoginAmount[playerid] >= 3)
{
SendClientMessage(playerid, COLOR_RED, "SERVER: You have exceeded the max amounts of login attempts [3]. You have been kicked.");
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
}
}
case DIALOG_REG:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Invalid Password", "The password you have entered is too small. \nPlease enter a password longer than 6 letters!", "Register", "Quit");
new query[300];
WP_Hash(pData[playerid][Password], 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Money`, `Admin`, `pX`, `pY`, `pZ`) VALUES ('%e', '%s', '%s', 0, 0, 0.0, 0.0, 0.0)", GPName(playerid), pData[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
}
}
return 1;
}
if(strcmp(hPass, pData[playerid][Password]) == 0)
if(!strcmp(hPass, pData[playerid][Password]))
Are you sure? be cause i use it in my saving system.
Can you show me the callback which you used to call player to check if he's registered or not, like "OnAccountCheck" as many people use it. |
public OnAccountCheck(playerid)
{
new str[200];
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "PASS", pData[playerid][Password], mysql, 129);
pData[playerid][ID] = cache_get_field_content_int(0, "ID");
format(str, sizeof(str), "Welcome back to Reindience Roleplay, %s! \nLooks like your account is registered, please enter your password below:", GPName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "Welcome back to Reindience Roleplay!", str, "Login", "Quit");
}
else
{
format(str, sizeof(str), "Welcome to Reindience Roleplay, %s! \nLooks like your account is not registered, please enter a password below:", GPName(playerid));
ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Welcome to Reindience Roleplay!", str, "Register", "Quit");
}
return 1;
}
cache_get_field_content(0, "PASS", pData[playerid][Password], mysql, 129);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Money`, `Admin`, `pX`, `pY`, `pZ`) VALUES ('%e', '%s', '%s', 0, 0, 0.0, 0.0, 0.0)", GPName(playerid), pData[playerid][Password], IP[playerid]);
`Password and PASS
cache_get_field_content(0, "Password", pData[playerid][Password], mysql, 129);
yea, that's the problem, the tutorial you took that from had a mistake , look here:
pawn Code:
pawn Code:
pawn Code:
Change it to: pawn Code:
|