ULX

Author Topic: SWEP using ULX to target player  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

Offline lohiemer

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
SWEP using ULX to target player
« on: July 03, 2015, 08:46:55 AM »
So I am trying to modify a SWEP of the "Kickhammer", but instead have left click kick, and right click ban. The problem is, when I right click to do the ban, it doesn't ban through ULX, and its a lot more difficult to remove a ban if it gets appealed when its not through ULX. (Accidently permanently banned myself. GG me.)

So what I am trying to do is ban the player through ULX instead of the built in ban system upon use, but usually I only modify SWEPs, I usually don't add my own code to them, so I am not entirely sure how to target the player or call the ban command.

The code existing is
Code: [Select]
if target:IsPlayer() then
target:EmitSound( "kick/hammer.wav" )
target:Kick( "You've been Kickhammer'd" )
PrintMessage( HUD_PRINTTALK, target:GetName() .. " has been Kickhammer'd!" )
end
end

I would remove the target:Kick because banning via ULX will do that anyways. Im pretty sure to call a ULX command it would be
Code: [Select]
ulx.ban(target, time)
or something along those lines, but I'm pretty sure ^ that isn't right, and then I don't know how to target the specific player that I am hitting with it.

Afterwards would come another problem, which would be the PrintMessage at the end. Would it be easier for me to simply create another ULX ban function, rename it, and change the message? For instance
Code: [Select]
local str = "#A banned #T " .. time
if reason and reason ~= "" then str = str .. " (#s)" end
ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes or reason, reason )
becomes
Code: [Select]
local str = "#A Banhammered #T " .. time
ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes)
(taking out reason since there would be no need for it)

Sorry for the giant noobish post. Thanks in advance for any help!