Get vehicle driver id???
#1

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!
Reply
#2

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.
Reply
#3

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;
}
}
Reply
#4

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.
Reply
#5

thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)