Posts: 284
Threads: 77
Joined: Nov 2013
I have alot of Timers in my server about 14 one, do i have to Kill timers when i finish from? after return function, because every 30 seconds server lagg 2 seconds then complete, if i not killed the timer it would keep loops?
Posts: 760
Threads: 22
Joined: May 2011
Reputation:
0
Not sure if they would loop like with ****** timers (some of his, he made a couple lol) has so they run just x amount of times. However killing them is always a good idea as they (yes I am guessing now, please don't sue me) take up some space while being there in the background. Same for some reason goes with every object etc, I don't know why but people always told me to delete everything in OnGameModeExit, however I don't know why if anyone please tell. xD
But yes kill them after using them please.
Posts: 284
Threads: 77
Joined: Nov 2013
So to kill the timer is an good idea
thanks for ur reply
Posts: 7
Threads: 4
Joined: Nov 2013
Posts: 284
Threads: 77
Joined: Nov 2013
Quote:
Originally Posted by BlackBank3
You could also optimize your timers.
Also about how much timers are you talking and what kind of stuff are in the callbacks/timers?
|
Код:
if(DMZone[playerid] >= 0)
{
SetPlayerHealth(playerid, 100000);
SetTimerEx("AntiSpawnkill",4000,0,"i",playerid);
}
Called this:
Код:
forward AntiSpawnkill(playerid);
public AntiSpawnkill(playerid)
{
if(DMZone[playerid] == 0)
{
SetPlayerHealth(playerid,100);
}
if(DMZone[playerid] == 1)
{
SetPlayerHealth(playerid,100);
}
if(DMZone[playerid] == 2)
{
SetPlayerHealth(playerid,100);
}
if(DMZone[playerid] == 3)
{
SetPlayerHealth(playerid,100);
}
if(DMZone[playerid] == 4)
{
SetPlayerHealth(playerid,100);
}
return 1;
}
Posts: 284
Threads: 77
Joined: Nov 2013
Quote:
Originally Posted by Burridge
AFAIK having lots of separate timers that work at the same time (for instance 5 1 second timers running at the same time) can cause some lag (especially with more players). I tend to have a global timer for everything that runs at the same time, then add checks so that it only runs the part of the timer that needs to run per player. (I probably explained that badly, sorry if it makes no sense).
Also IMHO you could make your timer much tidier and still work exactly the same. By using a switch statement.
pawn Код:
forward AntiSpawnkill(playerid); public AntiSpawnkill(playerid) { switch(DMZone[playerid]) { case 0 .. 4: SetPlayerHealth(playerid,100); // 0 - 4 } }
|
Код:
forward AntiSpawnkill(playerid);
public AntiSpawnkill(playerid)
{
switch(DMZone[playerid])
{
case 0 : SetPlayerHealth(playerid,100); // 0 - 4
case 1 : SetPlayerHealth(playerid,100); // 0 - 4
.
.
.
}
}
Like that?
Posts: 498
Threads: 24
Joined: Apr 2013