[HELP]Can use playerid in OnVehicleDeath
#6

Quote:
Originally Posted by Mikep
You wan't the ID of the driver?

pawn Код:
stock GetVehicleDriver(vehicleid)
{
  for(new i; i<MAX_PLAY; i++)
  {
    if (IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2)
    {
      return i;
    }
  }
  return -1;
}
He wants it after the vehicle has been destroyed.

You can use a variable to store the player last in it.

pawn Код:
new LastDriver[MAX_VEHICLES];

//OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER)
{
    LastDriver[GetPlayerVehicleID(playerid)] = playerid;
    return 1;
}

//OnVehicleDeath
DestroyVehicle (vehicleid);
SendClientMessage (LastDriver[vehicleid], COLOR_RED, "His car was destroyed");
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)