Question
#1

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

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

So to kill the timer is an good idea thanks for ur reply
Reply
#4

hey mahdi
Reply
#5

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

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

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
    }
}
Reply
#8

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?
Reply
#9

Yes you can switch
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)