Author Topic: Possible to over-ride ULX commands and ULib functions?  (Read 1975 times)

0 Members and 1 Guest are viewing this topic.

Offline jakej78b

  • Newbie
  • *
  • Posts: 26
  • Karma: 4
Possible to over-ride ULX commands and ULib functions?
« on: September 04, 2014, 09:15:15 PM »
Just curious, I was wanting to add a reason to slay. I have done so successfully before, but I want to do it without editing core files. (Been using Falco's ways for too long)

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: Possible to over-ride ULX commands and ULib functions?
« Reply #1 on: September 04, 2014, 09:23:37 PM »
Hello there,
I'd probably add a string param and give an output using ulx.fancyLogAdmin.

Also without editing core files? You could add an extra command slayres - just take a look at ulx.kick:
Code: [Select]
function ulx.kick( calling_ply, target_ply, reason )
        if reason and reason ~= "" then
                ulx.fancyLogAdmin( calling_ply, "#A kicked #T (#s)", target_ply, reason )
        else
                reason = nil
                ulx.fancyLogAdmin( calling_ply, "#A kicked #T", target_ply )
        end
        ULib.kick( target_ply, reason, calling_ply )
end
local kick = ulx.command( CATEGORY_NAME, "ulx kick", ulx.kick, "!kick" )
kick:addParam{ type=ULib.cmds.PlayerArg }
kick:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
kick:defaultAccess( ULib.ACCESS_ADMIN )
kick:help( "Kicks target." )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Possible to over-ride ULX commands and ULib functions?
« Reply #2 on: September 04, 2014, 11:23:12 PM »
Avoid, there's better ways than making new commands.

Likely two most helpful in this instance;
ULibCommandCalled (called on server before any Ulib command actually runs(which ULX uses of course)
ULibPostTranslatedCommand - Server hook - runs after a ulib command call - this one could look for slay, then run the additional logging code/whatever code you wanted after slay.

If I were wanting to do any additional commands in ULX but not actually change our project code...those are what I'd use.
« Last Edit: September 04, 2014, 11:26:21 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: Possible to over-ride ULX commands and ULib functions?
« Reply #3 on: September 05, 2014, 07:21:58 AM »
Oh,
thanks for pointing those two functions out, yes always have a read through the documentation first! :)

Offline jakej78b

  • Newbie
  • *
  • Posts: 26
  • Karma: 4
Re: Possible to over-ride ULX commands and ULib functions?
« Reply #4 on: September 05, 2014, 08:33:50 PM »
Thanks, JamminR. I'll be sure to give that a shot and report back!