Derma Menu nil value?

Alright I’m trying to code a derma menu serverside for my admin mod. It’s a simple admin mod, with no permissions and you have to manually set admins, but that’s besides the point.

Heres the code:

[lua]
function CsamMenu2()

DermaPanel1 = vgui.Create( “DFrame” )
DermaPanel1:SetPos( 370,170 )
DermaPanel1:SetSize( 450, 540 )
DermaPanel1:SetTitle( “CSAM Menu” )
DermaPanel1:SetVisible( true )
DermaPanel1:SetDraggable( false )
DermaPanel1:ShowCloseButton( true )
DermaPanel1:MakePopup()
RunConsoleCommand( “say”, “I am opening the CSAM Menu!” )

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Noclip” )
DermaButton:SetPos( 60, 58 )
DermaButton:SetSize( 160, 80 )
DermaButton.DoClick = function ()
RunConsoleCommand( “say”, “Noclip = ON” )
RunConsoleCommand( “CSAM_Noclip” )
end
DermaButton.DoRightClick = function ()
RunConsoleCommand( “say”, “Noclip = OFF” )
RunConsoleCommand( “CSAM_NoNoclip” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “God” )
DermaButton:SetPos( 60, 145 )
DermaButton:SetSize( 160, 80 )
DermaButton.DoClick = function ()
RunConsoleCommand( “say”, “GodMode = ON” )
RunConsoleCommand( “CSAM_God” )
end
DermaButton.DoRightClick = function ()
RunConsoleCommand( “say”, “GodMode = OFF” )
RunConsoleCommand( “CSAM_Ungod” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Freeze” )
DermaButton:SetPos( 60, 232 )
DermaButton:SetSize( 160, 80 )
DermaButton.DoClick = function ()
RunConsoleCommand( “say”, “Freeze = ON” )
RunConsoleCommand( “CSAM_Freeze” )
end
DermaButton.DoRightClick = function ()
RunConsoleCommand( “say”, “Freeze = OFF” )
RunConsoleCommand( “CSAM_UnFreeze”)
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “God (All)” )
DermaButton:SetPos( 230, 145 )
DermaButton:SetSize( 160, 80 )
DermaButton.DoClick = function ()
RunConsoleCommand( “say”, “General God = ON” )
RunConsoleCommand( “CSAM_GodAll” )
end
DermaButton.DoRightClick = function ()
RunConsoleCommand( “say”, “General God = OFF” )
RunConsoleCommand( “CSAM_UngodAll” )
end


local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Clean Server” )
DermaButton:SetPos( 300, 333 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_CleanServer” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Clear Decals” )
DermaButton:SetPos( 40, 333 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_ClearDecals” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Stop Sounds” )
DermaButton:SetPos( 170, 333 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_StopSounds” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “Strip Weapons” )
DermaButton:SetPos( 40, 406 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_StripWeapons” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “All Health 250” )
DermaButton:SetPos( 170, 406 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_all250” )
end

local DermaButton = vgui.Create( "DButton" )

DermaButton:SetParent( DermaPanel1 )
DermaButton:SetText( “All Health 500” )
DermaButton:SetPos( 300, 406 )
DermaButton:SetSize( 120, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( “CSAM_all500” )
end
end
[/lua]

I can code it clientside, but when I try serverside it says
the DFrame is a nil value.

This happens with all my derma menus serverside. I’m alright at coding but not at coding derma.
Please help me. :slight_smile:

You are not supposed to run it serverside. The vgui library is only available on the client.

Why can all those admin mods use derma menus then?

Cough ULX
Cough ASSMod
Cough Evolve

…? Are the files being sent or something?

Yeah, they are sent to the client.

AddCSLuaFile(string filename)

Or you could just put the derma files in lua/autorun/client then set up the concommands serverside…

I did put the derma files in clientside. The structure is like this. Addons\CSAM\lua\autorun\server
and Addons\CSAM\lua\autorun\client The concommands are serverside. They work by typing them in console, but it has 20 commands or so, and people don’t want to remember them. I have been working on a seperate derma on my clientside, not servers clientside. (does that make sense?)
I have sent the lua files to them thru megaupload.com and they had to add the menu manually, but I don’t want that. One, some people don’t exactly know the right path to put it in. Two, it’s a pain in my ass to tell people where to put it, or give it to them.

I don’t get it? all the derma goes serverside, then you do AddCSLuaFile (“myderma.lua”), with the concommands serverside, when the players click on your buttons, the serverside concommands do whatever function you’ve told them to do.

Yes, it all works, I know it does. The thing is though, it keeps returning nil when I try to open the menu.

THats because serverside doesn’t recognise DFrame as a serverside piece of code, therefore it has no idea what to do with it
Make all the derma VGUI in a clientside script, with all of the commands such as Kill or Ban in a serverside file and somehow link the two together so that when you do something, eg Click a button, it will run the kill or ban command etc

I am also looking for how to do this (link the serverside commands to the clientside derma menu)

PS. Im also wokring on an admin mod ^.^

Guys it’s been said several times AddCSLuaFile(“clientsidedrma.lua”) <–add that at the top of you server sided file. Do it for all client sided files

[editline]7th November 2010[/editline]

[lua]DermaPanel1 = vgui.Create( “DFrame” )
DermaPanel1:SetPos( 370,170 )
DermaPanel1:SetSize( 450, 540 )
DermaPanel1:SetTitle( “CSAM Menu” )
DermaPanel1:SetVisible( true )
DermaPanel1:SetDraggable( false )
DermaPanel1:ShowCloseButton( true )
DermaPanel1:MakePopup()
RunConsoleCommand( “say”, “I am opening the CSAM Menu!” )[/lua]

Also, since when can you do that? Don’t you have to end it…

No, you don’t end it, derma’s different then regular gLua.

(I’m pretty sure you don’t end it since the buttons parent each other to the DFrame)

You only do ends on statements, such as: If, function etc.

then AddCSLuaFile it already

uberpwns what don’t you get about clientside stuff clientside needs to be on the client and they need to download it using the AddCSLuaFile(“stupid derma no one even cares about.lua”) server goes on server doesn’t need adding or including shared needs adding and including on server and client.