One "global" timer or "Per-player" timer?
#1

I've been thinking stuff about my speedometer timers, and realized that I could just make a 1 global timer, instead of doing it "Per-Player", but.. What's better?
Global Timer: VehicleTimer = SetTimer("VehicleT", 1000, true);
Per-Player Timer: VehicleTimer[ playerid ] = SetTimerEx("VehicleT", 1000, true);

The current good side i see for the Global timer is: Less overall timers
But the bad side is, possible lag?

Here's my speedometer timer callback;
pawn Код:
PUB:VehicleT(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vID = GetPlayerVehicleID(playerid), string[142], string2[3], Float:rotation, Float:vhealth;
        GetVehicleZAngle(vID, rotation), GetVehicleHealth(vID, vhealth);
        new direction = floatround(rotation,floatround_round);
        while(direction > 360) direction -= 360;
        while(direction < 0) direction += 360;
        switch(direction)
        {
            case 0..22: string2 = "N";
            case 23..67: string2 = "NW";
            case 68..112: string2 = "W";
            case 113..157: string2 = "SW";
            case 158..202: string2 = "S";
            case 203..247: string2 = "SE";
            case 248..292: string2 = "E";
            case 293..337: string2 = "NE";
            case 338..360: string2 = "N";
        }
        format(string, sizeof(string), "~w~VEHICLE: ~y~%s~n~~w~SPEED: ~y~%d KM/H~n~~w~LOCATION: ~y~%s~n~~w~DIRECTION: ~y~%s~n~~w~HEALTH: ~y~%0.0f%%",VehicleNames[GetVehicleModel(vID)-400], GetPlayerSpeed(playerid), GetPlayerArea(playerid), string2, vhealth);
        TextDrawSetString(VehicleInfo[playerid], string);
        TextDrawShowForPlayer(playerid, VehicleInfo[playerid]);
        string = "\0";
    }
    else KillTimer(VehicleTimer[playerid]), TextDrawHideForPlayer(playerid, VehicleInfo[playerid]), TextDrawHideForPlayer(playerid, VehicleBox[playerid]);
    return 1;
}
Should I change something If i want to make it a global timer? (Except the obvious(The playerid, add loop ..))
Reply


Messages In This Thread
One "global" timer or "Per-player" timer? - by Kyance - 15.11.2014, 06:39
Re: One "global" timer or "Per-player" timer? - by Bakr - 15.11.2014, 08:23
Re: One "global" timer or "Per-player" timer? - by Virtual1ty - 15.11.2014, 08:25
Re : One "global" timer or "Per-player" timer? - by S4t3K - 15.11.2014, 09:13
Re: One "global" timer or "Per-player" timer? - by Bakr - 15.11.2014, 09:44
Re: One "global" timer or "Per-player" timer? - by Kyance - 15.11.2014, 11:47
Re: One "global" timer or "Per-player" timer? - by Bakr - 15.11.2014, 12:35
Re: One "global" timer or "Per-player" timer? - by Threshold - 15.11.2014, 14:31
Re: One "global" timer or "Per-player" timer? - by Kyance - 15.11.2014, 16:30

Forum Jump:


Users browsing this thread: 1 Guest(s)