mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = '%d', `Age` = '%d', `Pos_x` = '%f', `Pos_y` = '%f', `Pos_z` = '%f', `Skin` = '%d', `Job` = '%d', `AccLock` = '%d' WHERE `USERNAME` = '%e'" , PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pAccLock], pName); mysql_tquery(Database, DB_Query);
enum pInfo { ID, pPass[65], Salt[11], PasswordFails, Kills, Score, Deaths, pCash, pAdmin, pSex, pAge, Float:pPos_x, Float:pPos_y, Float:pPos_z, pSkin, pTeam, pAccent, Cache: Player_Cache, LoggedIn, pEmail, pAccLock }
cache_get_value_int(0, "AccLock", PlayerInfo[playerid][pAccLock]);
if(PlayerInfo[playerid][pAccLock] == 1) { new string[80]; SendClientMessage(playerid, COLOR_GREEN, "SERVER: This account is locked, visit the forum to unlock it!"); SendClientMessage(playerid, COLOR_GREEN, "> xxxxxxx"); SetTimerEx("KickPlayer",500,false,"i",playerid); format(string, sizeof(string), "WARNING: %s tried to log into a locked account.", RPName(playerid)); SendAdminMessage(COLOR_YELLOW, string); LockLog(string); }
People always blaming the problem on MySQL while its rarely got anything to do with it. I suppose pEmail stores text? Yet you haven't declared it as an array. Since pAccLock is right after it you will overwrite that value when you store the email. It's not a coincidence that you get those "random" values because these are the characters for the letters H, b and a, respectively.
And oh, don't use the name to query once you've retrieved the ID. |
mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = '%d', `Age` = '%d', `Pos_x` = '%f', `Pos_y` = '%f', `Pos_z` = '%f', `Skin` = '%d', `Job` = '%d', `AccLock` = '%d' WHERE `USERNAME` = '%e'"
Код:
mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = '%d', `Age` = '%d', `Pos_x` = '%f', `Pos_y` = '%f', `Pos_z` = '%f', `Skin` = '%d', `Job` = '%d', `AccLock` = '%d' WHERE `USERNAME` = '%e'" |
forward Check_Account(playerid);
public Check_Account(playerid)
{
if(cache_num_rows() > 0)
{
cache_get_value_name_int(0, "AccLock", PlayerInfo[playerid][pAccLock]);
Check_Ban(playerid);
}
else
{
Register dialogs
}
return 1;
}
forward Check_Ban(playerid);
public Check_Ban(playerid)
{
if(PlayerInfo[playerid][pAccLock] == 1)
{
new string[80];
SendClientMessage(playerid, COLOR_GREEN, "SERVER: This account is locked, visit the forum to unlock it!");
SendClientMessage(playerid, COLOR_GREEN, "> xxxxxxx");
SetTimerEx("KickPlayer",500,false,"i",playerid);
format(string, sizeof(string), "WARNING: %s tried to log into a locked account.", RPName(playerid));
SendAdminMessage(COLOR_YELLOW, string);
LockLog(string);
}
else
{
Login Dialog
}
return 1;
}
I'm very surprised that no one has mentioned the fact your treating int like strings in MySQL.
You only need to put '' around data that is of a string type: '%d' - Invalid Type ( should be %d without '' ) '%f' - Invalid Type ( this is a float not a string ). '%e' - Valid Type ( since the escaped string is outputted ) '%s' - Valid Type ( since its a string ) I also hope that not every column in your table structure is a string, as this is really bad practice and will slow down your query. |