Closed rube200 closed 3 years ago
Order: (Before update)
OnPlayerDeath
tellDeath
OnDeath
tellDead
(After update)
tellDeath
tellDead
OnPlayerDeath
OnDeath
Yeah my bad - I did not realize OnPlayerDeath was being used that way. That event was only used to show the owner how they died in the base game. #37 OnPreDeath was added for this case. Does that work, or is something else needed?
When I use native PrePlayerDeath event and it works (at least to read player inventory before death) but rocket OnPlayerDeath ain't updated to use it yet.
I suppose it could be hooked up, but the cause/limb/instigator for the Rocket event are not available during OnPreDeath. This has not been great for backwards compatibility, but do you think there are many outdated plugins relying on that?
I have no clue how many plugins got outdated with this change but in my cause it broke.
private void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb _, CSteamID murderer)
{
if (player == null || murderer == CSteamID.Nil || murderer == player.CSteamID)
return;
if (cause == EDeathCause.KILL)
return;
if (!PlayerTool.tryGetSteamPlayer(murderer.ToString(), out var murder))
return;
murder.player.skills.askAward(player.Player.skills.experience);
player.Player.skills.ServerSetExperience(0);
}
The code snipped you posted there should still work because all of those parameters are passed to onPlayerDied
. What seems to be the issue?
Problem is that rocketmod events are executed after tellDead
so server deletes the experience before plugins access it
Code order:
tellDead
onLifeUpdated //Inventory / experience is cleared at this point
static onPlayerLifeUpdated
OnPlayerDeath
OnDeath
Before:
OnPlayerDeath
tellDead
OnDeath
onLifeUpdated //Inventory / experience is cleared at this point
static onPlayerLifeUpdated
Ah okay, I see what you mean now. I will add a separate event for that and update Rocket to use it.
This should be addressed in tomorrow's update. https://github.com/SmartlyDressedGames/Legally-Distinct-Missile/commit/2291e9642d464944a962fecabfdcc0d1a3e39016
With the last changes made in rocketmod, when
OnPlayerDeath
happens it is no longer possible to get the experience of playing dead, this can affect other plugins that also use this event.