26.06.2012, 06:26
It really depends on what you're trying to do.
You're trying to make a speedometer so instead of using a timer, use the OnPlayerUpdate callback. It gets called around 30 times a sec, and it has a playerid parameter so you can avoid issues with foreach.
But if you actually need a timer use y_timers.
With y_timers, you don't have to use SetTimer, you don't have to forward any timers. The number between the [ ] is the tick rate, put in how often in milliseconds you want the function to be called.
You're trying to make a speedometer so instead of using a timer, use the OnPlayerUpdate callback. It gets called around 30 times a sec, and it has a playerid parameter so you can avoid issues with foreach.
But if you actually need a timer use y_timers.
pawn Код:
task Timer[1000]()
{
foreach(Player, i)
{
// if the player is in a vehicle
if(IsPlayerInAnyVehicle(i))
{
// math code here
// textdraw code here
}
}
return 1;
}