Derma not working?

I try to work with Derma (in clientside of course) and I get strange errors:

The error prints once, every time I press F3 (the default ShowSpare1 key)

This is my code:

[LUA]
function GM:ShowSpare1( ply )
local DermaPanel = vgui.Create( “DFrame” ) – Creates the frame itself
DermaPanel:SetPos( 50,50 ) – Position on the players screen
DermaPanel:SetSize( 1000, 900 ) – Size of the frame
DermaPanel:SetTitle( “Testing Derma Stuff” ) – Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) – Draggable by mouse?
DermaPanel:ShowCloseButton( true ) – Show the close button?
DermaPanel:MakePopup() – Show the frame
end
[/LUA]

Nothing pops up of course. I have also tried to not use the code in Serverside without any luck.

That would only happen if you were loading it serverside.

But I am not… that is the problem :confused:

GM:ShowSpare1 is a serverside hook.

Any tips on how I can do this then? With the showspare? Usermessages? Networked Variabels? Anything?

vgui.create is clientside so putting it in init.lua is a bad idea.

Usermessages would be best to use, its short and simple than networking.

This is clientside (cl_init.lua)



function testingmenu( ply )
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
        DermaPanel:SetPos( 50,50 ) -- Position on the players screen
        DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
        DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
        DermaPanel:SetVisible( true )
        DermaPanel:SetDraggable( true ) -- Draggable by mouse?
        DermaPanel:ShowCloseButton( true ) -- Show the close button?
        DermaPanel:MakePopup() -- Show the frame
end


usermessage.Hook("testingmenu", testingmenu)



This is serverside (init.lua)



function GM:ShowSpare1( ply ) 
    umsg.Start( "testingmenu", ply )
    umsg.End()
end 


I would suggest using:
The Network Library
Ex:
[lua]
if SERVER then
util.AddNetworkString(“PLAYER_ShowSpare1Menu”)
hook.Add(“ShowSpare1”, “CreateMenu”, function(ply)
net.Start(“PLAYER_ShowSpare1Menu”)
net.Send(ply)
end)
else
net.Receive(“PLAYER_ShowSpare1Menu”, function(len, ply)
if not(IsValid(ply)) then return end
local DMain = vgui.Create(“DFrame”)
DMain:SetSize(600,400)
DMain:Center()
DMain:SetTitle(“My Title”)
DMain:SetDraggable(false)
DMain:MakePopup()
end)
end
[/lua]

Or you can do something like this with a console command:
[lua]
if SERVER then
hook.Add(“ShowSpare1”, “CreateMenu”, function(ply)
ply:ConCommand(“ShowSpare1Menu”)
end)
else
concommand.Add(“ShowSpare1Menu”, function(ply, cmd, args)
if not(IsValid(ply)) then return end
local DMain = vgui.Create(“DFrame”)
DMain:SetSize(600,400)
DMain:Center()
DMain:SetTitle(“My Title”)
DMain:SetDraggable(false)
DMain:MakePopup()
end)
end
[/lua]

Okay. I went with the usermessages. They where more simple. And I am new to Glua.
Another question: If I want to display simple text in a derma box (MOTD) How would I do that?

I don’t see how they are more simple when the Network Library only requires one more line… which is “util.AddNetworkString(“MyMessage”)”.

Plus the major advantages of the net library are the large size limit (64kb/message) and the ability to send data backwards from the client to the server.

There is a huge variety of you to choose from for drawing in a panel, such as using HTML to draw a cool layout or you can just use the Panel’s paint function to draw something.
Check these out:
http://wiki.garrysmod.com/page/VGUI/Elements
Derma Controls

Found it for you :slight_smile:

He’s new to GLUA so usermessages are easier to understand than the network library + it’s only a test menu.

Why are you trying to limit someone? How do you know what he’s capable of?

Just because he’s learning it doesn’t mean he can’t try to learn it.

He chose what way he wanted, he can try the network libary if he wanted to. I am not stopping him or limiting I’m just suggesting whats easier. In his case to me all he wanted to do was to test out his menu.

You may find it easy to use but others may not; though he can try because I am not stopping him.

That doesn’t make sense…

You said that he’s new so he should use usermessages.

Anyway, use whatever solution you want.

I don’t understand how I’m not making sense in those quotes. I’m just suggesting it’s easier to understand and there’s nothing wrong with trying.
I am NOT suggesting to him ‘Don’t use Network Libraries and always use user messages’.

Though anyways if you are going into advanced menu’s and making a game mode then I encourage the use of Network Library method.

I just thought I would mention that PlayerBindPress would be a better way to have the menu open on F2

Definitely, best to not take client stuff through the server first.

I must say I agree with bliuemist. I am new. And usermessages are very easy to understand and use.
Besides… this gamemode is really REALLY small, so a few usermessages cannot damage anything.
Ty for the help lads :wink: