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?Code:function PLUGIN:OnEntityDeath(entity) -- Convert entity to player local player = entity:ToPlayer() print(player.displayName .. " died ") end
Help on this one would be very welcome,
OnEntityDeath question
Discussion in 'Rust Development' started by Rusty, Jun 9, 2015.
-
Wulf Community Admin
The variables would be the same in any language, so plugins such as Death Notes would point the way.
-
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