Hey so I have a Derma menu I need multiple buttons on, but I cant get a second button. My files are below
cl_init.lua:
[CODE]
include('shared.lua')
function ENT:Initialize()
self.Color = Color( 255, 255, 255, 255 )
end
function ENT:Draw()
--self:DrawEntityOutline( 1 )
self.Entity:DrawModel()
end
local function myMenu()
local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 550, 300 )
Frame:SetSize( 300, 300 )
Frame:SetTitle( "Ambassador" ) -- Title of Derma menu, can be changed to whatever you like.
Frame:SetVisible( true ) -- Do you want the derma menu to show?
Frame:SetDraggable( true ) -- Do you want to allow users to drag the menu
Frame:ShowCloseButton( true ) -- Do you want the X at the top right to appear?
Frame:MakePopup()
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(50, 25)
DButton:SetText( "Forums" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "forums" ) -- Console Command. Can be change in the command.lua
end
end
usermessage.Hook("Ambassador",myMenu) -- Menu Hook
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(100, 50)
DButton:SetText( "Collection" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "collection" ) -- Console Command. Can be change in the command.lua
end
end
usermessage.Hook("Collection",myMenu) -- Menu Hook[/CODE]
init.lua:
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/Humans/Group01/male_02.mdl")
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE || CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
self:DropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("Ambassador", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
end
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("Collection", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
end
end[/CODE]
Whats the issue? Why dosent the second button show up? Please help, I could really use it.
Put this into notepad++ because everything looked okay apart from the ends
Looks like your second button isn't actually inside the menu function:
[img]http://i.imgur.com/HRdZgtF.png[/img]
[IMG]http://i.imgur.com/OufHWEK.png[/IMG]
So :
cl_init.lua
[CODE]
include('shared.lua')
function ENT:Initialize()
self.Color = Color( 255, 255, 255, 255 )
end
function ENT:Draw()
--self:DrawEntityOutline( 1 )
self.Entity:DrawModel()
end
local function myMenu()
local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 550, 300 )
Frame:SetSize( 300, 300 )
Frame:SetTitle( "Ambassador" ) -- Title of Derma menu, can be changed to whatever you like.
Frame:SetVisible( true ) -- Do you want the derma menu to show?
Frame:SetDraggable( true ) -- Do you want to allow users to drag the menu
Frame:ShowCloseButton( true ) -- Do you want the X at the top right to appear?
Frame:MakePopup()
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(50, 25)
DButton:SetText( "Forums" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "forums" ) -- Console Command. Can be change in the command.lua
end
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(100, 50)
DButton:SetText( "Collection" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "collection" ) -- Console Command. Can be change in the command.lua
end
end
usermessage.Hook("OpenMenu",myMenu) -- Menu Hook
[/CODE]
init.lua
[CODE]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/Humans/Group01/male_02.mdl")
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE || CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
self:DropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("OpenMenu", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
end
end
[/CODE]
You should also have a unique name for every button you make.
[QUOTE=Invule;50054456]You should also have a unique name for every button you make.[/QUOTE]
No you don't
[QUOTE=Jawad Bendo;50053279][IMG]http://i.imgur.com/OufHWEK.png[/IMG]
So :
cl_init.lua
[CODE]
include('shared.lua')
function ENT:Initialize()
self.Color = Color( 255, 255, 255, 255 )
end
function ENT:Draw()
--self:DrawEntityOutline( 1 )
self.Entity:DrawModel()
end
local function myMenu()
local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 550, 300 )
Frame:SetSize( 300, 300 )
Frame:SetTitle( "Ambassador" ) -- Title of Derma menu, can be changed to whatever you like.
Frame:SetVisible( true ) -- Do you want the derma menu to show?
Frame:SetDraggable( true ) -- Do you want to allow users to drag the menu
Frame:ShowCloseButton( true ) -- Do you want the X at the top right to appear?
Frame:MakePopup()
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(50, 25)
DButton:SetText( "Forums" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "forums" ) -- Console Command. Can be change in the command.lua
end
local DButton = vgui.Create( "DButton", Frame )
DButton:SetPos(100, 50)
DButton:SetText( "Collection" )
DButton:SetTextColor( Color(0, 0, 0, 255) ) -- Color of text on the button. I have it set to black. If you need help changing the color, see the note.txt
DButton:SetSize( 200, 50 )
DButton.DoClick = function()
RunConsoleCommand( "collection" ) -- Console Command. Can be change in the command.lua
end
end
usermessage.Hook("OpenMenu",myMenu) -- Menu Hook
[/CODE]
init.lua
[CODE]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/Humans/Group01/male_02.mdl")
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE || CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
self:DropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("OpenMenu", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
end
end
[/CODE][/QUOTE]
I see my issue, thanks a ton!
[editline]2nd April 2016[/editline]
[QUOTE=NiandraLades;50052424]Put this into notepad++ because everything looked okay apart from the ends
Looks like your second button isn't actually inside the menu function:
[img]http://i.imgur.com/HRdZgtF.png[/img][/QUOTE]
Thanks you so much for the help Niandra.
Sorry, you need to Log In to post a reply to this thread.