Get all passangers from a specific vehicle?
#1

I might have missed something majorly but I can't figure out how to get all the passangers from a specific vehicle.
I want to kick the passangers out of the car when the driver parks it so they won't get teleported to the ocean.
Reply
#2

You can use a loop:
pawn Код:
stock RemoveAllPassengers(vehicleid)
{
     for (new i = 0; i != MAX_PLAYERS; ++i)
     {
             if(!IsPlayerConnected(i)) continue;
             if(IsPlayerInAnyVehicle(i) && GetPlayerVehicleID(i) == vehicleid)
             {
                   if(GetPlayerVehicleSeat(i) != 0 && GetPlayerVehicleSeat(i) != 128)
                   {
                          RemovePlayerFromVehicle(i);
                   }
              }
       }
 
       return 1;
}
Reply
#3

You could also just do:
pawn Код:
RemoveAllPassengers(vehicleid)
{
    foreach(new i: Player)
    {
        if(GetPlayerState(i) == PLAYER_STATE_PASSENGER && IsPlayerInVehicle(i, vehicleid))
        {
            RemovePlayerFromVehicle(i);
        }
    }
    return 1;
}
Reply
#4

You wont be able to remove from the bike, until they stop, Toggle Player not controllable and then remove him/her from bikes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)