HitInfo available in OnEntityKill?Solved
I am trying to use onentitykill to add points to a player when they destroy the patrol heli.
void OnEntityKill(BaseCombatEntity heli, HitInfo Info)
        {
            if (heli == null) return;
            if (heli is BaseHelicopter)
            {
                BasePlayer player = Info?.Initiator as BasePlayer;
                if (player == null) return;

                Puts("heli down");
              
                int newpoints = Cachedplayerstats[player.userID].points + helicopterpoints;
                Cachedplayerstats[player.userID].points = newpoints;

                checkrankalreadyhad(player);
                CheckRank(player, Info);
                CreateGUI(player);
            }

            foreach (var data in Cachedplayerstats) data.Value.Save(data.Key);
            return;
        }​

When i destroy the heli, it doesn't do anything tho. Any idea why?

Hey, I don't think OnEntityKill has HitInfo, wasn't it only for OnEntityDeath?
5b6ed4c9ac8e4.jpg misticos
Hey, I don't think OnEntityKill has HitInfo, wasn't it only for OnEntityDeath?
Oh, that makes sense. So is there a way to find out who killed the heli?
Switch to OnEntityDeath? Or log who did last hit
5b6ed4c9ac8e4.jpg misticos
Switch to OnEntityDeath? Or log who did last hit

I don't think onentitydeath works for the patrol heli. How would i find the last attacker in onentitykill?

5ee8d1e1c84dc.png Kingfoo55

I don't think onentitydeath works for the patrol heli. How would i find the last attacker in onentitykill?

I believe it works for every entity.
5e13a8d5b2bc5.jpg Wulf
I believe it works for every entity.
if (entity.ShortPrefabName == "patrolhelicopter")
            {
                Puts("heli down");
            }

if (entity is BaseHelicopter)
      {
         Puts("helidown");
      }
I tried both of these and when i shot the heli down, nothing happened.

It isnt working because killer is null.

BasePlayer killer = info?.Initiator as BasePlayer;
Why would killer be null when their is a player shooting it down?

Merged post

Fixed.
Locked automatically