How to add fuel per second?
#8

well create a timer like this
Код:
SetTimerEx("refillcar",1000,1,"d",playerid);
then create the "refillcar"
Код:
forward refillcar(playerid);
public refillcar(playerid)
{
Fuel[playerid]++;
}
note that this will refill and not stop refilling, to make it stop after x times you need to create 3 new variables, 1 for the amount it needs to refill, another to count up to that number and another one for the timer.
like this.

top of the script
Код:
new refilltimes[MAX_PLAYERS];
new refillcount[MAX_PLAYERS];
new refilltimer[MAX_PLAYERS];
then in the /refill command
Код:
refilltimes[playerid] = 100-Fuel[playerid];
refillcount[playerid] = 0;
killtimer(refilltimer[playerid]);
refilltimer[playerid] = SetTimerEx("refillcar",1000,1,"d",playerid);
then in the timer
Код:
if(refillcount[playerid] == refilltimes[playerid]) killtimer(refilltimer[playerid]);
refillcount[playerid]++;
Reply


Messages In This Thread
How to add fuel per second? - by lmfaoown - 06.03.2010, 23:04
Re: How to add fuel per second - by GaGlets(R) - 06.03.2010, 23:06
Re: How to add fuel per second - by lmfaoown - 06.03.2010, 23:25
Re: How to add fuel per second - by Namaco - 06.03.2010, 23:26
Re: How to add fuel per second - by lmfaoown - 06.03.2010, 23:27
Re: How to add fuel per second - by lmfaoown - 06.03.2010, 23:39
Re: How to add fuel per second - by lmfaoown - 07.03.2010, 01:30
Re: How to add fuel per second? - by cessil - 07.03.2010, 01:44
Re: How to add fuel per second? - by lmfaoown - 07.03.2010, 01:46
Re: How to add fuel per second? - by cessil - 07.03.2010, 01:49

Forum Jump:


Users browsing this thread: 3 Guest(s)