So, i was learning LUA with my first tutorials, was about to program a Derma GUI. There you could choose your weapons. I compared multiple scripts, found no mistakes but my GUI will not open using the console command ‘selectweapon’. Here’s my code:
function GivePlayerAWeapon( ply, cmd, args ) -- ply is the player, cmd is the command name (weapon_give), args is the arguments. if args == "pistol" then -- if the first argument is "pistol the do the following" ply:Give( "weapon_pistol" ) -- gives the player a pistol ply:ChatPrint( "You got a pistol" ) end end concommand.Add( "weapon_take", GivePlayerAWeapon ) concommand.Add( "selectweapon", WeaponSelectorDerma ) -- This console command doesn't work.
My Clientside Stuff for the gui is this:
concommand.Add( "selectweapon", WeaponSelectorDerma ) -- tried to define the console command a second time. function WeaponSelectorDerma() SHOPWeaponFrame = vgui.Create( "DFrame" ) -- create a frame. SHOPWeaponFrame:SetSize( 250, 80 ) -- sets its size. SHOPWeaponFrame:Center() SHOPWeaponFrame:SetTitle( "Choose your gun and run!" ) SHOPWeaponFrame:SetDraggable( true ) SHOPWeaponFrame:SetSizable( true ) -- can you resize it? SHOPWeaponFrame:ShowCloseButton( true ) SHOPPistolButton = vgui.Create( "DButton", SHOPWeaponFrame ) SHOPPistolButton:SetSize( 100, 30 ) SHOPPistolButton:SetPos( 10, 35 ) SHOPPistolButton:SetText( "Pistol" ) SHOPPistolButton.DoClick = function() RunConsoleCommand( "weapon_take", "pistol" ) SHOPWeaponFrame:Close() end -- make it run weapon_take in the console with the argument pistol. end
Sorry about some comments. These are the rest of explaining myself some LUA stuff.
Maybe it’s just silly mistake, but it would be great if you guys could help me. This is my first GUI and a little bit frustrating that it doesn’t work. I tested other GUIs with the ingame LUA-Pad before and it worked fine? So what’s the Problem?