Is it possible to get playerid from a vehicleid
#1

Hello, so my question is if it is possible to get the driver playerid from the vehicleid of the vehicle he is driving?I hope you understood what I meant to say. Thanks for reading.
Reply
#2

Yes, search GetVehicleDriver
http://forum.sa-mp.com/search.php?searchid=9984618
Reply
#3

Use a player loop in conjunction with IsPlayerInVehicle. There are probably more efficient ways, if you tend to use this a lot.
Reply
#4

I would think of setting a bool to true whenever a player gets in a vehicle and false when he gets out, this way
pawn Код:
new Driver[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    Driver[playerid] == false;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        Driver[playerid] == true;
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        Driver[playerid] == false;
    }
    return 1;
}

IsDriver(playerid)
{
    return Driver[playerid];
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)