SA-MP Forums Archive
Is Vehicle Occupied - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Is Vehicle Occupied (/showthread.php?tid=259300)



IsVehicleOccupied - [DOG]irinel1996 - 04.06.2011

Hi! How can I check if a vehicle is occupied, and if it's possible I'd like know the driver's name too.

Greetings from Spain.


Re: Is Vehicle Occupied - Ash. - 04.06.2011

Mm; I guess you could do something like:

pawn Код:
stock GetVehicleDriver(vid)
{
     for(new i; i < GetMaxPlayers(); i++)
     {
          if(!IsPlayerConnected(i)) continue;
          if(GetPlayerVehicleID(i) == vid && GetPlayerSeat(playerid) == 0) return i;
     }
     return INVALID_PLAYER_ID;
}
Usage: GetVehicleDriver(vehicleid)
if the vehicle is occupied. It will return the drivers player id. If it is not occupied it will return INVALID_PLAYER_ID.