ULX

Author Topic: [XGUI] Opening Client Settings tab via command  (Read 2716 times)

0 Members and 1 Guest are viewing this topic.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
[XGUI] Opening Client Settings tab via command
« on: June 30, 2015, 03:46:26 AM »
I am trying to create a command that when run will open a certain submodule in the client settings. My latest attempt was to just copy+paste the code of the function that is called when a row is selected, but I get the same error as with previous tries:
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/cl/xlib.lua:1113: attempt to index field 'panel' (a nil value)
I assume this is because I am setting nPanel to the wrong thing. I have tried the name of a submodule ("General Settings") and the acutal panel (genpnl) but neither seem to work.

Here is the function I copy+pasted, it is in addons/ulx/lua/ulx/xgui/settings/client.lua:
Code: [Select]
function changeClientSettingsTab( nPanel )
if nPanel ~= client.curPanel then
nPanel:SetZPos( 0 )
xlib.addToAnimQueue( "pnlSlide", { panel=nPanel, startx=-435, starty=0, endx=0, endy=0, setvisible=true } )
if client.curPanel then
client.curPanel:SetZPos( -1 )
xlib.addToAnimQueue( client.curPanel.SetVisible, client.curPanel, false )
end
xlib.animQueue_start()
client.curPanel = nPanel
else
xlib.addToAnimQueue( "pnlSlide", { panel=nPanel, startx=0, starty=0, endx=-435, endy=0, setvisible=false } )
self:ClearSelection()
client.curPanel = nil
xlib.animQueue_start()
end
if nPanel.onOpen then nPanel.onOpen() end --If the panel has it, call a function when it's opened
end

And here is the code where I call that function, located in addons/ulx/lua/ulx/modules/cl/xgui_client.lua:
Code: [Select]
ULib.cmds.addCommandClient( "ulx opentab", function( ply, cmd, args )
                                            xgui.show( "client" )
                                            changeClientSettingsTab( genpnl )
                                          end )

Any help is appreciated!
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given