Login Issue - 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: Login Issue (
/showthread.php?tid=552343)
Login Issue -
HighFlyer - 23.12.2014
Hi, I have this problem, where my script returns "Invalid Password" message. The password is saved when a player registers, and hashed using MD5. In the database, field "password" is formatted as char(32), which produces no more "sscanf warning: string buffer overflow" when entering the password, as I had that before.
Instead, the script now triggers the else clause, giving me a three time warning about an Invalid Password, as scripted in my code. I also verified that MD5 is correct, by dehashing it, and it gives me my password back, which is "testing". How can I fix this?
This is from MySQL debug:
Код:
[23:45:21] >> mysql_real_escape_string( Connection handle: 1 )
[23:45:21] CMySQLHandler::EscapeString(HighFlyer); - Escaped 9 characters to HighFlyer.
[23:45:21] >> mysql_query( Connection handle: 1 )
[23:45:21] CMySQLHandler::Query(SELECT * FROM `Accounts` WHERE `Username` = 'HighFlyer' AND `Password` = md5('testing')) - Successfully executed.
[23:45:21] >> mysql_store_result( Connection handle: 1 )
[23:45:21] CMySQLHandler::StoreResult() - Result was stored.
[23:45:21] >> mysql_num_rows( Connection handle: 1 )
[23:45:21] CMySQLHandler::NumRows() - Returned 0 row(s)
It seems to cut off there with no rows returned, but why? Here's my code:
Код:
stock Dialog_Login(playerid)
{
new str[128];
format(str, sizeof(str), "{FFFFFF}Welcome back to San Andreas Transport Clan {33FF33}%s\n{FFFFFF}Please login with your password below:", Player[playerid][Username]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFA19C}Welcome back, please login to SATC", str, "Login", "Cancel");
}
Код:
case DIALOG_LOGIN:
{
if(!response) // Cancel
{
Kick(playerid);
return 1;
}
if(!inputtext[0])
{
SendClientMessage(playerid, RED, "Error: Please enter a password.");
Dialog_Login(playerid);
return 1;
}
new esc_password[MAX_PASSWORD_LEN], query[512];
format(esc_password, sizeof(esc_password), "%s", inputtext);
mysql_debug(1);
format(query, sizeof(query), "SELECT * FROM `Accounts` WHERE `Username` = '%s' AND `Password` = md5('%s')", GetPlayerEscapedName(playerid), esc_password);
printf(esc_password);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0) // Password is correct
{
new result[1024];
mysql_fetch_row_format(result);
printf("Password is correct.");
if(sscanf(result, MYSQL_PLAYER_LOAD_FORMAT, Player[playerid]))
{
printf("MYSQL_PLAYER_LOAD_FORMAT OK");
WipeChat(playerid);
SendClientMessage(playerid, WHITE, "There was an error with the format of your account data.");
SendClientMessage(playerid, WHITE, "Please take a screenshot, if you know how, and post it as a bug report.");
SendClientMessage(playerid, WHITE, "Forums: "FORUMS"");
Kick(playerid);
mysql_debug(0);
printf("MYSQL_PLAYER_LOAD_FORMAT END OK");
return 1;
}
OnPlayerLogin(playerid);
printf("We have been successful");
}
else
{
Player[playerid][LoginAttempts]++;
format(str, sizeof(str), "Error: Invalid password (%d/%d)", Player[playerid][LoginAttempts], MAX_LOGIN_ATTEMPTS);
SendClientMessage(playerid, RED, str);
if(Player[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS) // He has tried to login MAX_LOGIN_ATTEMPTS times (or more if that was to somehow happen..)
{
SendClientMessage(playerid, RED, "Error: Too many login attempts, you have been kicked.");
Player[playerid][LoginAttempts] = 0;
Kick(playerid);
return 1;
}
Dialog_Login(playerid);
}
mysql_free_result();
}
I only managed to get the first printf(esc_password). The rest have not been returned by the script into the console. This line also returns a warning, that I think could be the culprit, but I have no idea why it does that.
Код:
OnPlayerLogin(playerid);
Код:
C:\Users\Kamil\Desktop\SATC\gamemodes\satc.pwn(11516) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.