Restricted spawn menu and derma panel

Okay… First of all… I’m editing the sandbox gamemode.
And I got some questions and bugs.

How do I make the Q menu restricted to superadmins from ULX?

I’m also trying to make my derma menu show up when F1 is pressed.
I tried to call the menu two ways. But it still doesnt work.
Here’s my code:

In init.lua it I’ve added this:

 AddCSLuaFile( "testingmenuclient.lua" )


function GM:ShowHelp(ply)

function GM:ShowTeam(ply)

And in testingmenuclient.lua I got this:

	function testpanel() -- Create the function
	local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Testing Derma Stuff" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "What does simon like?" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
    RunConsoleCommand( "say Simon licks balls, but there is nothing wrong with that!" ) -- What happens when you press the button
end -- ending the function
concommand.Add( "minmenu", testpanel )

When I press F1 it gives me the error “Unknown command: minmenu”
When I press F2 it gives me this error “:1: attempt to call global ‘testpanel’ (a nil value)”

Can someone help me?

In my opinion I would find it easier to create a custum Sandbox group and add select users there, then restrict the Q menu that way, just so you don’t have to import Objects and mess with double var bullshit.

I only want superadmins to be able to get the menu up. I’m currently working on a youtube server.
I’m not good at lua. If you could tell me how to do it, it would be nice.

In your cl_init.lua, do you ever do include(“testingmenuclient.lua”) as well as AddCSLuaFile(“testingmenuclient.lua”) in your init.lua? You have to make sure the file is run and the client has received it for the file to work.

Also, why would you use SendLua when a concommand works fine?

Oops. No I didn’t include in cl_init -.-
Well. Because I tried the SendLua was just to see if it was me who was stupid and made something weird in ConCommand that made the error.

… It worked, thanks a bunch! :slight_smile:

So… Anyone who knows what I can do to limit the Q Menu to Superadmins?
By the way… I see some people got some kind of script that automatic spawns ent. and/or props after server start. How is that possible? What is it called?

Oh ya! How do I make a button that spawns a melon infront of the player?

local melon = ents.Create(“prop_physics”)
local tr = pl:GetEyeTrace()
melon:SetPos( tr.HitPos + tr.HitNormal * 15 )

You just need to replace “pl” with whatever player you’re using, and make sure you put the correct model in melon:SetModel.

I’m really new to Lua. What do I do with that code? Could you explain me where to put it, and what it does?

Allrightey. So, this is what’s known as serverside code, meaning that it will only work correctly when used on the server. The best way to get a script to run easily is to put it in your garrysmod/lua/autorun folders. In the root autorun, everything is “shared”, meaning the code is run on both the client and the server – however this does not guarantee that all functions will work on both client and server. For example, if you put this file in your lua/autorun:

[lua]if SERVER then print(“I’m on the server!”) end
if CLIENT then print(“I’m on the client!”) end[/lua]

Then it would print “I’m on the client!” since you are a client.

With this in mind, you want to make this code so that it spawns in front of the player. However, you said that you want the client to decide when to do something – that makes it a little trickier. The best way to solve this is with concommands. For example,

function SendMessage( ply, command, arguments ) – Concommands give three things you can use: the player who called the concommand, the command itself, and the arguments
– If you did “ulx help”, then the player = you, the command = “ulx”, and the arguments = “help”

-- Note: "ply" and "pl" are shorthand notation for "player"
ply:ChatPrint( "Hello, World!" )


So, you need to combine concommands with the ents.Create and put it in the autorun server. Then you can call that concommand whenever you want. Does that make any sense?

Yes, thanks a lot!

Only thing I need now is restricted Q-Menu.
And some sort of script that spawns stuff at server start
Or… A lua coder perhaps? >.<