SA-MP Forums Archive
[Help] MySQL saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] MySQL saving (/showthread.php?tid=630794)



[Help] MySQL saving - Sibuscus - 18.03.2017

Now that I finally converted to the MySQL system, It's been kindda hard. I want when the player disconnects all the stats to be saved, so I have

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
day,year,month;
    
getdate(year,month,day);
    new 
query[128];
    new 
Float:xFloat:yFloat:zFloat:a;
    
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playerida);
    
mysql_format(g_Sqlquerysizeof(query), "UPDATE `accounts` SET `Level` = %d, `Admin` = %d, `Cash` = %d, `Kills` = %d, `Deaths` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f, `Warnings` = %d, `isBanned` = %d WHERE `ID` = %d",
    
PlayerInfo[playerid][Level], PlayerInfo[playerid][Admin], GetPlayerMoney(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], xyzaPlayerInfo[playerid][Warnings], PlayerInfo[playerid][isBanned], PlayerInfo[playerid][ID]);
    
mysql_tquery(g_Sqlquery"""");
    return 
1;

When I added this for my /makeadmin command:

Код:
mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `Admin` = %d WHERE `ID` = %d", level, PlayerInfo[givingID][ID]);
mysql_tquery(g_Sql, query, "", "");

The admin level gets saved here. BEFORE I added these lines, it wouldn't save on OnPlayerDisconnect .But, It's a pain in the ass to add these lines for every command and everything. So, how do I make all of these stats save when the player disconnects, as my onPlayerDisconnect doesn't work, obviously