Function makes server crash
#1

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!
Reply
#2

Saving the players every 15 seconds thats right.

Save during OnPlayerDisconnect would be better.
Reply
#3

Yes, but sometimes people crash.. what should i do?
Reply
#4

OnPlayerDisconnect is also called when the player crashes.
Reply
#5

If you read the wiki.

When people /q, get kicked/banned and when they crash it saves.
Reply
#6

Oh, so a timed function like that is just a waste then .. x) (correct me if im wrong)
Reply
#7

it should be settimerex or loop it through all players, but I only update players when they disconnect.
Reply
#8

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

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

Try put it jointly:
pawn Код:
Score = dini_Int(cfile, "Minutes Ingame");
Like this:
pawn Код:
Score = dini_Int(cfile, "MinutesIngame");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)