Function makes server crash -
Cameltoe - 13.06.2010
can anyone tell me why my function crashes the server?
Forward:
Код:
forward SaveUser(playerid);
Gamemodeinit:
Код:
SetTimer("SaveUser", 15000, true);
Saveuser function:
Код:
public SaveUser(playerid)
{
if (IsLogged[playerid] == 1)
{
new Score;
format(cfile, 128, userfile, GetName(playerid));
Score = dini_Int(cfile, "Minutes Ingame");
dini_IntSet(cfile, "Money", GetPlayerMoney(playerid));
dini_IntSet(cfile, "Deaths", GetPlayerDeaths(playerid));
dini_IntSet(cfile, "Kills", GetPlayerKills(playerid));
dini_IntSet(cfile, "Score", Score / 10);
SetPlayerMoney(playerid, dini_Int(cfile, "Money"));
SetPlayerScore(playerid, dini_Int(cfile, "Score"));
SetPlayerDeaths(playerid, dini_Int(cfile, "Deaths"));
SetPlayerKills(playerid, dini_Int(cfile, "Kills"));
GetPlayerPos(playerid, positionx, positiony, positionz);
dini_FloatSet(cfile, "X", positionx);
dini_FloatSet(cfile, "Y", positiony);
dini_FloatSet(cfile, "Z", positionz);
SavePlayerBagToFile(playerid);
}
return 1;
}
Annoys the crap outta me.. Thx for all help!
Re: Function makes server crash -
Retardedwolf - 13.06.2010
Saving the players every 15 seconds thats right.
Save during OnPlayerDisconnect would be better.
Re: Function makes server crash -
Cameltoe - 13.06.2010
Yes, but sometimes people crash.. what should i do?
Re: Function makes server crash -
Johndaone - 14.06.2010
OnPlayerDisconnect is also called when the player crashes.
Re: Function makes server crash -
Retardedwolf - 14.06.2010
If you read the wiki.
When people /q, get kicked/banned and when they crash it saves.
Re: Function makes server crash -
Cameltoe - 14.06.2010
Oh, so a timed function like that is just a waste then .. x) (correct me if im wrong)
Re: Function makes server crash -
shady91 - 14.06.2010
it should be settimerex or loop it through all players, but I only update players when they disconnect.
Re: Function makes server crash -
Johndaone - 14.06.2010
Quote:
Originally Posted by Cameltoe
Oh, so a timed function like that is just a waste then .. x) (correct me if im wrong)
|
I have a timer on 30 minutes, else i have it onplayerdisconnect
Re: Function makes server crash -
Cameltoe - 14.06.2010
Even when changning it to 30 sec it causes the server to crash.. server has been running for about 4 hours now! (without the Save func.)
but if i turn in it it crashes after 30 sek to 30 mins..
Re: Function makes server crash -
CyNiC - 14.06.2010
Try put it jointly:
pawn Код:
Score = dini_Int(cfile, "Minutes Ingame");
Like this:
pawn Код:
Score = dini_Int(cfile, "MinutesIngame");