• Print

Author Topic: [SOLVED] Custom Cvar Sliders in XGUI?  (Read 6262 times)

0 Members and 1 Guest are viewing this topic.

Offline Zotero

  • Newbie
  • *
  • Posts: 6
  • Karma: 1
[SOLVED] Custom Cvar Sliders in XGUI?
« on: June 05, 2013, 08:16:12 pm »
Hi,
I'm running a TTT server (I know, ew, another TTT fag)
But I was wondering, in the XGUI menu, you know how if you go to settings, and then server, and on the side there's a slider for gravity? (and something else)
I would like to make a slider (or two) just below that, which changes a different cvar (ttt_spec_prop_rechargetime | ttt_spec_prop_force | ttt_spec_prop_base)
Thanks in advance!
« Last Edit: June 06, 2013, 04:19:44 pm by Zotero »

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Custom Cvar Sliders in XGUI?
« Reply #1 on: June 06, 2013, 07:31:00 am »
Easiest way would be to open ulx/lua/ulx/xgui/settings/server.lua, add the following lines (pretty much a copy of the lines above it) after line 20:
Code: Lua
  1. xlib.makelabel{ x=10, y=210+offset, label="ttt_spec_prop_rechargetime", parent=server }
  2. xlib.makeslider{ x=10, y=225+offset, label="<--->", w=125, min=0, max=4, decimal=2, repconvar="ttt_spec_prop_rechargetime", parent=server }

For each additional one you add, you'll have to add 45 to the y value, and change the label and then change repconvar to the correct cvar. Also you should set min/max and decimal (number of decimal places) to good values for each one, too.

Note that this will only work if these cvars are 'replicated cvars'-- you can check by testing if you can change these cvars from your CLIENT console. If they're not replicated, you will see a 'Only server owners can change this CVAR' type message, and you'll have to do something to work around that.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Zotero

  • Newbie
  • *
  • Posts: 6
  • Karma: 1
Re: Custom Cvar Sliders in XGUI?
« Reply #2 on: June 06, 2013, 12:05:31 pm »
Ah, thank you! Exactly what I was looking for. I'll be back with updates.

Offline Zotero

  • Newbie
  • *
  • Posts: 6
  • Karma: 1
Re: Custom Cvar Sliders in XGUI?
« Reply #3 on: June 06, 2013, 12:10:51 pm »
Yes, it is indeed a server CVAR.
Maybe we could work something out with RCON?

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Custom Cvar Sliders in XGUI?
« Reply #4 on: June 06, 2013, 12:22:16 pm »
you could just code it as its own command?

by doing something like this but modify it to use a integer instead of a set value

Here is a simple example (untested):

Code: Lua
  1. function ulx.proprechargetime( calling_ply, amount )
  2.  
  3.         RunConsoleCommand("ttt_spec_prop_rechargetime", amount)
  4.  
  5.         ulx.fancyLogAdmin( calling_ply, "#A set the prop rechargetime to #i", amount )
  6. end
  7. local proprechargetime = ulx.command( "TTT CVAR", "ulx proptime", ulx.proprechargetime, "!ptime" )
  8. proprechargetime:addParam{ type=ULib.cmds.NumArg, min=0, max=10000, default=1000, hint="Prop recharge time", ULib.cmds.optional, ULib.cmds.round }
  9. proprechargetime:defaultAccess( ULib.ACCESS_ADMIN )
  10. proprechargetime:help( "Changes the Prop Recharge Time." )
  11.  
« Last Edit: June 06, 2013, 12:35:00 pm by bender180 »
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Custom Cvar Sliders in XGUI?
« Reply #5 on: June 06, 2013, 02:54:02 pm »
You could just make it a replicated cvar (as Stickly does for all the default gmod cvars).
Experiencing God's grace one day at a time.

Offline Zotero

  • Newbie
  • *
  • Posts: 6
  • Karma: 1
Re: Custom Cvar Sliders in XGUI?
« Reply #6 on: June 06, 2013, 04:19:17 pm »
Bender180, You are a genius, thank you :)
Also, I just realized who you are, the creator of the TTT plugins. I'm honored to have you reply! :P
That plugin code worked, with some slight remodelling. Thank you!

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: [SOLVED] Custom Cvar Sliders in XGUI?
« Reply #7 on: June 06, 2013, 04:40:02 pm »
haha, no problem glad it worked for you.   :D
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

  • Print