General > Developers Corner

Command added to xgui doesn't work

(1/3) > >>

Eccid:
I built this off of looking at code in the other menus in the xgui, and some posts on the forums, and though I had it right. I want to make a category that makes certain ttt commands quicker to use, that just print straight to console. The category is added fine, and the button and text appears, but when I push the button nothing happens in the console. I want to make sure I have this one working and I know what I'm doing wrong before I add the rest of the commands. Here's what I have.


--- Code: ---local CATEGORY_NAME = "TTT"

function ulx.tttadminreport( calling_ply )
ULib.console( calling_ply, "ttt_print_adminreport" )
end
local tttadminreport = ulx.command( CATEGORY_NAME, "Admin Report", ulx.tttadminreport, )
tttadminreport:defaultAccess( ULib.ACCESS_ADMIN )
tttadminreport:help( "Displays all death information in the console." )
--- End code ---

iSnipeu:

--- Quote from: Eccid on December 13, 2012, 03:39:58 PM ---I built this off of looking at code in the other menus in the xgui, and some posts on the forums, and though I had it right. I want to make a category that makes certain ttt commands quicker to use, that just print straight to console. The category is added fine, and the button and text appears, but when I push the button nothing happens in the console. I want to make sure I have this one working and I know what I'm doing wrong before I add the rest of the commands. Here's what I have.


--- Code: ---local CATEGORY_NAME = "TTT"

function ulx.tttadminreport( calling_ply )
ULib.console( calling_ply, "ttt_print_adminreport" )
end
local tttadminreport = ulx.command( CATEGORY_NAME, "Admin Report", ulx.tttadminreport, )
tttadminreport:defaultAccess( ULib.ACCESS_ADMIN )
tttadminreport:help( "Displays all death information in the console." )
--- End code ---

--- End quote ---

The second arg is the console command name you want to use, which should look something like "ulx slap" (or "ulx adminreport").
It should be showing up in xgui once you have fixed that.


Also, ULib.console prints a message to a player, if you want to run a command you should use ply:ConCommand.

JamminR:
Not sure if you've seen ULib docs - https://ulyssesmod.net/docs
As for ULX, there isn't really, most of it is based on the ULib structures.
But, I wrote a conversion how to when we first started using the command object structure.
Might be of some help.

--- Quote from: JamminR on January 09, 2010, 12:09:49 PM ---
--- Code: ---local <name of object, best if same as command> = ulx.command( "<STRING- help category, ex Fun>", "<STRING - console command, example 'ulx <this>'>", <literal function name>, "<STRING - command used in chat to perform action>, <BOOLEAN-hide saychat or not>, <BOOLEAN-require spaces after command or not> )
<name of object>:addParam{ type=ULib.cmds.PlayersArg } -- allows and requires player to input one or more players.
<name of object>:addParam{ type=ULib.cmds.NumArg, min=<min number>, max=<max number>, default=<default number>, hint="<STRING to show during ULX's error assistance", ULib.cmds.optional--<, ULib.cmds.round } -- Add additional number argument, optional, with min/max, and default.
<name of object>:defaultAccess( ULib.ACCESS_ADMIN ) -- Register ULX minimum required default access. In this case, admin
<name of object>:help( "<STRING - command to show in help menu for those with access to this command>" ) -- show this in previously set (in ulx.command) "help" category
<name of object>:logString( "Formatted strnig - Example. "#1s did something to #2s with #3i numbers" ) -- ULX log file and chat. Yes, this can be tricky. Just remember that each addParam command you add is in order. #1, #2, .. above. #1 is always player performing action. #1s makes it a string (see the s after 1). #2 using this code block example is player being acted on, #2s = string. #3i = integer (see type=ULib.cmds.NumArg?)
ulx.addToMenu( ulx.ID_MCLIENT, "<STRING - show this in menu>", "<STRING - console command, example 'ulx <this>'>" )

--- End code ---

--- End quote ---
(I don't remember if ulx.addToMenu is still in use...it was at time of writing)

Eccid:

--- Quote from: iSnipeu on December 14, 2012, 08:45:01 AM ---The second arg is the console command name you want to use, which should look something like "ulx slap" (or "ulx adminreport").
It should be showing up in xgui once you have fixed that.


Also, ULib.console prints a message to a player, if you want to run a command you should use ply:ConCommand.

--- End quote ---
It's showing up in the menu fine, it just won't run the command; I'll edit it to use ply:ConCommand like you suggest and test it when my server empties.


--- Quote from: JamminR on December 14, 2012, 02:50:44 PM ---Not sure if you've seen ULib docs - https://ulyssesmod.net/docs
As for ULX, there isn't really, most of it is based on the ULib structures.
But, I wrote a conversion how to when we first started using the command object structure.
Might be of some help.(I don't remember if ulx.addToMenu is still in use...it was at time of writing)

--- End quote ---

Yeah, I saw this and used it and read through some of the built in menus to set mine up.

I may be one of few, but I find the docs for ulib a bit confusing. I have trouble finding the info I need from it. elsewhere someone had set up calling_ply:ConCommand to call a command, but it didn't work for me, and I couldn't find it in the documentation to see what I was doing wrong. I thought that ULib.console would print the command to my console and call the report, since It was what I could find about it in the docs. Any tips on using the docs more effectively?

Eccid:

--- Code: ---local CATEGORY_NAME = "TTT"

function ulx.tttadminreport(calling_ply)
ply:ConCommand(calling_ply, "ttt_version")
end
local tttadminreport = ulx.command(CATEGORY_NAME, "Admin Report", ulx.tttadminreport)
tttadminreport:defaultAccess(ULib.ACCESS_ADMIN )
tttadminreport:help("Displays all death information in the console.")
--- End code ---

This is what I have currently, I'm using ttt_version so i can test this script alon on the server, now when I press it though, it comes back "Unkown Command 'Admin' "

Navigation

[0] Message Index

[#] Next page

Go to full version