SA-MP Forums Archive
OnPlayerDeath doesn't recognise if a player was in a vehicle? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath doesn't recognise if a player was in a vehicle? (/showthread.php?tid=649447)



OnPlayerDeath doesn't recognise if a player was in a vehicle? - ranme15 - 09.02.2018

I am trying this:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
	SendClientMessageToAll(-1, "ION just died.");
	if(IsPlayerInAnyVehicle(playerid)) SendClientMessageToAll(-1, "ION was in a vehicle.");
	return 1;
}
The second message doesn't get displayed. And I am in a vehicle.
Is the OnPlayerDeath not recognising whether a player was in a vehicle or not option possible?


Re: OnPlayerDeath doesn't recognise if a player was in a vehicle? - RogueDrifter - 09.02.2018

Well i guess OnPlayerDeath is callef after the players death since once you die you exit the vehicle, what you can do is set a variable true at onplayerdeath that resets at onplayerspawn lets name it playerdied[playerid] then go to onplayerstatechange and use if (oldstate == 2 || oldstate == 3) && playerdied[playerid] ...//code
Something within the lines of that ^


Re: OnPlayerDeath doesn't recognise if a player was in a vehicle? - Mugala - 09.02.2018

when player dies he's automatically removed from vehicle before this callback.


Re: OnPlayerDeath doesn't recognise if a player was in a vehicle? - Sew_Sumi - 09.02.2018

^^ This... Track the players last vehicle in an array (LastUsedCar[MAX_PLAYERS]), and use OnPlayerEnterVehicle, OnPlayerExitVehicle to see which car needs to be updated to it.


Re: OnPlayerDeath doesn't recognise if a player was in a vehicle? - ranme15 - 09.02.2018

Yeah well, I've used OnPlayerStateChange as a workaround.
Thank you guys anyway.


Re: OnPlayerDeath doesn't recognise if a player was in a vehicle? - Sew_Sumi - 09.02.2018

That's an interesting thing too, StateChange will occur.