Y_INI Save stats on 10-Seconds
#1

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

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

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

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

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

Like this?
Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("savestats",10000,true,"i",playerid);
	return 1;
}
forward savestats(playerid);
public savestats(playerid)
{
    SaveStats(playerid);
    return 1;
}
Reply
#7

Why not just make one timer instead of like 50+ to save the player's stats?
Reply
#8

Well why don't you try saving the stats under 'OnPlayerUpdate' callback?
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)