1. Code:
    function PLUGIN:OnEntityDeath(entity)
      -- Convert entity to player
      local player = entity:ToPlayer()
      print(player.displayName .. " died ")
    end
    Can't find very info online about LUA's OnEntityDeath, how would i go about extracting the killer and the weapon he was using? Even the body part that got hit?

    Help on this one would be very welcome,
     
  2. Wulf

    Wulf Community Admin

    The variables would be the same in any language, so plugins such as Death Notes would point the way.
     
  3. Code:
    function PLUGIN:OnEntityDeath (vic, hitinfo)
        local attacker = nil
        if (not vic) or (not hitinfo) then return false end
        if not hitinfo.HitEntity then return false end
       
        print("[" .. self.Title .. "] HitEntity: " .. tostring(hitinfo.HitEntity.displayName))
        print("[" .. self.Title .. "] Vic: " .. tostring(vic))
       
        if not hitinfo then return false end
        print("Bone: " .. hitinfo.HitBone)
        local victim = vic:ToPlayer()
        if victim then
            print("VICTIM: " .. victim.displayName)
            local attacker = hitinfo.Initiator
            print(attacker.displayName)
            print(attacker:ToPlayer().displayName)
                
        end
       
        if (victim ~= nil) and (attacker ~= nil) then
            print("PVP: " .. attacker.displayName .. " killed " .. victim.displayName)
            print(hitinfo.Weapon)   --<<-- doesnt return anything?
        end
    end
    All is working except hitinfo.Weapon doesnt return a thing.. what am i doing wrong?