#1

Hello guys.

I have this Rent Script where you jump on a bike and u get a dialog that says do you want to rent this bike and if you press YES you will play 50$.

I want to make per minute payment, for ex u get the bike and you pay 50$ and after every minute you pay 25$ while you are on the bike. U know what i mean?

How can I do that

Here is my rent script

Код:
if(IsAVelosipedCar(newcar))
		{
			if (HireCar[playerid] != newcar)
			{
				format(string,sizeof(string),"Za da go rentate ovaj velosiped\nStisnete ^RENT^\nZa da izlezete od velosipedo stisnete ^IZLEZ^\n{FF4040}CENA:20$/minuta");
				ShowPlayerDialog(playerid, 4464, DIALOG_STYLE_MSGBOX,"Rent Velosiped",string,"Rent","Izlez");
				TogglePlayerControllable(playerid, 0);
			}
		}
Код:
public IsAVelosipedCar(carid)
{
	for(new i = 0; i < sizeof(VelosipedCar); i++)
	{
		if(carid == VelosipedCar[i])	return 1;
	}
	return 0;
}
Код:
  		 if(dialogid == 4464)
          {
                        if(response)
                        {
                                TogglePlayerControllable(playerid,1);
                                GivePlayerMoney(playerid, -50);
                                SendClientMessage(playerid,COLOR_WHITE,"{FFA500}INFO:{FFFFFF}Vie rentavte za 50$");
                        }
                        if(!response)
                        {
                                TogglePlayerControllable(playerid,1);
                                RemovePlayerFromVehicle(playerid);
                                SendClientMessage(playerid,COLOR_WHITE,"{FFA500}INFO:{FFFFFF}Vie odbivte da rentate.");
						}
			      }
Thanmks
Reply
#2

anyone?
Reply
#3

Using SetTimerEx.

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); 
Now you create a new function (for the code that will be run every 1 minute, i.e. take $50)

PHP код:
forward PayPerMinute(playerid);
public 
PayPerMinute(playerid)
{
    
GivePlayerMoney(playerid, -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

PHP код:
 KillTimer(BikeRentTimer[playerid]); 
And that will stop the timer from running, otherwise it will just keep running every 1 minute.


Hope this helps
Reply
#4

Quote:
Originally Posted by ItsRobinson
Посмотреть сообщение
Using SetTimerEx.

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); 
Now you create a new function (for the code that will be run every 1 minute, i.e. take $50)

PHP код:
forward PayPerMinute(playerid);
public 
PayPerMinute(playerid)
{
    
GivePlayerMoney(playerid, -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

PHP код:
 KillTimer(BikeRentTimer[playerid]); 
And that will stop the timer from running, otherwise it will just keep running every 1 minute.


Hope this helps
Yep, thank you very much <3

Just I have no idea where to put the end timer, after they leave the bike ..


EDIT: I went like this
PHP код:
public IsAFaggioCar(carid)
{
    for(new 
0sizeof(FaggioCar); i++)
    {
        new 
playerid;
        if(
carid == FaggioCar[i])    return 1;
        
KillTimer(BikeRentTimer[playerid]);
    }
    return 
0;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)