OnPlayerDeath not triggering in safe zone after player sleeps and diesSolved
I have a plugin to give a player their clothes back when they respawn.  Doesn't seem to work if as player sleeps in a safe zone and gets killed by the AI.  Looks like OnPlayerDeath doesn't trigger at all. 

I'm trying to test it more but it takes a while before a safe zone sleeper gets killed...

Am I missing something simple?
If it is a sleeper, it wouldn't be a player as far as I know... so you'd likely need to use OnEntityDeath.
I'll have to double check, but I thought sleepers were still BasePlayers.  Will try the OnEntityDeath hook and see if that works.

Merged post

Killed a sleeping player while player was online.  Triggered OnPlayerDeath and OnEntityDeath(BasePlayer).

Logged out in bandit camp.  Died.  No triggers for either.

Trying it again now with OnEntityDeath(BaseCombatEntity), in case the sleeper is no longer a BasePlayer when logged out.

I think offline sleepers are still BasePlayers, based on BasePlayer.sleepingPlayerList.  Will see...

Merged post

I set hooks to log every OnPlayerDeath and OnEntityDeath.  Logged out in bandit camp.  Logged in dead.  Neither hook triggered.

I'd like to look at the code the server uses to kill sleepers.  But I'm not sure where it is. 

I think it is bypassing the regular ways of killing. 
What are you using for the argument with OnEntityDeath?
I'm using both OnEntityDeath(BasePlayer) and OnEntityDeath(BaseCombatEntity).  Neither is catching my death in the safe zones.

Merged post

Been loggin my sleeper with BasePlayer.sleepingPlayerList.  As soon as it's not in that list, I log in, and I'm dead.  (With no hooks being triggered.)

I'll have to check if a dead safe zone sleeper makes a corpse.  Maybe the server is nuking the GameObject directly so it doesnt make a corpse or backpack? 

Merged post

Just saw an offline sleeper die, not in safe zone. 

OnPlayerDeath(BasePlayer) - worked.
OnEntityDeath(BasePlayer) - worked.

I wrote a helper command to detect my sleeper. Logged out at 18:04 in the scientist compound.  It could see my sleeper until 18:23. Next check did not find the sleeper.  Nothing triggered.  Logged in, definitely dead.

Merged post

I figured it out.  When a player sleeps in a safe zone, it sets a timer to call BasePlayer.ScheduledDeath().  That method called BaseNetworkable.Kill() to get rid of the sleeper.  Which triggers the OnEntityKill(BaseNetworkable) hook.  Not OnEntityDeath or OnPlayerDeath.

Had someone watch while it happened.  Sleeper disappeared and OnEntityKill triggered.
Locked automatically