Timer...
#1

Ok so I'm having a bit of a headaiche here... I know how to make timers work etc publicly and continously and how to turn them off etc.. But I'm trying to make a timer that in my taxi's which are defined by vehicle models.. If the taxi metre is running which is done by setting /meter on I want to display something for each person inside the vehicle like Taxi Meter = $5-10-15-20-25-30 etc every second and give $5 a second to the driver and -$5 from the passenger and then when the /meter is turned off it stops. Or when the passenger (paying) or taxi driver leave the vehicle.

Could some one point me in the right direction or show me some example snippets of code? Really having a brain fuck over this lol! So frustrating as I know it can be done simply!

Phil
Reply
#2

SetTimer("disable", 30000, false); Like that

https://sampwiki.blast.hk/wiki/SetTimer
Reply
#3

Easy.
pawn Код:
new Timer[MAX_PLAYERS];//We'll use this to kill the timer,The reason why there is MAX_PLAYER is because the timer will start for each player, not in global
pawn Код:
Timer[playerid] = SetTimerEx("MyTimer",500,1,"i",playerid);//This will the timer only for the player.
//This is where most scripters fuck up, you should use SetTimerEx in case you want it to start only for the player
pawn Код:
forward MyTimer(playerid);
public MyTimer(playerid)
{
//if(meter[playerid] == 1)//Assuming you used a variable to detect if the meter is true or false
{
//this is the part where you should cost him money, maybe Money[playerid] ++;?
}
//else if(meter[playerid] == 0)//If the meter isn't true.
{
KillTimer(Timer[playerid]);
//That will simply kill the timer.
}
Reply
#4

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Easy.
pawn Код:
new Timer[MAX_PLAYERS];//We'll use this to kill the timer,The reason why there is MAX_PLAYER is because the timer will start for each player, not in global
pawn Код:
Timer[playerid] = SetTimerEx("MyTimer",500,1,"i",playerid);//This will the timer only for the player.
//This is where most scripters fuck up, you should use SetTimerEx in case you want it to start only for the player
pawn Код:
forward MyTimer(playerid);
public MyTimer(playerid)
{
//if(meter[playerid] == 1)//Assuming you used a variable to detect if the meter is true or false
{
//this is the part where you should cost him money, maybe Money[playerid] ++;?
}
//else if(meter[playerid] == 0)//If the meter isn't true.
{
KillTimer(Timer[playerid]);
//That will simply kill the timer.
}
Omg thankyou for explaining the SetTimerEx that made perfect sense lol! The one on the Wiki page is rather useless tbh! My brain fuck has been this entire time mainly because I didn't know how to set a timer to a player. This describes exactly what was holding me up and now I'll crack on finaly! Thanks alot pal +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)