SA-MP Forums Archive
Individual player timers? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Individual player timers? (/showthread.php?tid=161739)



Individual player timers? - VictorMartinez - 21.07.2010

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


Re: Individual player timers? - Kar - 21.07.2010

a loop you mean?

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



Re: Individual player timers? - VictorMartinez - 21.07.2010

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?


Re: Individual player timers? - Kar - 21.07.2010

ya eays

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


Re: Individual player timers? - DJDhan - 21.07.2010

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.


Re: Individual player timers? - VictorMartinez - 21.07.2010

thanks daaaaawgs