General > Developers Corner

Possible to over-ride ULX commands and ULib functions?

(1/1)

jakej78b:
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)

Avoid:
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: ---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." )

--- End code ---

JamminR:
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.

Avoid:
Oh,
thanks for pointing those two functions out, yes always have a read through the documentation first! :)

jakej78b:
Thanks, JamminR. I'll be sure to give that a shot and report back!

Navigation

[0] Message Index

Go to full version