I am working on a sort of damage logs and I need the weapon of the killed player. Currently I am using entitytakedamage hook, but it seems like the weapon is dropped before this hook. I also tried PlayerDeath, but it also didn't work.
What would be the best way of getting the gun of someone who is killed?
edit: This is for TTT
[CODE]
if SERVER then
hook.Add("PlayerDeath", "PlayerDeathLog", function(victim, inflictor, attacker)
-- victim: the player (entity) who died
-- inflictor: the entity that was used to kill the person (weapon_zm_improvised for example)
-- attacker: the player or entity that killed the victim
end)
end
[/CODE]
Maybe this can help you.
[editline]4th December 2015[/editline]
if you want to get the gun class you would do this for example:
[CODE]
if SERVER then
hook.Add("PlayerDeath", "PlayerDeathLog", function(victim, inflictor, attacker)
if inflictor:IsWeapon() then --if the victim got killed by a weapon
local weapon = inflictor:GetClass() --this would be the weapon's class
end
end)
end
[/CODE]
[QUOTE=P4sca1;49246134][CODE]
if SERVER then
hook.Add("PlayerDeath", "PlayerDeathLog", function(victim, inflictor, attacker)
-- victim: the player (entity) who died
-- inflictor: the entity that was used to kill the person (weapon_zm_improvised for example)
-- attacker: the player or entity that killed the victim
end)
end
[/CODE]
Maybe this can help you.
[editline]4th December 2015[/editline]
if you want to get the gun class you would do this for example:
[CODE]
if SERVER then
hook.Add("PlayerDeath", "PlayerDeathLog", function(victim, inflictor, attacker)
if inflictor:IsWeapon() then --if the victim got killed by a weapon
local weapon = inflictor:GetClass() --this would be the weapon's class
end
end)
end
[/CODE][/QUOTE]
I need the victims gun, not the inflictor. At playerdeath, the player has already dropped the gun.
[QUOTE=_Jacob;49246170]I need the victims gun, not the inflictor. At playerdeath, the player has already dropped the gun.[/QUOTE]
Sorry, misunderstood your question.
[editline]4th December 2015[/editline]
Maybe you can use this:
[url]http://wiki.garrysmod.com/page/GM/DoPlayerDeath[/url]
you should be able to use ply:GetActiveWeapon() here because ply:Alive() is still returning true in this hook.
[editline]4th December 2015[/editline]
Tested, it is working on DarkRP.
[QUOTE=P4sca1;49246182]Sorry, misunderstood your question.
[editline]4th December 2015[/editline]
Maybe you can use this:
[url]http://wiki.garrysmod.com/page/GM/DoPlayerDeath[/url]
you should be able to use ply:GetActiveWeapon() here because ply:Alive() is still returning true in this hook.
[editline]4th December 2015[/editline]
Tested, it is working on DarkRP.[/QUOTE]
Ill try it, but in the base gamemode this is the event the guns are dropped in.
edit: This fixed it. Thanks a bunch for the help :)
Sorry, you need to Log In to post a reply to this thread.