General > Developers Corner

ULX Commands

<< < (2/6) > >>

Aaron113:
So what about the echoing into chat?  I looked though ULX and didn't see any ULib.tsayColor() on the commands.

Aaron113:
Whats wrong with this that is not logging or echoing into chat?



--- Code: ---local CATEGORY_NAME = "Custom"


function ulx.warn( calling_ply, target_plys, Reason )
end
local warn = ulx.command( CATEGORY_NAME, "ulx warn", ulx.warn, "!warn" )
warn:addParam{ type=ULib.cmds.PlayerArg }
warn:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.takeRestOfLine }
warn:defaultAccess( ULib.ACCESS_ADMIN )
warn:help( "Warn a player." )
warn:logString( "#1s warned #2s for #3s" )
--- End code ---

Aaron113:
Also, some help with setting common options.  Like ban has: spammer, Minge, Griefer, ect.

JamminR:
I just spent about half hour poking around regarding your echo command to screen issue.
At first, I thought ULib might be expecting a 'return' function as I saw a few return <boolean>, <String message> at the end of some functions that looked like what would be output to a user.
Then I realized, not every ulx function has that and it seems to be meant as an override.
Are you getting the command logged to your ulx server logfile?
Is the command actually running? I know we put in some checks that if for any reason the command doesn't run, it doesn't echo.
In your (currently blank) function, try something as simple as a print to console Msg() and "return" with nothing else.

Megiddo, does logString do more than write to a log file. From log.lua, it didn't look like it. And if not, what should he do to have it echo to the screen?

As for the ban, there is a 'completes' variable you can pass in your parameters.
Pass it a table, and the parameter will suggest whatever is in the table after previous parameters are chosen (if any).

Cbrad24's recent ULX rate release shows this in action.
It has a screenshot of the 'legal' gmod allowed ratings after having typed

Earlier in his code, he sets up a table

--- Code: ---ulx.ratings = { "naughty", "like", "love", "artistic", "star", "builder" }

--- End code ---

Then in his command setup, he uses the following parameter after the Players parameter.

--- Code: ---rate:addParam{ type=ULib.cmds.StringArg, completes=ulx.ratings, hint="rating", error="invalid rating \"%s\" specified", ULib.cmds.restrictToCompletes }

--- End code ---
If you wanted to allow for more than just that table, you could leave out ULib.cmds.restrictToCompletes
It's pretty obvious what that does. :)

Have you seen http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html ?
It has much on the command system ULX uses and the available parameters.

Aaron113:

--- Quote ---Are you getting the command logged to your ulx server logfile?
Is the command actually running? I know we put in some checks that if for any reason the command doesn't run, it doesn't echo.
In your (currently blank) function, try something as simple as a print to console Msg() and "return" with nothing else.
--- End quote ---
I've had to do filex.Append and ULib.tsayColor() for logging and echoing.  I know for a fact the command is running.  I just took all my code out.


--- Quote ---Have you seen http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html ?
It has much on the command system ULX uses and the available parameters.
--- End quote ---
I have seen it.  It can just be a bit confusing.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version