ULX

Author Topic: Command added to xgui doesn't work  (Read 5794 times)

0 Members and 2 Guests are viewing this topic.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Command added to xgui doesn't work
« 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: [Select]
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." )

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Command added to xgui doesn't work
« Reply #1 on: December 14, 2012, 08:45:01 AM »
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: [Select]
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." )

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.
« Last Edit: December 14, 2012, 08:46:34 AM by iSnipeu »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Command added to xgui doesn't work
« Reply #2 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.
Code: [Select]
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>'>" )
(I don't remember if ulx.addToMenu is still in use...it was at time of writing)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Command added to xgui doesn't work
« Reply #3 on: December 14, 2012, 03:44:29 PM »
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.
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.

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)

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?

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Command added to xgui doesn't work
« Reply #4 on: December 16, 2012, 05:04:10 AM »
Code: [Select]
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.")

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' "

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Command added to xgui doesn't work
« Reply #5 on: December 16, 2012, 05:57:18 AM »
Code: [Select]
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.")

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' "

Use "ulx adminreport" for the second arg.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Command added to xgui doesn't work
« Reply #6 on: December 16, 2012, 08:37:07 AM »
To expand on Isnipeu a bit (I could see someone thinking 'which' second arg)
The portion here;
Code: [Select]
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> )Here's MrPresident's explode command from the conversion tutorial I link to previously, edited to use all the parameters (booleans at end, not required).
Code: [Select]
local explode = ulx.command( "Fun", "ulx explode", ulx.explode, "!explode", false, true )See what it means now?
See what you have to change?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Command added to xgui doesn't work
« Reply #7 on: December 16, 2012, 02:19:04 PM »
I changed it, now it's just back to doing nothing -_-
« Last Edit: December 16, 2012, 02:30:04 PM by Eccid »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Command added to xgui doesn't work
« Reply #8 on: December 16, 2012, 04:46:26 PM »
You've not got the player console command structured right.
If the player running the command indeed has a working console command called ttt_version, then the following should work better for you or the person running it.
Code: [Select]
calling_ply:ConCommand( "ttt_version" )
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Command added to xgui doesn't work
« Reply #9 on: December 17, 2012, 03:36:46 PM »
Nothing seems to work, now I get this in the console when i click the button
"Invalid command entered. If you need help, please type "ulx help" in your console."

Here's my code, if you guys can't figure it out either, I'm done. I don't have time to dedicate to a lost cause.
Code: [Select]
local CATEGORY_NAME = "TTT"

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

I've also tried every combination of the line
Code: [Select]
calling_ply:ConCommand(calling_ply, "ttt_version")
that I can think of.
« Last Edit: December 17, 2012, 03:51:24 PM by Eccid »

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Command added to xgui doesn't work
« Reply #10 on: December 18, 2012, 01:00:00 AM »
Code: [Select]
function ulx.tttadminreport( calling_ply )
calling_ply:ConCommand("ttt_version")
end
local tttadminreport = ulx.command( CATEGORY_NAME, "ulx tttadminreport", ulx.tttadminreport )
tttadminreport:defaultAccess( ULib.ACCESS_ADMIN )
tttadminreport:help("Displays all death information in the console.")

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Command added to xgui doesn't work
« Reply #11 on: December 18, 2012, 05:56:27 AM »
Code: [Select]
function ulx.tttadminreport( calling_ply )
calling_ply:ConCommand("ttt_version")
end
local tttadminreport = ulx.command( CATEGORY_NAME, "ulx tttadminreport", ulx.tttadminreport )
tttadminreport:defaultAccess( ULib.ACCESS_ADMIN )
tttadminreport:help("Displays all death information in the console.")

I had tried that, and it didn't work for me... but now it does. Is it that I didn't put spaces around the first calling_ply? Thanks a ton for all the help though.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Command added to xgui doesn't work
« Reply #12 on: December 18, 2012, 12:24:59 PM »
Lua is (mostly) white space agnostic, so it wasn't the spacing that made the difference.
Experiencing God's grace one day at a time.

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Command added to xgui doesn't work
« Reply #13 on: December 19, 2012, 04:22:59 AM »
I had tried that, and it didn't work for me... but now it does. Is it that I didn't put spaces around the first calling_ply? Thanks a ton for all the help though.

calling_ply:ConCommand( calling_ply, "ttt_version" )
^ in red is what the problem was, the spacing is just how I personally like it set out.

Offline centran

  • Newbie
  • *
  • Posts: 43
  • Karma: 8
Re: Command added to xgui doesn't work
« Reply #14 on: December 19, 2012, 03:42:32 PM »
doesn't this just basically run the command on the client console for them?
If that is the case then that user needs to have rcon access(for ttt_print_adminreport at least)
Try using ttt_print_damagelog AFTER a round has ended. All players are allowed to run that after a round ends and before a new one gets out of preparing.