Y_INI Save stats on 10-Seconds -
Bug. - 29.10.2012
Hey all, i have that register system:
https://sampforum.blast.hk/showthread.php?tid=273088
Now the system save the stats only when i LogOut "/q".
How make a Timer or somethinglike this to save the stats evrey 10-Seconds
( Sorry 4 bad english ). xD
Re: Y_INI Save stats on 10-Seconds -
playbox12 - 29.10.2012
Why would you want to save every 10 seconds? Why not save when something actually changes? A lot of people are afraid of data loss due to crashes but I wouldn't recommend saving it in such a small interval. Say the player buys something expensive, just save when that happens, don't save small changes like 10 dollar, but maybe start at 10,000.
Re: Y_INI Save stats on 10-Seconds -
gtakillerIV - 29.10.2012
Make a timer and start it under OnGameModeInit, then make the timer loop for everyone in the server and check if he is connected after that save his/her stats.
OR just save the player's stats when he leaves(OnPlayerDisconnect). <==== I recommend this one.
Re: Y_INI Save stats on 10-Seconds -
Bug. - 29.10.2012
I got a TDM Server - and when i kill someon and i do stats i see: kill: 2 , the last kill when i "/q"
EDIT: Can you helpme with the timer i don't know how to make it.
Re: Y_INI Save stats on 10-Seconds -
[D]ry[D]esert - 29.10.2012
add this
pawn Код:
SetTimerEx("savestats",10000,true,"i",playerid);
under OnPlayerConnect
and this
pawn Код:
forward savestats(playerid);
public savestats(playerid)
{
SaveStats(playerid); //change it to your stock name
return 1;
}
under your OnPlayerConnect.
Re: Y_INI Save stats on 10-Seconds -
Bug. - 29.10.2012
Like this?
Код:
public OnPlayerConnect(playerid)
{
SetTimerEx("savestats",10000,true,"i",playerid);
return 1;
}
forward savestats(playerid);
public savestats(playerid)
{
SaveStats(playerid);
return 1;
}
Re: Y_INI Save stats on 10-Seconds -
gtakillerIV - 29.10.2012
Why not just make one timer instead of like 50+ to save the player's stats?
Re: Y_INI Save stats on 10-Seconds -
Lordzy - 29.10.2012
Well why don't you try saving the stats under 'OnPlayerUpdate' callback?
Re: Y_INI Save stats on 10-Seconds -
[D]ry[D]esert - 29.10.2012
Quote:
Originally Posted by gtakillerIV
Why not just make one timer instead of like 50+ to save the player's stats?
|
and this is another way.
pawn Код:
OnPlayerGamemodeInt()
{
SetTimer("savestats",10000,true);
//other codes here
}
forward savestats();
public savestats()
{
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if (IsPlayerConnected(i))
{
SaveStats(i);
}
}
}
Re: Y_INI Save stats on 10-Seconds -
[D]ry[D]esert - 29.10.2012
Quote:
Originally Posted by Bug.
i put it on the end od script:
Код:
G:\CokeTDM [0.3e]\gamemodes\NpTDM.pwn(1243) : error 017: undefined symbol "SaveStats"
G:\CokeTDM [0.3e]\gamemodes\NpTDM.pwn(1248) : error 030: compound statement not closed at the end of file (started at line 1239)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
|
Quote:
Originally Posted by [D]ry[D]esert
and this is another way.
pawn Код:
forward savestats(); public savestats() { for (new i = 0; i != MAX_PLAYERS; ++i) { if (IsPlayerConnected(i)) { SaveStats(i); } } }
|
place this at the end of your script