SA-MP Forums Archive
If vehicle has passengers? - 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: If vehicle has passengers? (/showthread.php?tid=444456)



If vehicle has passengers? - ajwar - 16.06.2013

Is it possible to check and stop player from entering vehicle if there is 1 or more passengers in that car allready? i mean 1 passenger per vehicle. How to check that?


Re: If vehicle has passengers? - OrMisicL - 16.06.2013

Yes its possible, you should loop through all the connected players and check their vehicle ID

pawn Код:
stock IsVehiclePassengerOccupied(vehicleid)
{
    for(new i = 0: i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) != 0)
            return true;
    }
    return false;
}
Thats function will return true there is a passenger in that vehicle, false otherwise


Re: If vehicle has passengers? - ajwar - 16.06.2013

Thank's, exactly what i was searching