18.02.2019, 18:40
Using SetTimerEx.
Now you create a new function (for the code that will be run every 1 minute, i.e. take $50)
This timer will loop until you use KillTimer.
When the player stops renting the bike (when they get off or something, whatever you choose) you'll need to kill the timer like so
And that will stop the timer from running, otherwise it will just keep running every 1 minute.
Hope this helps
PHP код:
//Under the playing being told he's paying $50
//You'll be needing a public variable for each player. i.e. new BikeRentTimer[MAX_PLAYERS];
BikeRentTimer[playerid] = SetTimerEx("PayPerMinute", 60000 /*60000(miliseconds) = 1 minute*/, true, "i", playerid);
PHP код:
forward PayPerMinute(playerid);
public PayPerMinute(playerid)
{
GivePlayerMoney(playerid, -50);
}
When the player stops renting the bike (when they get off or something, whatever you choose) you'll need to kill the timer like so
PHP код:
KillTimer(BikeRentTimer[playerid]);
Hope this helps