Need some help with my Gamemode.

http://250kb.de/u/130722/p/evYcnYta5kHP.png

Sup Guys ,
Im coding a new Gamemode called ‘Warzone’ . But im not good in Gmod Lua . My first problem is shelf give :

Note : Thats loot_checkout.lua
/


--- Loadout Menu
function checkout()

	local bg = vgui.Create( "DFrame" )
	local bt = vgui.Create( "DButton" )
	
  bg:SetPos( ScrW()/2 - 225, ScrH()/2 - 100 )
  bg:SetSize( 450, 200 )
  bg.SetVisible( true )
  bg.SetTitle( "Loadout Menu" )
  bg:SetDraggable( true )
  bg:ShowCloseButton( true )
  bg:MakePopup()
  
	bt:SetParent( bg )
	bt:SetText( "AK-47" )
	bt:Center()
	bt:SettSize( 150, 50 )
		bt.DoClick = function()


And here should be the function for Shelf Give . 
It should give the gun in inventory.                                          <------------------------- Button give problem
bsp : self.Player:Give( "knife" )
But it does not work :(
	
		end


end

Then i want a function what opens the menu when pressed the KEY_Q . <------- Complete problem
And my last litte problem :

I want that the Menu opens on Spawn & Respawn.

Update : 22 . 7 . 2013
Added some problems :

How i change player Model with a button.
How i make it so that the menu comes first before spawning and then a button which spawns you.

**Note : If you think this guy can’t code , let me say somethink about me : Im 16 , and im coding much languages , but lua is complicated for me . I can’t write English good , but I can understand it very good. **
If you want to chat with me to get more code information , write me in steam!
Thanks if you guys help me :wink:

[LUA]function GM:PlayerBindPress(ply, bind, pressed)
if (bind == “+menu”) then
checkout()
end
[/LUA]
cl_init.lua

and also
[LUA]
function openOnSpawn( ply )
if PLAYER:Spawn()
checkout()
end
end

openOnSpawn()
[/LUA]

tell me if it works.

Thank it works but the openOnSpawn function does not work :frowning: i dont know why there, comes no error!

[editline]22nd July 2013[/editline]

And i need the give function for the button…

If you want it to be on initialspawn you can use

[LUA]
function GM:InitialSpawn( ply )
checkout()
end
[/LUA]

Thanks dude :slight_smile: But my other problems are not done^^

[editline]22nd July 2013[/editline]

And i had a problem now it mean that local bg = vgui.Create( “DFrame” )
local bt = vgui.Create( “DButton” )
is not global but how i change it to global ?

global bt= vgui.Cream( “DButton” ) does not work …

[editline]22nd July 2013[/editline]

**[ERROR] gamemodes/warzone/gamemode/lootwarzone.lua:93: attempt to index global ‘vgui’ (a nil value)

  1. checkout - gamemodes/warzone/gamemode/lootwarzone.lua:93
  2. RunClass - gamemodes/warzone/gamemode/lootwarzone.lua:49
    3. PlayerSpawn - gamemodes/base/gamemode/player.lua:245
    4. unknown - gamemodes/warzone/gamemode/init.lua:27

** With InitialSpawn

[editline]22nd July 2013[/editline]

[quote=“Nox that!, post:5, topic:131899”]

Thanks dude :slight_smile: But my other problems are not done^^

[editline]22nd July 2013[/editline]

And i had a problem now it mean that local bg = vgui.Create( “DFrame” )
local bt = vgui.Create( “DButton” )
is not global but how i change it to global ?

global bt= vgui.Cream( “DButton” ) does not work …

Download it here http://www.file-upload.net/download-7870034/warzone-gm-luaonly.zip.html
and fixed if you want … I dont know … My Brain is overflowing. If you mean it works , just reupload it and post the link .