My code should allow a derma panel to open from a console command and the F3 key. My console command works and opens the derma panel. However, the F3 key isn't opening the derma panel.
This is my cl_init.lua
[CODE]function frame_open()
frame = vgui.Create("DFrame")
frame:SetPos(50,50)
frame:SetSize(800,700)
frame:SetTitle("Easy Access Admin Menu")
frame:SetVisible(true)
frame:Center()
frame:SetDraggable(true)
frame:ShowCloseButton(true)
frame:SetBackgroundBlur(false)
frame:MakePopup()
frame.Paint = function()
draw.RoundedBox( 8, 0, 0, frame:GetWide(), frame:GetTall(), Color( 0, 0, 0, 255 ) )
end
label2 = vgui.Create("DButton", frame)
label2:SetText("Quick Ban")
label2:SetSize(300,50)
label2:SetPos(250,100)
label2.DoClick = function()
frame:Close()
end
label3 = vgui.Create("DButton", frame)
label3:SetText("From When to When:")
label3:SetPos(250,200)
label3:SetSize(300,50)
label3.DoClick = function()
frame:Close()
end
label = vgui.Create("DButton", frame)
label:SetText("Video URL:")
label:SetPos(250,300)
label:SetSize(300,50)
label.DoClick = function()
frame:Close()
end
submit = vgui.Create("DButton", frame)
submit:SetText("Submit")
submit:SetPos(250,400)
submit:SetSize(300,50)
submit.DoClick = function()
frame:Close()
end
end
concommand.Add("adminmenu",frame_open)
hook.Add("Initialize","frame_create",frame_create)
usermessage.Hook("MyMenu", frame_open)[/CODE]
and this is my init.lua
[CODE]function frame_create( ply )
umsg.Start( "frame_open", ply )
umsg.End()
end
hook.Add("ShowSpare1", "MyHook", MyMenu)[/CODE]
It doesn't work because you've copypasted code without changing function names
Wait, why not just do
[CODE]
hook.Add("ShowSpare1", "MyHook", frame_open)
[/CODE]
Clientside and get rid of the other hooks? That would work, right?
Also, please localize the function at the top
[QUOTE=MPan1;49213155]Wait, why not just do
[CODE]
hook.Add("ShowSpare1", "MyHook", frame_open)
[/CODE]
Clientside and get rid of the other hooks? That would work, right?
Also, please localize the function at the top[/QUOTE]
Because ShowSpare(x) is serversided for... Whatever reason??
------
You're using globalised variables and functions, you're using outdated copypasta code and you're using user messages. Use net, localise your variables and write your own code because you can understand it.
i dont even see where you're hooking it to the f3 button
Still no error and I did what you guys said...
cl_init.lua
[CODE]function adminmenu()
frame = vgui.Create("DFrame")
frame:SetPos(50,50)
frame:SetSize(800,700)
frame:SetTitle("Easy Access Admin Menu")
frame:SetVisible(false)
frame:Center()
frame:SetDraggable(true)
frame:ShowCloseButton(false)
frame:SetBackgroundBlur(false)
frame:MakePopup()
frame.Paint = function()
draw.RoundedBox( 8, 0, 0, frame:GetWide(), frame:GetTall(), Color( 0, 0, 0, 255 ) )
end
local xbutton = vgui.Create("DButton", frame)
xbutton:SetText("X")
xbutton:SetSize(20,20)
xbutton:SetPos(780,0)
xbutton.DoClick = function()
frame:SetVisible(false)
end
local label2 = vgui.Create("DButton", frame)
label2:SetText("Quick Ban")
label2:SetSize(300,50)
label2:SetPos(250,100)
label2.DoClick = function()
local menu = DermaMenu()
for _,ply in pairs(player.GetAll()) do
menu:AddOption(ply:Name(),function() print(ply:Name()) end)
end
end
local label3 = vgui.Create("DButton", frame)
label3:SetText("From When to When:")
label3:SetPos(250,200)
label3:SetSize(300,50)
label3.DoClick = function()
frame:SetVisible(false)
end
local label = vgui.Create("DButton", frame)
label:SetText("Video URL:")
label:SetPos(250,300)
label:SetSize(300,50)
label.DoClick = function()
frame:SetVisible(false)
end
local submit = vgui.Create("DButton", frame)
submit:SetText("Submit")
submit:SetPos(250,400)
submit:SetSize(300,50)
submit.DoClick = function()
frame:SetVisible(false)
end
end
hook.Add("Initialize","frame_create",adminmenu)
net.Receive('openadminmenu', adminmenu)
print("GOT IT!")
concommand.Add("adminmenu", function()
frame:SetVisible(true)
end)[/CODE]
Init.lua
[CODE]util.AddNetworkString('openadminmenu')
hook.Add( "PlayerSay", "adminmenucommand", function( ply, text, public )
text = string.lower( text )
if ( text == "!adminmenu" ) then
ply:ConCommand( "adminmenu" )
return ""
end
end )
local function ShowSpare1(ply)
net.Start('openadminmenu')
net.Send(ply)
end
hook.Add("ShowSpare1", "f3adminmenu", adminmenu)
[/CODE]
Don't make ShowSpare1 a local function
[QUOTE=mjctechguy;49234135]Don't make ShowSpare1 a local function[/QUOTE]
Dont think this matters.
[code]local function ShowSpare1(ply)
net.Start('openadminmenu')
net.Send(ply)
end
hook.Add("ShowSpare1", "f3adminmenu", ShowSpare1)[/code]
Also remove the frame:SetVisible(false) from the adminmenu function and the derma should show when you press f3
[QUOTE=mjctechguy;49240893][code]local function ShowSpare1(ply)
net.Start('openadminmenu')
net.Send(ply)
end
hook.Add("ShowSpare1", "f3adminmenu", ShowSpare1)[/code]
Also remove the frame:SetVisible(false) from the adminmenu function and the derma should show when you press f3[/QUOTE]
You're a little late. Lol
I got it working without the need of an init.lua and I saw that mistake before you posted. Thanks guys!
Sorry, you need to Log In to post a reply to this thread.