SA-MP Forums Archive
How to check if vehicle is being driven already. - 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: How to check if vehicle is being driven already. (/showthread.php?tid=610842)



How to check if vehicle is being driven already. - Dustly - 29.06.2016

So I have a specific vehicle on the map lets say
tropic = AddStaticVehicle(454,313.3820,3454.1711,0.3374,52. 7016,63,66); //

The vehicle has alot of attached objects. So you can't enter it normaly
The Vehicle has a custom interior and in order to drive it you must enter the vehicles interior and grab a pickup that puts you in the driver seat.

However, I'm worried that if multiple people grab the pickup and the driver seat is already occupied, they might crash, so I need a way to check if some one is in the driver seat when grabbing the pickup and deny the player entry if some one is already driving.. :c

https://sampforum.blast.hk/showthread.php?tid=553980

EDIT:I may have found my answer within this.. not sure yet.


Re: How to check if vehicle is being driven already. - blackeagle1122 - 29.06.2016

This should work,
pawn Код:
stock IsSeatTaken(vehicleid, seatid)
{
    for(new i = GetPlayerPoolSize(); i != -1; i--)
    {
        if(!IsPlayerConnected(i)) continue;
        if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seatid) return 1;
    }
    return 0;
}