Putting a player in vehicle if not in use
#1

This is the script that i have created, but it does not work! ::

pawn Код:
public OnPlayerSpawn(playerid)
    {
        if(IsVehicleOccupied(car1))
        if(IsVehicleOccupied(car2))
        if(IsVehicleOccupied(car3))
        {
            PutPlayerInVehicle(playerid, car4, 0);
            TogglePlayerControllable(playerid, 0);
        }
        else
        {
            PutPlayerInVehicle(playerid, car3, 0);
            TogglePlayerControllable(playerid, 0);
            return 1;
            }
        else
        {
            PutPlayerInVehicle(playerid, car2, 0);
            TogglePlayerControllable(playerid, 0);
            return 1;
            }
        else
        {
            PutPlayerInVehicle(playerid, car1, 0); //If car 1 is empty, player will be put in car 1
            TogglePlayerControllable(playerid, 0);
            return 1;
            }
        return 1;
    }
It is suppost to do this:

Check if car1 is in use, if not put the player in the car. If it is in use, put the player in car 2.

Then, check if car2 is in use, if it is not, put the player in car2. If it is in use, put the player in car3.

Then, check if car3 is in use, if it is not, put the player in car3. If it is in use, put the player in car4.



I only need this to work with 4 cars. Please repair the script to make it work!

Thanks.
Reply
#2

pawn Код:
public OnPlayerSpawn(playerid) {
    if(IsVehicleOccupied(car1)) {
        if(IsVehicleOccupied(car2)) {
            if(IsVehicleOccupied(car3)) {
                if(IsVehicleOccupied(car4)) {
                    // Nothing available!
                }
                else {
                    return PutPlayerInVehicle(playerid, car3, 0);
                }
            }
            else {
                return PutPlayerInVehicle(playerid, car3, 0);
            }
        }
        else {
            return PutPlayerInVehicle(playerid, car2, 0);
        }
    }
    else {
        return PutPlayerInVehicle(playerid, car1, 0);
    }
   
    return 1;
}
Untested and messy, sorry. Should work though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)