I'm trying to make a button on my derma panel and it keeps appearing below the derma.
[lua]
concommand.Add( "open_menu", function( ply, cmd, args )
local pnl = vgui.Create( "DFrame" )
pnl:SetSize( 600, 500 )
pnl:SetPos( 450, 50 )
pnl:SetTitle( "Set Playermodel" )
pnl:SetDraggable( true )
pnl:ShowCloseButton( true )
pnl:SetVisible( true )
pnl:MakePopup()
local pnlButton = vgui.Create( "DButton" )
pnlButton:SetParent( DermaPanel )
pnlButton:SetText( "Button" )
pnlButton:SetPos( 465, 510 )
pnlButton:SetSize( 150, 50 )
end )
[/lua]
[QUOTE=Chad Mobile;19855256]I'm trying to make a button on my derma panel and it keeps appearing below the derma.
[lua]
concommand.Add( "open_menu", function( ply, cmd, args )
local pnl = vgui.Create( "DFrame" )
pnl:SetSize( 600, 500 )
pnl:SetPos( 450, 50 )
pnl:SetTitle( "Set Playermodel" )
pnl:SetDraggable( true )
pnl:ShowCloseButton( true )
pnl:SetVisible( true )
pnl:MakePopup()
local pnlButton = vgui.Create( "DButton" )
pnlButton:SetParent( DermaPanel )
pnlButton:SetText( "Button" )
pnlButton:SetPos( 465, 510 )
pnlButton:SetSize( 150, 50 )
end )
[/lua][/QUOTE]
local pnlButton = vgui.Create( "DButton", pnl )
pnlButton:SetText( "Button" )
pnlButton:SetPos( 465, 510 )
pnlButton:SetSize( 150, 50 )
Edit* well actually your setpos is at 510 so you also need to change the setpos to something smaller like 465, 400
There are a bunch of methods that can help you with positioning:
[url]http://wiki.garrysmod.com/?title=Panel.AlignBottom[/url]
[url]http://wiki.garrysmod.com/?title=Panel.AlignRight[/url]
Well he didn't have a positioning problem Dbutton doesn't have a setparent function.
[QUOTE=-TB-;19856231]Well he didn't have a positioning problem Dbutton doesn't have a setparent function.[/QUOTE]
Positioning panels manually is a bad habit; it makes the code less reusable and less editable. You also lose any ability to make the frame adjust to the screen resolution.
Its not that bad if you use ScrW() and ScrH() and multiply them by precentages.
Isn't the position relative to the parent element position rather than being global?
Hmm nevermind then, your right.
I just need to make a menu that can pop up, and have a button (or more) that can be pressed to do something that I can control.
[editline]02:55PM[/editline]
[code]autorun/client/poop.lua:14: function arguments expected near '='[/code]
I get this error with this code:
[lua]
concommand.Add( "open_menu", function( ply, cmd, args )
local pnl = vgui.Create( "DFrame" )
pnl:SetSize( 600, 500 )
pnl:SetPos( 450, 50 )
pnl:SetTitle( "Set Playermodel" )
pnl:SetDraggable( true )
pnl:ShowCloseButton( true )
pnl:SetVisible( true )
local pnlButton = vgui.Create( "DButton", pnl )
pnlButton:SetText( "Button" )
pnlButton:SetPos( 225, 250 )
pnlButton:SetSize( 150, 50 )
pnlButton:DoClick = function( pnlButton )
RunConsoleCommand("give weapon_bugbait")
end )
[/lua]
I don't get this, but I've never done Derma before.
pnlButton.DoClick
Dot rather than colon. Reason for this is
mything.myfunc(mything, arg1, arg2 ...)
is equal to
mything:myfunc(arg1, arg2 ...)
But when you're defining a function like this you have to use the first notation. If you type out the second notation it assumes you're calling the function and expects you do put the arguments afterwards.
Ah, ok thanks. I'm trying to start a gamemode, but I might not. I'll have to see where it goes.
On the buttons RunConsoleCommand i didn't know you could put a console command that gives a weapon on a client file could be wronge.
it works for me :v:
dang every time i try it it messes up ill have to look into that for my gamemode.
Haha, Okay.
[QUOTE=??????;19865111]On the buttons RunConsoleCommand i didn't know you could put a console command that gives a weapon on a client file could be wronge.[/QUOTE]
I think give is a cheat command, that really shouldn't work on a multiplayer game. Unless I'm mistaken though, singleplayer lets you use cheats anyway.
give isn't a cheat command, because I just did impulse 101 and it didnt work until I turned sv_cheats on.
Lol.
so how would you give a weapon in multiplayer?
I'm just making this for singleplayer for now, I might start on a gamemode.
-Snip
[QUOTE=??????;19870048]so how would you give a weapon in multiplayer?[/QUOTE]
ply:Give("WeaponName")
[QUOTE=Brodster55;19872679]ply:Give("WeaponName")[/QUOTE]
Yeah, on the server. You'd have to have a console command so the client can contact the server "asking" for the weapon.
[QUOTE=iRzilla;19880735]Of course you would add some security so that it will only effect the loadout and not give it instantly.[/QUOTE]
Or only actually give you the weapon if you're an admin, or subtract points for spawning it only doing so if you have enough.
The policy for whether the player is allowed to have the weapon is up to you, the console command just signals to the server that a specific player is requesting it, not that you have to give him it.
Sorry, you need to Log In to post a reply to this thread.