• Ban Player on Death of Admin Weapon SWEP
    5 replies, posted
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. [CODE]function PlayerDeath( victim, inflictor, attacker ) if inflictor:GetClass() =="spartan_kick" then ply:ConCommand( 'ulx ban "' victim '" ); end end[/CODE]
[B]ply[/B] is not defined, you have to concatenate strings with [B]..[/B] and your function is never been called, try this:[code]hook.Add( "PlayerDeath", "SpartanKick", function( victim, inflictor, attacker ) if inflictor:GetClass() == "spartan_kick" then attacker:ConCommand( 'ulx ban "' .. victim:Nick() .. '" 0' ); end end )[/code]
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.
[lua] function SWEP:PrimaryAttack() local o=self:GetOwner() local e=o:GetEyeTrace().Entity if(e&&e:IsPlayer())then ulx.ban(o,e,0,"I'm a badmin :D") end end [/lua] P.S. [QUOTE=LoweChaser;52908741][B]ply[/B] is not defined, you have to concatenate strings with [B]..[/B] and your function is never been called[/QUOTE] 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.
Please don't use console commands for that. Many players will just set their name to [code];"ulx luarun wowobackdoor!"[/code] Use the actual ban function: [code]ULib.queueFunctionCall( ULib.kickban, victim, 0, "banned!!", attacker )[/code]
Sorry, you need to Log In to post a reply to this thread.