Simple Derma window

Hey there, I am just a beginner with LUA, and I really wan’t to know how to make a simple derma window that pops up when you type, for example !menu.
On there it will show 2 buttons, “Kick” and “Ban”. (And maybe change map later when I know some more :D)

Is this something thats easy to make? And of course it must be for admin only :slight_smile:

Sorry if this post is all messed up, and non understandable, but I’m a noob at LUA and Derma :smiley:

Yes, it’s pretty easy to make. First add a hook serverside to see if a player types !menu:

[lua]hook.Add( “PlayerSay”, “MenuCheck”, function( ply, msg )
if ( msg == “!menu” ) then
ply:ConCommand( “open_menu” )
end
end )[/lua]

Then create the console command open_menu clientside, which creates the derma menu:

[lua]concommand.Add( “open_menu”, function( ply, cmd, args )
local pnl = vgui.Create( “DFrame” )
pnl:SetSize( 300, 600 )
pnl:SetPos( ScrW() / 2 - 150, ScrH() / 2 - 300 )
pnl:SetTitle( “Admin menu” )
pnl:SetDraggable( true )
pnl:ShowCloseButton( true )
pnl:SetVisible( true )
pnl:MakePopup()
end )[/lua]

To add the buttons and all, have a look here.

Where am I supposed to put the second piece of code?

I put the first on in init.lua, which is right I think?

BTW, how do I make this admin only?

You put the second piece of code somewhere clientside and the first somewhere serverside. So yes, init.lua should do fine. You make it admin only by adding an admin check to the if block:

[lua]if ( msg == “!menu” and ply:IsAdmin() ) then[/lua]

“Unknown command: open_menu”

I put the second code in the cl_init.lua, which is clientside.

Any idea why it doesnt work?

Are you sending cl_init.lua?

Now I feel really noobish D: Sending? You mean including it in some other file?

You should really go through the tutorials on the wiki to get some basic knowledge of Lua before doing this.

Sending as in, quite literally, sending the file to the client, making him download it. Making it one of those Lua files that downloads when you join some servers.

You do this by putting AddCSLuaFile(“filename.lua”) in a serverside file, replacing filename.lua with the path and filename of the file you want to send to the client.

Thanks, will try that :slight_smile:

BTW, I have read some tutorials, still don’t understand all of it.