22.07.2012, 10:23
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!
format(string, 128, "%s is the driver", WhoIsDriver(GetVehicleID(playerid)));
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 Код:
|
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;
}
}
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;
}