save player data on crash
#1

how do you make mysql save data when the player crashes or server restarts?
Reply
#2

onplayerdisconnect is called even if player crashes.
Reply
#3

but it doesnt seem to work
Reply
#4

You could just run a looping timer for, lets say, 5 minutes that would save the players data.
Reply
#5

I think that OnPlayerDisconnect is not called on player crash.
You should to what funky1234 said.
Reply
#6

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)
Reply
#7

It's impossible.
Reply
#8

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;
}
Reply
#9

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

so can you help me with the timer?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)