SA-MP Forums Archive
Getting vehicles 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)
+--- Thread: Getting vehicles driver (/showthread.php?tid=481431)



Getting vehicles driver - Gilbonzo - 15.12.2013

Title I have tried couple ways to check the current vehicle driver heres the code

Код:
stock GetVehicleDriver(playerid) 
{
	new veh = GetPlayerVehicleID(playerid);
	for(new i = 0;i<MAX_PLAYERS;i++)
	if(GetPlayerVehicleID(i) == veh && GetPlayerVehicleSeat(i) == 0 && i != playerid)
	{
		return i;
	}
	return 0;
}
So for some reason it doesn't work please help


Re: Getting vehicles driver - SilentSoul - 15.12.2013

You can simply use ,
pawn Код:
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
   //do something!
}
Source : https://sampwiki.blast.hk/wiki/GetPlayerState


Re: Getting vehicles driver - erminpr0 - 15.12.2013

pawn Код:
stock GetVehicleDriver(vehicleid)
{
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(i) == vehicleid)
        {
            break;
            return i;
        }
    }
    return INVALID_PLAYER_ID;
}

stock GetPlayerVehicleDriver(playerid)
{
    return GetVehicleDriver(GetPlayerVehicleID(playerid));
}