PlayerDeath Hook - Who killed the Player?

Hello everyone.

So basically, in my gamemode, I have custom sweps which are ranged. It always registers as “mdm_glock18” has killed the player, rather than saying the player has killed them. How can I check who the weapon belongs to?

function KillPlayer( victim, killer, weapon )

	if ( killer == weapon ) then
             -- What goes in here?


hook.Add( "PlayerDeath", "OnPlayerDeath", KillPlayer )

You could use ENT:GetOwner() I guess. I still don’t quite know what the hell you are doing…

Uhh, are you looking for simply killer:Nick()?

Thanks, Starfox. That did work. In regards to what I’m doing, I am trying to make a gamemode for Garry’s Mod and I just sometimes don’t know what the code is for something.

Niandra, that isn’t what I meant, I didn’t want to get the suspect’s name, I wanted to identify the suspect as the object that the player was killed by wasn’t a player, but an object.

You’re calling it out of order:

It is victim, weapon_which_can_also_be_called_inflictor, attacker.

weapon_which_can_also_be_called_inflictor is the object, weapon or “explosive” that caused the death. Attacker is the player ( or world ) that used the weapon to kill the victim.

Here are some examples based on PlayerDeath ( gun-race, etc… ):

Take a look at how it’s used in the base gamemode:

There’s a little work that goes into finding out how the player died