Timers decrease lag?
#1

Heey all,

I am making a cnr server so using much timers.
Is there a Timer Streamer or something for decreasing the lags?

Thanks Admigo
Reply
#2

I doubt you need that many timers, I bet you could cut down on most of them as you are probably making far too many of them when you may not even need them.

One example of a common mistake I see around here: Are you using timers to limit how often a certain command can be used? If so, you are doing it a very inefficient way.

Can you show us an example of the timers you use that you think may need to be optimized?
Reply
#3

Try not to use much timers I am sure there are better ways for some of your timers

EDIT: goddamn... -.-'
Reply
#4

Quote:
Originally Posted by admigo
Посмотреть сообщение
Heey all,

I am making a cnr server so using much timers.
Is there a Timer Streamer or something for decreasing the lags?

Thanks Admigo
It is not always necessary to use timers there are a lot more functions of times in the PAWN you can use them. Also, I've observe that the timer makes the server lag to some extent. You can have a look in the pawn lang and decide if you want to use timer itself as there are tickcounts etc..

-FalconX
Reply
#5

I think i am only use 6 timers but sometimes my server lags that if i am typing something the message show about 5 seconds later and sometime my game clock is stuck then about some seconds it starting again so lag by timers i think.
Reply
#6

Try to categorize timers,don't use it too much or it will cause lag.Regroup the timers.Example:

If you have to check players hp/armour and money,dont do 3 timers,just use one for all the 3 checks.
Reply
#7

What About Y_Timers? Whats does that include?
Reply
#8

That only changes the way you make timers, doesn't improve speed. If your timers are really fast, you shouldn't have a lot of code in them. Especially in OnPlayerUpdate, you need to keep the code in there to a minimal amount because it's called over 10 times a second.
Reply
#9

I have a one second timer with lots of variables like:
Код:
if(HasRobbedRecently[playerid]>=1)
{
 HasRobbedRecently[playerid]--;
}
Is this a problem?
Reply
#10

Quote:
Originally Posted by admigo
Посмотреть сообщение
I have a one second timer with lots of variables like:
Код:
if(HasRobbedRecently[playerid]>=1)
{
 HasRobbedRecently[playerid]--;
}
Is this a problem?
Do you use that to limit how often someone can rob? If so, why do you need a timer for that? Instead use tickcount, for example:

pawn Код:
new HasRobbedRecently[MAX_PLAYERS];

if((tickcount() - 60000) < HasRobbedRecently[playerid]) return SendClientMessage(playerid, COLOR_RED, "Error, you cannot rob now");// Player has not waited 60 seconds
else
{
    // Player has waited 60 seconds...do the robbery
    HasRobbedRecently[playerid] = tickcount();
}
Doing it that way will avoid using timers and make things a lot cleaner
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)