Reworking the killfeed OR how to get killer's weapon?
2 replies, posted
My current schema is like
hook.Add ("PlayerDeath", "pvp_killfeed", function (victim, inflictor, attacker)
-- sending inflictor:GetClass(), victim and attacker to clients using net.
end)
serverside and
net.Receive ("killfeed_notice_death", function ()
drawnotice (net.ReadEverything)
end)
function drawnotice (att, inf)
-- attacker name as DLabel
-- inflictor as DKillIcon
-- victim name as DLabel
end
clientside.
The problem is that usually inflictor is equal to the attacker, so inflictor:GetClass() returns not the weapon, but "player". How can I get the weapon a kill was made with?
P.S. I had an idea to check for attacker's active weapon inside that hook, but it is not a good idea. Now I can see my only chance in using EntityTakeDamage hook and parsing CTakeDamageInfo, but it is relatively complicated. Maybe there are easier ways? How does default killfeed work?
Default kill feed uses the same hook, however it converts the inflictor to the active weapon (source https://github.com/Facepunch/garrysmod/blob/8de8cfc1595cb99ce4e715438b4ada9c9e5628e4/garrysmod/gamemodes/base/gamemode/player.lua#L168-L176).
Thanks for directions, bud :3
Sorry, you need to Log In to post a reply to this thread.