Updating every second? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Updating every second? (
/showthread.php?tid=581231)
Updating every second? -
Mouiz - 11.07.2015
How to make it update every second?
PHP код:
public Data(name[], value[])
{
new INI:File = INI_Open(SERVER_FILE);
INI_SetTag(File, "server");
INI_WriteInt(File,"Account Ids",ServerInfo[Accountid]);
INI_WriteInt(File,"Announce",ServerInfo[Announce]);
INI_WriteInt(File,"Auto_Login",ServerInfo[AutoLog]);
INI_WriteInt(File,"Locked",ServerInfo[sLocked]);
INI_WriteInt(File,"Read_PersonalMessages",ServerInfo[ReadPms]);
INI_WriteInt(File,"Max_Ping",ServerInfo[MaxPing]);
INI_WriteInt(File,"Read_Commands",ServerInfo[ReadCmds]);
INI_WriteInt(File,"Chat",ServerInfo[Chat]);
INI_WriteInt(File,"Hours",ServerInfo[H]);
INI_WriteInt(File,"Minuites",ServerInfo[M]);
INI_WriteInt(File,"Seconds",ServerInfo[S]);
INI_Close(File);
}
Re: Updating every second? -
HydraHumza - 11.07.2015
make a timer on Onplayerupdate
Re: Updating every second? -
Threshold - 11.07.2015
First of all, that's a very bad idea. Opening and writing to a file every second, it's just unnecessary. If someone wants to know how long the server has been up, refer to your variables "ServerInfo[H], [M] and [S]". The only time you should update anything in a file is probably when a value is actually changed. Anything that needs to be updated every second should be avoided if possible.
What are you trying to update per second?
Re: Updating every second? -
Sime30 - 11.07.2015
Quote:
Originally Posted by Humza
make a timer on Onplayerupdate
|
LOL! NO!
Make a global timer outside OnPlayerUpdate and update those things there
Edit:
Read Threshold's advice.
Re: Updating every second? -
Mouiz - 11.07.2015
Quote:
Originally Posted by Threshold
First of all, that's a very bad idea. Opening and writing to a file every second, it's just unnecessary. If someone wants to know how long the server has been up, refer to your variables "ServerInfo[H], [M] and [S]". The only time you should update anything in a file is probably when a value is actually changed. Anything that needs to be updated every second should be avoided if possible.
What are you trying to update per second?
|
I used it for account ids because if server crashed so the account ids will not be saved because i put the account id updating under "OnGameModeExit" and it will effect the whole database
Re: Updating every second? -
Threshold - 11.07.2015
You should save it whenever the account IDs are actually changed. So lets say someone registers, you add 1 to the account IDs. Save the account IDs then, not in a timer.