save player data on crash - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: save player data on crash (
/showthread.php?tid=214832)
save player data on crash -
THE_KNOWN - 22.01.2011
how do you make mysql save data when the player crashes or server restarts?
Re: save player data on crash -
Macluawn - 22.01.2011
onplayerdisconnect is called even if player crashes.
Re: save player data on crash -
THE_KNOWN - 22.01.2011
but it doesnt seem to work
Re: save player data on crash -
Ash. - 22.01.2011
You could just run a looping timer for, lets say, 5 minutes that would save the players data.
Re: save player data on crash -
Alex_Valde - 22.01.2011
I
think that OnPlayerDisconnect is not called on player crash.
You should to what funky1234 said.
Re: save player data on crash -
THE_KNOWN - 22.01.2011
buti want it to save the players exact position on crash (i thought of useing a loop for everysecond but i think itll increase cpu usage)
Re: save player data on crash -
sabretur - 22.01.2011
It's impossible.
Re: save player data on crash -
THE_KNOWN - 22.01.2011
ok then can you guys help me how to set a timer for it?
here is the saving part which is called on player disconnect.
Код:
SavePlayer(playerid)
{
if(!PlayerLogged[playerid])
return 0;
Money[playerid] = GetPlayerMoney(playerid);
skin[playerid] = GetPlayerSkin(playerid);
GetPlayerPos(playerid, X[playerid],Y[playerid],Z[playerid]);
GetPlayerFacingAngle(playerid, Ang[playerid]);
CheckMySQL();
new string[256];
format(string, sizeof(string), "UPDATE Users SET Money='%d',skin='%d',X='%f',Y='%f',Z='%f',Angle='%f',dlic='%d' WHERE Name='%s'", Money[playerid], skin[playerid],X[playerid],Y[playerid],Z[playerid],Ang[playerid],dlic[playerid], Name[playerid]);
mysql_query(string);
return 1;
}
Re: save player data on crash -
Alex_Valde - 22.01.2011
Yeah, you can't actually do it (or I can't thing of a way to do this).
But you can start a timer with save time between 4<x secs what can save pos.
Every second loop will really drain your CPU.
Re: save player data on crash -
THE_KNOWN - 22.01.2011
so can you help me with the timer?