Mysql OnPlayerDisconnect
#1

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 ?
Reply
#2

pawn Код:
printf("Query: %s", szQuery);
?
Reply
#3

does mysql_format also query?
Reply
#4

Actually, I found a bigger error lol, the same username keeps getting registered into new lines
Reply
#5

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?
Reply
#6

Personally, I like to format() then mysql_query();

Try:

if(mysql_num_rows != 0) {
//Found
}
else {
//Not found
}
Reply
#7

Why would you escape a username in the first place ?
Reply
#8

error 076: syntax error in the expression, or invalid function call

error on the if(mysql-----------
Reply
#9

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.
Reply
#10

if(mysql_num_rows() != 0)
Reply
#11

mysql_format doesn't also send the query to the database. You need to call mysql_query after using mysql_format.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)