Hi, I did this and it works, but I have a problem. When the killer is helicoper or high externall wall (and more but I don't remember) I get an error. I know that that's because you can't SendReply to an helicopter ^^
Code:void OnEntityDeath(BaseCombatEntity entity, HitInfo Info) { BasePlayer player = entity.ToPlayer(); if (player != null) { BasePlayer Killer = null; if (Info != null) { Killer = Info.Initiator.ToPlayer(); if (Info?.Initiator != null) { SendReply(Killer, "Something"); } } } }
Solved If killer is player on OnEntityDeath
Discussion in 'Rust Development' started by Reynostrum, Jun 20, 2016.
-
Code:
void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo) { if (entity == null || hitInfo?.Initiator == null) return; if (entity is BasePlayer && hitInfo.Initiator is BasePlayer) { var victim = entity.ToPlayer(); var attacker = hitInfo.Initiator.ToPlayer(); SendReply(victim, "you died"); SendReply(attacker, "you killed: " + victim.displayName); } }
EDIT: Maybe you were, I didn't notice the first if, not sure why that wasn't working before.
EDIT 2: I'm apparently unable to read, you were checking if the person dying was a player, then wanting to send a message to the killer. They have to both be players.Last edited by a moderator: Jun 20, 2016 -
Wulf Community Admin
-
-
Thank you! Solved!