06.06.2010, 14:38
Hey, Heres my login command
Theres something wrong with it, when i register (my register command works fine) and after i login it says its the wrong pass?
I cant see whats wrong, and im new to mysql so i dont know all the callbacks yet.
pawn Код:
CMD:login(playerid, params[])
{
new LogPass[24], pname[MAX_PLAYER_NAME], str[128];
if(sscanf(params, "s", LogPass)) return SENDMSG(playerid, COLOR_GREENLIGHT, "[WR Usage]: /login [Password]");
else if (strlen(LogPass) > 24) return ERRORMSG(playerid, "[WR Server]: The password is you typed is too long, try again");
else if(IsLogged[playerid] == 1) return ERRORMSG(playerid, "[WR Server]: You're already logged in!");
else
{
GetPlayerName(playerid, pname, sizeof(pname));
format(query, sizeof(query), "SELECT * FROM users WHERE username = '%s'", PlayerName);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
format(query, sizeof(query), "SELECT password FROM users WHERE username = '%s'", PlayerName);
mysql_query(query);
mysql_store_result();
if(strlen(query) == strlen(LogPass)) // Change to != if its all wrong on login
{
LoadStats(playerid);
}
else
{
format(str, sizeof(str), "logpass: %s, query: %s", strval(LogPass), strval(query));
ERRORMSG(playerid, "[WR Server]: Login failed, try again");
}
}
else
{
SENDMSG(playerid, COLOR_GREENLIGHT, "[WR Server]: This username is not found in the database, please use /register");
}
}
return 1;
}
I cant see whats wrong, and im new to mysql so i dont know all the callbacks yet.