SA-MP Forums Archive
recomendation save account mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: recomendation save account mysql (/showthread.php?tid=617740)



recomendation save account mysql - FelipeAndres - 25.09.2016

Hello
I have two questions

when saving an account OnPlayerDisconnect,
It is better to use mysql_function_query or mysql_query?

I've never used this
PHP Code:
public SavePlayer(playerid)
{
    new 
query[100];
    
mysql_format(dbquerysizeof(query), "UPDATE `players` SET money = %d, score = %d WHERE `nick` = '%e'"Money[playerid], Score[playerid], name(playerid));
    
mysql_query(dbqueryfalse);
    return 
1;

OR

I have always used this way, okay well?
PHP Code:
public SavePlayer(playerid)
{
    new 
query[100];
    
mysql_format(dbquerysizeof(query), "UPDATE `players` SET money = %d, score = %d WHERE `nick` = '%e'"Money[playerid], Score[playerid], name(playerid));
    
mysql_function_query(dbqueryfalse"""");
    return 
1;

other question:
rarely (almost never), some players lose their statistics.
It happens 1 time in 10000 so to speak, this only happens with statistics that are saved when the player is disconnected, for example score, money, etc.

PHP Code:
new query[100];
mysql_format(dbquerysizeof(query), "UPDATE `players` SET money = %d, score = %d WHERE `nick` = '%e'"Money[playerid], Score[playerid], name(playerid));
mysql_function_query(dbqueryfalse""""); 
thanks


Re: recomendation save account mysql - Konstantinos - 25.09.2016

1) Always use threaded queries.
2) The only reason I can think of it happen is if the query isn't executed in OnPlayerDisconnect and it is delayed which the variables eventually get reset.


Respuesta: recomendation save account mysql - FelipeAndres - 25.09.2016

thanks for answering

which of the two functions would be threaded?


Re: recomendation save account mysql - AndySedeyn - 25.09.2016

Neither. mysql_tquery is the function for threaded queries.


Respuesta: recomendation save account mysql - FelipeAndres - 25.09.2016

mysql_function_query is not the same as mysql_tquery?


Re: recomendation save account mysql - Konstantinos - 25.09.2016

mysql_function_query was a macro for mysql_tquery in R33+ versions.


Re: recomendation save account mysql - Rdx - 25.09.2016

Quote:
Originally Posted by Konstantinos
View Post
1) Always use threaded queries.
Why? It is gonna work without threaded query too.


Re: recomendation save account mysql - Konstantinos - 25.09.2016

Quote:
Originally Posted by Rdx
View Post
Why? It is gonna work without threaded query too.
Sure it will but the question was which one (non-threaded queries vs threaded queries) is better and the answer is obvious as we all know.


Respuesta: recomendation save account mysql - FelipeAndres - 25.09.2016

you could suggest something to avoid the problem of losing OnPlayerDisconnect statistics?
I would thank you a lot