Question -
MahdiGames - 10.01.2014
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?
Re: Question -
Hansrutger - 10.01.2014
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.
Re: Question -
MahdiGames - 10.01.2014
So to kill the timer is an good idea

thanks for ur reply
Re: Question -
NightSpore - 10.01.2014
hey mahdi
Re: Question -
BlackBank - 10.01.2014
Quote:
Originally Posted by MahdiGames
So to kill the timer is an good idea  thanks for ur reply
|
You could also optimize your timers.
Also about how much timers are you talking and what kind of stuff are in the callbacks/timers?
Re: Question -
MahdiGames - 11.01.2014
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;
}
Re: Question -
Burridge - 11.01.2014
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
}
}
Re: Question -
MahdiGames - 11.01.2014
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?
Re: Question -
amirab - 11.01.2014
Yes you can switch
Re: Question -
Burridge - 11.01.2014
pawn Код:
forward AntiSpawnkill(playerid);
public AntiSpawnkill(playerid)
{
switch(DMZone[playerid])
{
case 0 .. 4: SetPlayerHealth(playerid,100); // 0 - 4
}
}
Is the same as
pawn Код:
forward AntiSpawnkill(playerid);
public AntiSpawnkill(playerid)
{
switch(DMZone[playerid])
{
case 0: SetPlayerHealth(playerid,100);
case 1: SetPlayerHealth(playerid,100);
case 2: SetPlayerHealth(playerid,100);
case 3: SetPlayerHealth(playerid,100);
case 4: SetPlayerHealth(playerid,100);
}
}
My example simply loops through the first 4 in one line since each case does EXACTLY the same thing anyway.