Derma/VGUI Help

So im trying to make a new menu.
And I keep getting this error;
[lua]
Unknown Command: TEAM_Mayor
[/lua]
Btw, im new to LUA coding, and trying to learn something.

** init.lua **
[lua]
AddCSLuaFile( “shared.lua” )
AddCSLuaFile( “cl_init.lua” )


// You can make a simple function using arguements to make this less messier but this would be the simplest way to explain what it does.
function TEAM_Mayor( ply ) – Creating the function.
ply:UnSpectate() – As soon as the person joins the team, he get’s Un-spectated
ply:SetTeam( 1 ) – We’ll set him to team 1
ply:Spawn() – Let’s spawn him.
ply:Give( “weapon_physgun” ) – …then give them the Gravity Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “weapon_mad_fists” )
ply:SetModel( “models/player/urban.mdl” )

end – End the function
concommand.Add(“TEAM_Mayor”, TEAM_Mayor) – Adding a concommand (Console Command) for the team.

function TEAM_SWAT( ply )
ply:UnSpectate()
ply:SetTeam( 2 )
ply:Spawn()
ply:Give( “weapon_physgun” ) – …then give them the Phys Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “arrest_stick” )
ply:Give( “unarrest_stick” )
ply:Give( “stunstick” )
ply:Give( “weapon_mad_fists” )
ply:Give( “weapon_mad_mp5” )
ply:SetModel( “models/player/combine_soldier.mdl” )
end
concommand.Add(“TEAM_SWAT”, TEAM_SWAT)

function TEAM_Police( ply )
ply:UnSpectate()
ply:SetTeam( 3 )
ply:Spawn()
ply:Give( “weapon_physgun” ) – …then give them the Phys Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “arrest_stick” )
ply:Give( “unarrest_stick” )
ply:Give( “stunstick” )
ply:Give( “weapon_mad_fists” )
ply:Give( “weapon_mad_mp5” )
ply:SetModel( “models/player/police.mdl” )
end
concommand.Add(“TEAM_Police”, TEAM_Police)

function TEAM_Army( ply )
ply:UnSpectate()
ply:SetTeam( 4 )
ply:Spawn()
ply:Give( “weapon_physgun” ) – …then give them the Phys Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “arrest_stick” )
ply:Give( “unarrest_stick” )
ply:Give( “stunstick” )
ply:Give( “weapon_mad_fists” )
ply:Give( “weapon_mad_mp5” )
ply:Give( “weapon_mad_m3” )
ply:SetModel( “models/player/urban.mdl” )
end
concommand.Add(“TEAM_Army”, TEAM_Army)

end

function GM:PlayerInitialSpawn( ply ) --“When the player first joins the server and spawns” function

ply:ConCommand( "TeamMenu" ) --Run the console command when the player first spawns

end --End the “when player first joins server and spawn” function

function GM:PlayerLoadout( ply ) --“The weapons/items that the player spawns with” function

ply:StripWeapons() -- This command strips all weapons from the player.
		
end -- This ends the if/elseif.

end – This ends the function.

[/lua]

** cl_init.lua **
[lua]
AddCSLuaFile( “shared.lua” )

function TeamMenu( ) – Starting the function.

// all the buttons I’m about to create are just a simple way to explain everything. I would make a table and make buttons that way but look through some more tutorials about loops till you do that.
local TeamMenu = vgui.Create( “DFrame” ) – Creating the Vgui.
TeamMenu:SetPos( ScrW() +250, ScrH() / 2 -200 ) – Setting the position of the menu.
TeamMenu:SetSize( 260, 210 ) – Setting the size of the menu.
TeamMenu:SetTitle( “Choose Which Class You Wanna Exploit.” ) – The menu title.
TeamMenu:ShowCloseButton( false ) – Want us to see the close button? No.
TeamMenu:SetVisible( true ) – Want it visible?
TeamMenu:SetDraggable( false ) – Setting it draggable?
TeamMenu:MakePopup( ) – And now we’ll make it popup
function TeamMenu:Paint() – This is the funny part. Let’s paint it.
draw.RoundedBox( 8, 0, 0, self:GetWide(), self:GetTall(), Color( 0,0,0,200 ) ) – This paints, and round’s the corners etc.
end – Now we ONLY end the painting function.

– This is a part which I had to add for the fun sake.

if !TeamMenu.Open then – If the menu is closed, then
TeamMenu:MoveTo(ScrW() / 2 - 250, ScrH() / 2 - 200, 1.6, 0,1) – When you open it, it will slide trough the screen, not teleport.
end – Ending the if statement

– Button time.
local team_1 = vgui.Create( “DButton”, TeamMenu ) – Creating the vgui of the button.
team_1:SetPos( 5, 30 ) – Setting the position.
team_1:SetSize( 250, 30 ) – Setting the size
team_1:SetText( “Mayor” ) – Setting the text of the button

team_1.Paint = function() – The paint function
surface.SetDrawColor( 0, 255, 0, 255 ) – What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, team_1:GetWide(), team_1:GetTall() ) – Paint what cords
end – Ending the painting

team_1.DoClick = function() --Make the player join team 1
RunConsoleCommand( “TEAM_Mayor” )
TeamMenu:Close() – Close the DFrame (TeamMenu)
end – Ending the button.

– Now, this will be going on for 3 other buttons.
local team_2 = vgui.Create( “DButton”, TeamMenu )
team_2:SetPos( 5, 70 )
team_2:SetSize( 250, 30 )
team_2:SetText( “SWAT” )

team_2.Paint = function() – The paint function
surface.SetDrawColor( 0, 0, 255, 255 ) – What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, team_2:GetWide(), team_2:GetTall() ) – Paint what cords (Used a function to figure that out)
end

team_2.DoClick = function() --Make the player join team 2
RunConsoleCommand( “TEAM_SWAT” )
TeamMenu:Close()
end

local team_3 = vgui.Create( “DButton”, TeamMenu )
team_3:SetPos( 5, 110 ) --Place it next to our previous one
team_3:SetSize( 250, 30 )
team_3:SetText( “Police” )

team_3.Paint = function() – The paint function
surface.SetDrawColor( 255, 0, 0, 255 ) – What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, team_3:GetWide(), team_3:GetTall() ) – Paint what cords (Used a function to figure that out)
end

team_3.DoClick = function() --Make the player join team 3
RunConsoleCommand( “TEAM_Police” )
TeamMenu:Close()
end

local team_4 = vgui.Create( “DButton”, TeamMenu )
team_4:SetPos( 5, 150 ) --Place it next to our previous one
team_4:SetSize( 250, 30 )
team_4:SetText( “Army” )

team_4.Paint = function() – The paint function
surface.SetDrawColor( 102, 34, 0, 255 ) – What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, team_3:GetWide(), team_3:GetTall() ) – Paint what cords (Used a function to figure that out)
end

team_4.DoClick = function() --Make the player join team 4
RunConsoleCommand( “TEAM_Army” )
TeamMenu:Close()
end

end – Now we’ll end the whole function.

concommand.Add(“TeamMenu”, TeamMenu) – Adding the Console Command. So whenever you enter your gamemode, simply type TeamMenu in console.
[/lua]

** shared.lua **
[lua]
//Shared.lua

----------Colors---------
local clrTable = {} //Color table
clrTable[“Green”] = Color(20, 150, 20, 255)
clrTable[“Blue”] = Color(25, 25, 170, 255)
clrTable[“Red”] = Color(150, 20, 20, 255)
clrTable[“Brown”] = Color(102, 34, 0, 255)

GM.Name = “Test Mod”
GM.Author = “Markus Olsen”
GM.Email = “”
GM.Website = “www.serveraim.net

TEAM_1 = 1
TEAM_2 = 2
TEAM_3 = 3
TEAM_4 = 4

team.SetUp( TEAM_1, “Mayor”, clrTable[“Green”] )
team.SetUp( TEAM_2, “SWAT”, clrTable[“Blue”] )
team.SetUp( TEAM_3, “Police”, clrTable[“Red”] )
team.SetUp( TEAM_4, “Army”, clrTable[“Brown”] )
[/lua]

function TEAM_Mayor( ply )

You use TEAM_Mayor in a concommand.
You need 3 arguments for that:

function TEAM_Mayor( ply, cmd, args )

Change all of your concommands.

[lua]
function GM:PlayerLoadout( ply ) --“The weapons/items that the player spawns with” function

ply:StripWeapons() -- This command strips all weapons from the player.
         
end -- This ends the if/elseif.

end – This ends the function.
[/lua]

In init.lua is causing an error, that is why the console command does not exist.
You have one ‘end’ too much.

[editline]18th February 2012[/editline]

You are not required to have all the arguments defined.

Ehm, so what would the code be?
[lua]
function TEAM_SWAT( ply )
ply:UnSpectate()
ply:SetTeam( 2 )
ply:Spawn()
ply:Give( “weapon_physgun” ) – …then give them the Phys Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “arrest_stick” )
ply:Give( “unarrest_stick” )
ply:Give( “stunstick” )
ply:Give( “weapon_mad_fists” )
ply:Give( “weapon_mad_mp5” )
ply:SetModel( “models/player/combine_soldier.mdl” )
end
concommand.Add(“TEAM_SWAT”, TEAM_SWAT)
[/lua]

Am I going to change this?:
**function TEAM_SWAT( ply ) **
Or this?:
**concommand.Add(“TEAM_SWAT”, TEAM_SWAT) **

He wants you to define all the arguments like this
[lua]function TEAM_SWAT( ply, cmd, args )[/lua]

But that is not the problem here at all. You are only using the player argument so you don’t need the other ones.

Ok, I will try what you wrote. Brb, ill post here if it works or not.
Edit: Wait, will it be like this?
[lua]

function TEAM_Army( ply )
ply:UnSpectate()
ply:SetTeam( 4 )
ply:Spawn()
ply:Give( “weapon_physgun” ) – …then give them the Phys Gun.
ply:Give( “weapon_physcannon” )
ply:Give( “keys” )
ply:Give( “arrest_stick” )
ply:Give( “unarrest_stick” )
ply:Give( “stunstick” )
ply:Give( “weapon_mad_fists” )
ply:Give( “weapon_mad_mp5” )
ply:Give( “weapon_mad_m3” )
ply:SetModel( “models/player/urban.mdl” )
end
concommand.Add(“TEAM_Army”, TEAM_Army)

function GM:PlayerInitialSpawn( ply ) --“When the player first joins the server and spawns” function

ply:ConCommand( "TeamMenu" ) --Run the console command when the player first spawns

end --End the “when player first joins server and spawn” function

function GM:PlayerLoadout( ply ) --“The weapons/items that the player spawns with” function

ply:StripWeapons() -- This command strips all weapons from the player.
         
end -- This ends the if/elseif.

[/lua]

[editline]18th February 2012[/editline]

Unknown command: TeamMenu
Anyone?

you didn’t add the TeamMenu command

I just tried your client code and it works like it should for me.
Have you changed the client code since you posted the original question?

Old habit, but you’re right. I just quickly read it through and noticed that.