1. Has anyone been able to get Entity death to work when killing helicopter?
     
  2. Wulf

    Wulf Community Admin

    What exactly isn't working about it and how are you checking?
     
  3. Code:
     void OnEntityDeath(BaseCombatEntity victim, HitInfo attacker)
    {
          if (victim is BaseHelicopter )
         {
                    //do something.... Code never gets here when i kill heli
         }
    }
     
  4. Wulf

    Wulf Community Admin

    Try printing out some info, and perhaps check by id or name instead.
     
  5. Maybe try "OnEntityKill":
    Code:
    void OnEntityKill(BaseNetworkable entity)
    {
        if (entity != null && entity is BaseHelicopter)
            Puts(entity.ShortPrefabName);
    }
     
  6. That's what I'm using but it triggers when the heli despawns naturally as well - any way to accurately determine if a heli has been killed by a player or despawned naturally with either OnEntityKill or OnEntityDeath

    Thanks.
     
  7. With OnEntityDeath, you should be able to check if HitInfo.Initiator is a BasePlayer.
     
  8. Oh - yeah, that sounds like it'll work :)

    Thanks!
     
  9. Hmm, I tried:
    Code:
    if (info.Initiator != null && info.Initiator is BasePlayer) {
    And:
    Code:
    if (info.Initiator != null && info.Initiator.ToPlayer() != null) {
    And neither triggered when a player shoots down the heli - all I see is the content of the catchall else which I was using when the heli despawns.

    Any other thoughts? The full block is:
    Code:
    void OnEntityDeath(BaseCombatEntity entity, HitInfo info) {    if (entity != null && entity is BaseHelicopter) {        if (info.Initiator != null && info.Initiator.ToPlayer() != null) {            Puts("ToPLayer: The last heli was destroyed.");        } else if (info.Initiator != null && info.Initiator is BasePlayer) {            Puts("BasePlayer: The last heli was destroyed.");        } else if (info.Initiator == null) {            Puts("The heli despawned.");        }    }}