SA-MP Forums Archive
Get all passangers from a specific vehicle? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get all passangers from a specific vehicle? (/showthread.php?tid=569427)



Get all passangers from a specific vehicle? - Chrillzen - 30.03.2015

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.


Re: Get all passangers from a specific vehicle? - Abagail - 30.03.2015

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;
}



Re: Get all passangers from a specific vehicle? - CalvinC - 30.03.2015

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;
}



Re: Get all passangers from a specific vehicle? - ikey07 - 30.03.2015

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