Timer question
#1

I'm making a speedo and whats better:
-Making just 1 timer looping threw all players and getting their speed and setting the textdraw string
or
-Making a timer for every player and getting their speed setting the textdraw string?
Because since iv made this the 1 big timer looping threw all players i experienced some lag in my server.
Reply
#2

Quote:
Originally Posted by Delux13
Посмотреть сообщение
Because since iv made this the 1 big timer looping threw all players i experienced some lag in my server.
How many players do you have on your server? And are you checking to see if they're in a vehicle / connected aswell?

Quote:
Originally Posted by ******
Посмотреть сообщение
I would however recommend using y_timers which is designed to balance the timers used in a mode over time so they don't all trigger at once (as they are often all started at once with the same delays). The next version will also have options for per-player timers too.
I agree, although i have to say i don't use them. From what i have read about them, they seem to do your job pretty well, along with, well, anything

--
Example timer:
This is the way i do it (well, the reduced version, my version is bigger and logs distance)
pawn Код:
public SpeedTimer()
{
    static string[64];
    for(new i; i < GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            format(string, sizeof(string), "Speed: %i", GetPlayerSpeed(i));
            SetSpeedString(i, string);
        }
    }
}
Reply
#3

Two years ago, I made a system to check if the player had a crash with their vehicle. I thought a timer per player would do the trick, but it seemed that a loop through all players worked better. Now I'm using y_timers, although I dumped my vehicle crash system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)