Individual player timers?
#1

How do I make individual player timers? Like using MAX_PLAYERS and where there is a timer for each [playerid]
Reply
#2

a loop you mean?

pawn Code:
for(new i = 0; i <MAX_PLAYERS; i++)
    {
Reply
#3

lol let's say I want a textdraw to hide for a player after a certain time, I would need every player to have their own timer, like arrayed. Does that make sense?
Reply
#4

ya eays

pawn Code:
SetTimerEx("HideDraw", 15000, 0, "i", playerid);
notice the playerid in it
Reply
#5

Code:
new timer[MAX_PLAYERS];
Ex:

Code:
public OnPlayerConnect(playerid)
{
        timer[playerid] = SetTimerEx("fast",25000,1,"i",playerid);
        return 1;
}
The above code will call the function "fast(playerid)" (it's random) when a player connects and will repeat every 25 seconds.

We could have fun like so:

Code:
forward fast(playerid);
public fast(playerid)
{
        if(IsPlayerInAnyVehicle(playerid))
        {
                new veh = GetPlayerVehicleID(playerid);
                new Float:x,Float:y,Float:z;
                GetVehiceVelocity(veh,x,y,z);
                SetVehicleVelocity(veh,x+50,y,z);
        }
        return 1;
}
Now every 25 seconds it will check if the player is in a vehicle, will give him a boost!

If you have more players, it wouldn't be really wise to use per-player-timers. You could use a "for" loop every 25 seconds.
Reply
#6

thanks daaaaawgs
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)