How to make a car rentable
#7

pawn Код:
new RentCar[10]; //10 rentable cars

public OnGameModeInit()
{
RentCar[0] = CreateVehicle(.......);
RentCar[1] = CreateVehicle(.......);
RentCar[2] = CreateVehicle(.......);
RentCar[3] = CreateVehicle(.......);
RentCar[4] = CreateVehicle(.......);
RentCar[5] = CreateVehicle(.......);
RentCar[6] = CreateVehicle(.......);
RentCar[7] = CreateVehicle(.......);
RentCar[8] = CreateVehicle(.......);
RentCar[9] = CreateVehicle(.......);
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
       
                     for(new i=0; i<sizeof(RentCar); i++)
             {
                     if (vehicleid == RentCar[i]) {
                     TogglePlayerControllable(playerid, 0);
                     SendClientMessage(playerid, COLOR_COLOR,"Would you like to rent this vehicle? Type /rentveh or /exit");
                     }
                }



return 1;
}
Then just make two cmds; /exit to RemovePlayerFromVehicle(playerid); and /rentveh to TogglePlayerControllable(playerid, 1); if the player is in RentCar



EDIT:

Here

pawn Код:
if(strcmp(cmd,"/exit",true)==0)
        {
                     for(new i=0; i<sizeof(RentCar); i++)
             {
                     if (GetPlayerVehicleID(playerid) == RentCar[i]) {
                     RemovePlayerFromVehicle(playerid);
                     }
                     }
        return 1;
        }

        if(strcmp(cmd,"/rentveh",true)==0)
        {
                     for(new i=0; i<sizeof(RentCar); i++)
             {
                     if (GetPlayerVehicleID(playerid) == RentCar[i]) {
                     TogglePlayerControllable(playerid, 1);
                     GivePlayerMoney(playerid, -5000);
                     SendClientMessage(playerid, COLOR_COLOR,"You have rent this vehicle");
                     }
                     }
        return 1;
        }
Sorry for bad indentation, I wrote them quickly
Reply


Messages In This Thread
How to make a car rentable - by Mehtab - 04.12.2010, 19:13
Re: How to make a car rentable - by Mean - 04.12.2010, 20:03
Re: How to make a car rentable - by Steven82 - 04.12.2010, 20:42
Re: How to make a car rentable - by Hal - 04.12.2010, 22:21
Re: How to make a car rentable - by BJaxx - 04.12.2010, 22:32
Re: How to make a car rentable - by Mehtab - 05.12.2010, 07:27
Re: How to make a car rentable - by Jakku - 05.12.2010, 07:44
Re: How to make a car rentable - by Mehtab - 05.12.2010, 07:44

Forum Jump:


Users browsing this thread: 1 Guest(s)