SA-MP Forums Archive
How To Check If A Vehicle Has A Driver - 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: How To Check If A Vehicle Has A Driver (/showthread.php?tid=201809)



How To Check If A Vehicle Has A Driver - mouradde48 - 22.12.2010

Hello Guys,,,

Does Anyone Know How To Check If A Vehicle Has A Driver ?

Thanks f Advance ....



Re: How To Check If A Vehicle Has A Driver - Mauzen - 22.12.2010

You can loop through all players, check if their player state is PLAYER_STATE_DRIVER and if yes, if they are sitting in the vehicle you want to get the driver of.
All in all 10 lines of code


Re: How To Check If A Vehicle Has A Driver - scottyishere - 22.12.2010

pawn Код:
public VehicleHasDriver(vehicleid)
{
     for(new i=0;i<=MAX_PLAYERS;i++)
     {
           if(IsPlayerInAnyVehicle(i))
           {
                if(GetPlayerVehicleID(i)==vehicleid)
                {
                       if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                       {
                             return 1;
                        }
                 }
           }
     }
     return 0;
}



Re : How To Check If A Vehicle Has A Driver - mouradde48 - 22.12.2010

OK ,,,
I Think That I Understood ...
Well , I Hope

Thanks For Your Quick Answer