One global timer vs. multiple timers
#17

Quote:
Originally Posted by LocMax
View Post
Well this is basically one example how it does:

pawn Code:
if(PlayerInfo[i][Jail] > 0) PlayerInfo[i][Jail]--;
else if(PlayerInfo[i][Jail] == 0)
{
      unjail
}
So you think it'd be better if it was OnPlayerUpdate?
Performance-wise, wouldn't make any lag and so on?
Your code won't work properly (if you were to use that in OPU) if the player goes AFK since the updates are not sent when a player is paused.Or you could consider it to be a new feature where the countdown doesn't decrease if the player goes AFK :P

You can optimize it:

pawn Code:
if(GetTickCount() > PlayerInfo[i][JailReleaseTick) { unjail }
where JailReleaseTick is when the player must be unjailed.If the player isn't jailed then set JailReleaseTick to FLOAT_INFINITY.

Though there is a function call in the above code, it hardly makes any difference.You can make a local variable and call GetTickCount just once and use the same tick for other checks.

At end of the thread, cessil uses OPU for making a SYNC System and for many anti-cheat checks.
https://sampforum.blast.hk/showthread.php?tid=220089

Quote:

wouldn't make any lag and so on

It is a myth that "adding code to OPU will slow down the server".

I use OPU for most of the simple anti-cheat checks and it does no harm!

I am guessing that using many timers will internally slow down the server because it needs to check every timer in every server tick!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)