Mysql OnPlayerDisconnect -
Abreezy - 09.08.2011
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
mysql_format(Handler, szQuery, "UPDATE `account` SET Money = %d, Level = %d WHERE Username` = '%e'", GetPlayerMoney(playerid), User[playerid][Level], pName(playerid));
printf("Data of player %s has been updated", pName(playerid));
return 1;
}
Anyone know why this is being ran ? It says data of player was updated, but the whole update format never happens, how can i fix this ?
Re: Mysql OnPlayerDisconnect -
Donya - 09.08.2011
pawn Код:
printf("Query: %s", szQuery);
?
Re: Mysql OnPlayerDisconnect -
PrawkC - 09.08.2011
does mysql_format also query?
Re: Mysql OnPlayerDisconnect -
Abreezy - 09.08.2011
Actually, I found a bigger error lol, the same username keeps getting registered into new lines
Re: Mysql OnPlayerDisconnect -
Abreezy - 09.08.2011
Anyone see an error in the following code:
pawn Код:
public OnPlayerConnect(playerid)
{
mysql_format(Handler, szQuery, "SELECT * FROM `account` WHERE Username = '%e'", pName(playerid));
mysql_store_result();
if(mysql_num_rows() > 0) {
ShowPlayerDialog(playerid, 20, DIALOG_STYLE_INPUT, "Hype Roleplay", "Welcome Back [ :: ] Enter your password below to login ", "Login", "Quit");
} else {
ShowPlayerDialog(playerid, 10, DIALOG_STYLE_INPUT, "Hype Roleplay", "Welcome to Hype-RP [ :: ] Enter a password to register ", "Register", "Quit");
}
mysql_free_result();
return 1;
}
No matter what, it keeps making me register the account, and since in my DB i have an id system aswell, I have 5 "Abreezy"s register, ids 2-6. How can I fix this, so there wont be repeated accounts?
Re: Mysql OnPlayerDisconnect -
Snipa - 09.08.2011
Personally, I like to format() then mysql_query();
Try:
if(mysql_num_rows != 0) {
//Found
}
else {
//Not found
}
Re: Mysql OnPlayerDisconnect -
[NoV]LaZ - 09.08.2011
Why would you escape a username in the first place ?
Re: Mysql OnPlayerDisconnect -
Abreezy - 09.08.2011
error 076: syntax error in the expression, or invalid function call
error on the if(mysql-----------
Re: Mysql OnPlayerDisconnect -
[NoV]LaZ - 09.08.2011
Quote:
Originally Posted by Abreezy
error 076: syntax error in the expression, or invalid function call
error on the if(mysql-----------
|
A function's parameters (if any) are enclosed in brackets, (), and in Snipa's 'example' he doesn't use them.
Re: Mysql OnPlayerDisconnect - [L3th4l] - 09.08.2011
if(mysql_num_rows() != 0)
Re: Mysql OnPlayerDisconnect -
Grim_ - 09.08.2011
mysql_format doesn't also send the query to the database. You need to call mysql_query after using mysql_format.