Ban Player on Death of Admin Weapon SWEP

Hi guys im in the works of creating a swep, The idea is when you are hit with it you are instantly perma banned with ulx.

I have been trying for about 3 hours now to try and work a solution and can simply not get it.

If anyone could give me a hand i would be so grateful and would teach me! i simply can’t get ( victim, inflictor, attacker ) to work at all for me tried loads of examples with it.

Here is my code below.

function PlayerDeath( victim, inflictor, attacker )
     if inflictor:GetClass() =="spartan_kick" then
	 ply:ConCommand( 'ulx ban "' victim '" );

ply is not defined, you have to concatenate strings with and your function is never been called, try this:

hook.Add( "PlayerDeath", "SpartanKick", function( victim, inflictor, attacker )
   if inflictor:GetClass() == "spartan_kick" then
      attacker:ConCommand( 'ulx ban "' .. victim:Nick() .. '" 0' );
end )

Strange, It runs fine with no errors but simply does not work.
User dies as usual but nothing on the code end is doing anything ulx kicking in my case as im using bots.
Im testing this all in game server hopefully that works that way. Really getting confused at this point.

You could just simply do it based on who you hit instead of on death.

function SWEP:PrimaryAttack()
local o=self:GetOwner()
local e=o:GetEyeTrace().Entity
ulx.ban(o,e,0,“I’m a badmin :D”)


targeting by nick is horribly unreliable.
FYI, Btw, for the noobies,
“$<steamid>” targets by steamid in ulx.

It’s surprising how many people don’t seem to know about that.