SA-MP Forums Archive
Get vehicle driver id??? - 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: Get vehicle driver id??? (/showthread.php?tid=361781)



Get vehicle driver id??? - pasha97 - 22.07.2012

Hi! I am making a derby mode for my server and i need a function to get the id of a player who is driving a current vehicle. Is that possible? Thanks!


Re: Get vehicle driver id??? - Kindred - 22.07.2012

Wait, what do you mean, you want to see who is in a certain vehicle id?

Like WhoIsDriver(vehicleid)? Of which would return who the vehicle driver is. (so, lets say you wanted the drivers name to appear when someone enters the car, you would do this

pawn Код:
format(string, 128, "%s is the driver", WhoIsDriver(GetVehicleID(playerid)));
If so, I can easily make it for you.


Re: Get vehicle driver id??? - pasha97 - 22.07.2012

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Wait, what do you mean, you want to see who is in a certain vehicle id?

Like WhoIsDriver(vehicleid)? Of which would return who the vehicle driver is. (so, lets say you wanted the drivers name to appear when someone enters the car, you would do this

pawn Код:
format(string, 128, "%s is the driver", WhoIsDriver(GetVehicleID(playerid)));
If so, I can easily make it for you.
No, i want a function which could return a driver id,not a name. For example,

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)//playerid here isn't and id of a driver, but it is an id of a player who synced the damage
{
new driver=WhoIsDriver(vehicleid);//get driver id
if(derby[driver] > 0)//if driver is in derby mode
{
    SetPlayerHealth(driver,GetPlayerHealth(driver)-5);//take -5 health points
    return 1;
}
}



Re: Get vehicle driver id??? - Kindred - 22.07.2012

pawn Код:
stock WhoIsDriver(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++) //Loops through all players
    {
        if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i; //Returns playerid if the player is in the vehicleid provided AND is the driver
    }
    return 1;
}
Here, try this.


Re: Get vehicle driver id??? - pasha97 - 22.07.2012

thank you!