[HELP]Can use playerid in OnVehicleDeath -
Lucas Giovanni - 13.03.2009
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
Re: [HELP]Can use playerid in OnVehicleDeath -
ICECOLDKILLAK8 - 13.03.2009
killerid = the playerid that killed the vehicle
Re: [HELP]Can use playerid in OnVehicleDeath -
Mikep - 13.03.2009
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;
}
Re: [HELP]Can use playerid in OnVehicleDeath -
ICECOLDKILLAK8 - 13.03.2009
killerid is the id of the driver AFAIK
Re: [HELP]Can use playerid in OnVehicleDeath -
Mikep - 13.03.2009
I don't think so, I think if its blown up by a rocket, eh, I'll test it.
Re: [HELP]Can use playerid in OnVehicleDeath -
Backwardsman97 - 13.03.2009
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");
Re: [HELP]Can use playerid in OnVehicleDeath -
Mikep - 13.03.2009
killerid always returns 255 (INVALID_PLAYER_ID)
backwardsman, mine works just as well.
Re: [HELP]Can use playerid in OnVehicleDeath -
Lucas Giovanni - 13.03.2009
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;
Re: [HELP]Can use playerid in OnVehicleDeath -
Lucas Giovanni - 13.03.2009
error 001: expected token: ";", but found "-identifier-"
Re: [HELP]Can use playerid in OnVehicleDeath -
Backwardsman97 - 13.03.2009
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.