13.08.2016, 16:20
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(VehicleRentID[i] == vehicle)
{
format(string, sizeof(string), "%s is currently renting this Faggio.", GetName(i));
InformationMessage(playerid, string);
IsEngineRunning(playerid); // Performs a check to determine whether engine is running, followed by a message sent to the player.
break;
}
else
{
format(string, sizeof(string), ""WHITE"You can rent this Faggio for "GREEN"$%d"WHITE".\nWould you like to rent it?", RentalPrice);
ShowPlayerDialog(playerid, RentalDialog, DIALOG_STYLE_MSGBOX, ""YELLOW"Barrona Rental", string, "Rent", "Exit");
break;
}
}
1. Begin the loop
2. Check if first player's in loop rented vehicle id is the same as the one player is entering
3. If yes, dissalow renting
4. If no, allow renting
So it will only check VehicleRentID for first player. Use this instead:
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsARentVehicle(vehicle)) // Faggio Rent Vehicles (San Fierro Airport)
{
if(VehicleRentID[playerid] > 0)
{
ErrorMessage(playerid, "You are already renting a vehicle.");
RemovePlayerFromVehicle(playerid);
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(VehicleRentID[i] == vehicle)
{
format(string, sizeof(string), "%s is currently renting this Faggio.", GetName(i));
InformationMessage(playerid, string);
IsEngineRunning(playerid); // Performs a check to determine whether engine is running, followed by a message sent to the player.
return 1;
}
}
format(string, sizeof(string), ""WHITE"You can rent this Faggio for "GREEN"$%d"WHITE".\nWould you like to rent it?", RentalPrice);
return ShowPlayerDialog(playerid, RentalDialog, DIALOG_STYLE_MSGBOX, ""YELLOW"Barrona Rental", string, "Rent", "Exit");
}
}