ULX

Author Topic: Making a simple menu  (Read 2067 times)

0 Members and 1 Guest are viewing this topic.

Offline DankNessProvides

  • Newbie
  • *
  • Posts: 26
  • Karma: -3
Making a simple menu
« on: June 04, 2016, 11:01:54 AM »
I am just trying to make a simpler UI for ULX commands as some admins on a server I am staff on are complaining about how awkward it is and I just offered to make a simple menu for it, but I have one issue I am trying to make this menu appear whenever the player types "!adminpanel". But it is refusing to actually appear I have been told by a couple basic LUA devs it should appear, of course this is just the start but I don't really wanna make it when I don't know what it will look like. This file is located in "garrysmod/lua/autorun" and I don't know if that actually has to do with anything but just in case. All I want is little pointers as to what the issue is. :/

Code: [Select]
local frame = vgui.Create("DFrame")
frame:SetSize(1000,700)
frame:Center()
frame:SetVisible(true)
frame:MakePopup()

concommand.Add( "adminpanel", frame )

hook.Add( "PlayerSay", "Killurself", function( ply, text, public )
text = string.lower( text ) -- Make the chat message entirely lowercase
if ( text == "!adminpanel" ) then
frame
return ""
end
end )
« Last Edit: June 04, 2016, 11:04:31 AM by DankNessProvides »

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Making a simple menu
« Reply #1 on: June 04, 2016, 11:08:28 AM »
It needs to be in lua/ulx/modules/cl if it doesn't exist, make it. Make a new folder in /addons though.

Also, do you want ulx or normal concommand? Ulx is much easier IMO.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline DankNessProvides

  • Newbie
  • *
  • Posts: 26
  • Karma: -3
Re: Making a simple menu
« Reply #2 on: June 04, 2016, 12:06:13 PM »
It needs to be in lua/ulx/modules/cl if it doesn't exist, make it. Make a new folder in /addons though.

Also, do you want ulx or normal concommand? Ulx is much easier IMO.

This does not make any sense I want to make a UI that isn't in the ulx thing the buttons and stuff I want the thing I actually want is why won't it actually make the menu come up when I type in the command....

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Making a simple menu
« Reply #3 on: June 04, 2016, 12:47:51 PM »
vgui is a client-side library, and thus must be run on the client. Simply putting the file in lua/autorun will not work. You need to run AddCSLuaFile() in the file to have clients download it.

As an alternative you can have it be loaded as a ULX module as iViscosity suggested. This will simply load the file with ULX, it will not change the code in any way nor will it style it like XGUI (ULX's menus).
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