[HELP]Can use playerid in OnVehicleDeath
#1

You can use "playerid" in public OnVehicleDeath ??

Example:

public OnVehicleDeath (vehicleid, killerid)
(
DestroyVehicle (vehicleid);
SendClientMessage (playerid, COLOR_RED, "His car was destroyed");//I can use it??
)
return 1;
)


If you can not please anyone knows of any way to use "playerid"?

Tanks
Reply
#2

killerid = the playerid that killed the vehicle
Reply
#3

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

killerid is the id of the driver AFAIK
Reply
#5

I don't think so, I think if its blown up by a rocket, eh, I'll test it.
Reply
#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
#7

killerid always returns 255 (INVALID_PLAYER_ID)

backwardsman, mine works just as well.
Reply
#8

Ok e use this funcion

new LastDriver[MAX_VEHICLES];

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

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




But now I'm having trouble adding an array in public ...
See how I did it add, but did not work:

/ / OnVehicleDeath
DestroyVehicle (vehicleid);
SendClientMessage (LastDrive [vehicleid], COLOR_RED "His car was destroyed");
Insurance LastDrive [vehicleid] == 0;
Reply
#9

error 001: expected token: ";", but found "-identifier-"
Reply
#10

Quote:
Originally Posted by Lucas Giovanni
Ok e use this funcion

new LastDriver[MAX_VEHICLES];

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

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




But now I'm having trouble adding an array in public ...
See how I did it add, but did not work:

/ / OnVehicleDeath
DestroyVehicle (vehicleid);
SendClientMessage (LastDrive [vehicleid], COLOR_RED "His car was destroyed");
Insurance LastDrive [vehicleid] == 0;
Try setting LastDriver to 255.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)