05.12.2010, 07:44
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;
}
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;
}