SA-MP Forums Archive
Save crashes server MYSQL - 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: Save crashes server MYSQL (/showthread.php?tid=500449)



Save crashes server MYSQL - Blademaster680 - 13.03.2014

Whenever I disconnect from the server it crashes in the middle of the save.
Here is the code:
Код:
stock SaveStats(playerid)
{
	new query[1024];
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	
	format(query, sizeof(query), "UPDATE playerdata SET Cash=%i, PosX=%f, PosY=%f, PosZ=%f, Interior=%f, VirtualWorld=%f, AdminLevel=%i WHERE Name='%s'",
	PlayerInfo[playerid][Cash],
	x,
	y,
	z,
	PlayerInfo[playerid][Int],
	PlayerInfo[playerid][VW],
	PlayerInfo[playerid][Admin],
	GetName(playerid));
	
	mysql_query(query);
	printf("Player Saved");
	return 1;
}
Here is the server log:
Quote:

[13:04:11] [join] Jason_Smith has joined the server (0:127.0.0.1)
[13:04:20] sscanf warning: String buffer overflow.
[13:04:30] RCON (In-Game): Player #0 (Jason_Smith) has logged in.
[13:04:34] [debug] Server crashed while executing RP_Mysql.amx
[13:04:34] [debug] AMX backtrace:
[13:04:34] [debug] #0 native fwrite () [004056e0] from samp-server.exe
[13:04:34] [debug] #1 0003893c in ?? (0x0003bd6c, 0x0003fb44) from RP_Mysql.amx
[13:04:34] [debug] #2 0003eb3c in public cmd_makeadmin (0x00000000, 0x0003be40) from RP_Mysql.amx
[13:04:34] [debug] #3 native CallLocalFunction () [00472ad0] from samp-server.exe
[13:04:34] [debug] #4 000064d4 in public OnPlayerCommandText (0x00000000, 0x0003be0c) from RP_Mysql.amx
[13:04:34] [debug] Native backtrace:
[13:04:34] [debug] #0 77cf22d2 in ?? () from C:\Windows\SysWOW64\ntdll.dll
[13:04:34] [debug] #1 00493990 in ?? () from samp-server.exe
[13:04:34] [debug] #2 0040531e in ?? () from samp-server.exe




Re: Save crashes server MYSQL - Ruben_Alonso - 13.03.2014

Are you sure it's the saving query that is causing the crash?

Also, inside your format function you should change this:

Interior=%f, VirtualWorld=%f

to this:

Interior=%i, VirtualWorld=%i

Both of the variables are not float i belieave.


Re: Save crashes server MYSQL - xo - 13.03.2014

pawn Код:
stock SaveStats(playerid)
{
    new query[400];
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    format(query, sizeof(query), "UPDATE playerdata SET Cash='%d', PosX='%f', PosY='%f', PosZ='%f', Interior='%d', VirtualWorld='%d', AdminLevel='%d' WHERE Name='%s'",
    PlayerInfo[playerid][Cash],x,y,z,PlayerInfo[playerid][Int],PlayerInfo[playerid][VW],PlayerInfo[playerid][Admin],GetName(playerid));
    mysql_query(query);
    printf("Player Saved");
    return 1;
}