Gamemode devwlopment team choosing menu problem

Sorry for the typo in the title :frowning:
Ok im a developing a gamemode and i have the team choosing menu , but when i load the gamemode it wont come up here is the code from cl_init.lua


 include( 'shared.lua' ) //LOAD THAT
 
 function set_team() 
 
 frame = vgui.Create( "DFrame" ) 
 frame:SetPos( 100, ScrH() / 2 ) //Set the window in the middle of the players screen/game window 
 frame:SetSize( 200, 210 ) //Set the size 
 frame:SetTitle( "Change Team" ) //Set title 
 frame:SetVisible( true ) 
 frame:SetDraggable( false ) 
 frame:ShowCloseButton( true ) 
 frame:MakePopup() 
 
 team_1 = vgui.Create( "DButton", frame ) 
 team_1:SetPos( 30, 30 )
 team_1:SetSize( 100, 50 ) 
 team_1:SetText( "Humans" ) 
 team_1.DoClick = function() //Make the player join team 1 
 
     RunConsoleCommand( "team_1" ) 
 
 end 
 
 team_2 = vgui.Create( "DButton", frame ) 
 team_2:SetPos( 30, 85 ) //Place it next to our previous one 
 team_2:SetSize( 100, 50 ) 
 team_2:SetText( "Tokra" ) 
 team_2.DoClick = function() //Make the player join team 2 
 
     RunConsoleCommand( "team_2" ) 
	
 
 end 
 
 team_3 = vgui.Create( "DButton", frame ) 
 team_3:SetPos( 135, 30 ) //Place it next to our previous one 
 team_3:SetSize( 100, 50 ) 
 team_3:SetText( "Goauld" ) 
 team_3.DoClick = function() //Make the player join team 3 
 
     RunConsoleCommand( "team_3" ) 
 
 end 
 
 team_4 = vgui.Create( "DButton", frame ) 
 team_4:SetPos( 135, 85 ) //Place it next to our previous one 
 team_4:SetSize( 100, 50 ) 
 team_4:SetText( "Wraith" ) 
 team_4.DoClick = function() //Make the player join team 4 
 
     RunConsoleCommand( "team_4" ) 
 
 end
 
 end 
 concommand.Add( "team_menu", set_team )
 


And when i load gmod with the gamemode i get this in the console


Couldn't include file 'Stargate Roleplay\gamemode\cl_init.lua' (File not found) (<nowhere>)
[cpp] 
There was a problem opening the gamemode file 'Stargate Roleplay/gamemode/cl_init.lua'


Registering gamemode 'Stargate Roleplay' derived from 'base'
Sending 8 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
Scanning for downloaded fonts..
Redownloading all lightmaps


Gamemode folder names cannot have spaces.

Fix that and it will work.

And this should be just:
[lua]include( ‘shared.lua’ )[/lua]
Not twice.

Its not being found because it’s not registering because there is an error in it.

You are missing the “i” in “include” on the second line of your file.

Your missing a I in include and have spaces in file paths

The missing I was just an mistake when i copied over the code in the file itself its there but it still wont show the team menu , i have a clean gmod , no addons or extra maps so its not conflicting i will try to get rid of the spaces in the gamemode files now

Maybe if you read the other posts in thread your problem will be fixed.

I read all of them and no it wasnt fixed but it changed the error now with this cl_init:


 include( "shared.lua" )
 
 function set_team() 
 
 frame = vgui.Create( "DFrame" ) 
 frame:SetPos( 100, ScrH() / 2 ) //Set the window in the middle of the players screen/game window 
 frame:SetSize( 200, 210 ) //Set the size 
 frame:SetTitle( "Change Team" ) //Set title 
 frame:SetVisible( true ) 
 frame:SetDraggable( false ) 
 frame:ShowCloseButton( true ) 
 frame:MakePopup() 
 
 team_1 = vgui.Create( "DButton", frame ) 
 team_1:SetPos( 30, 30 )
 team_1:SetSize( 100, 50 ) 
 team_1:SetText( "Humans" ) 
 team_1.DoClick = function() //Make the player join team 1 
 
     RunConsoleCommand( "team_1" ) 
 
 end 
 
 team_2 = vgui.Create( "DButton", frame ) 
 team_2:SetPos( 30, 85 ) //Place it next to our previous one 
 team_2:SetSize( 100, 50 ) 
 team_2:SetText( "Tokra" ) 
 team_2.DoClick = function() //Make the player join team 2 
 
     RunConsoleCommand( "team_2" ) 
	
 
 end 
 
 team_3 = vgui.Create( "DButton", frame ) 
 team_3:SetPos( 135, 30 ) //Place it next to our previous one 
 team_3:SetSize( 100, 50 ) 
 team_3:SetText( "Goauld" ) 
 team_3.DoClick = function() //Make the player join team 3 
 
     RunConsoleCommand( "team_3" ) 
 
 end 
 
 team_4 = vgui.Create( "DButton", frame ) 
 team_4:SetPos( 135, 85 ) //Place it next to our previous one 
 team_4:SetSize( 100, 50 ) 
 team_4:SetText( "Wraith" ) 
 team_4.DoClick = function() //Make the player join team 4 
 
     RunConsoleCommand( "team_4" ) 
 
 end
 
 end 
 concommand.Add( "team_menu" set_team ) 

I get the following console output :


Lua initialized (Lua 5.1)
[gamemodes\stargaterp\gamemode\cl_init.lua:56] ')' expected near 'set_team'
[cpp] 
There was a problem opening the gamemode file 'StargateRP/gamemode/cl_init.lua'


Registering gamemode 'StargateRP' derived from 'base'
Sending 8 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
Scanning for downloaded fonts..
Unknown command: team_menu
Redownloading all lightmaps


[lua]concommand.Add( “team_menu”, set_team )[/lua]

Sorry but i dont understand i have that dont I ?

You have 2 options.

1 - Read the lua pil and learn basic lua knowledge.
2 - Give up and dont try making a gamemode.

But untill you decide, hereas a working code.
I would use DPanelList but i dont have the time.
[lua]include( “shared.lua” )

concommand.Add(“team_menu”, function(ply, cmd, args)
frame = vgui.Create( “DFrame” )
frame:SetSize( 200, 210 )
frame:Center()
frame:SetTitle( “Change Team” )
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()

team_1 = vgui.Create( "DButton", frame ) 
team_1:SetPos( 30, 30 )
team_1:SetSize( 100, 50 ) 
team_1:SetText( "Humans" ) 
team_1.DoClick = function() //Make the player join team 1
	RunConsoleCommand( "team_1" ) 
end 
 
team_2 = vgui.Create( "DButton", frame ) 
team_2:SetPos( 30, 85 ) //Place it next to our previous one 
team_2:SetSize( 100, 50 ) 
team_2:SetText( "Tokra" ) 
team_2.DoClick = function() //Make the player join team 2 
	RunConsoleCommand( "team_2" ) 
end 

team_3 = vgui.Create( "DButton", frame ) 
team_3:SetPos( 135, 30 ) //Place it next to our previous one 
team_3:SetSize( 100, 50 ) 
team_3:SetText( "Goauld" ) 
team_3.DoClick = function() //Make the player join team 3  
	RunConsoleCommand( "team_3" )  
end 
 
team_4 = vgui.Create( "DButton", frame ) 
team_4:SetPos( 135, 85 ) //Place it next to our previous one 
team_4:SetSize( 100, 50 ) 
team_4:SetText( "Wraith" ) 
team_4.DoClick = function() //Make the player join team 4  
	RunConsoleCommand( "team_4" )  
end 

end)[/lua]

I am still learning but as i learn i try to try out the things i learn , anyway i based this code on a tutorial on gmod wiki and the team_menu command was there at the bottom , anyway thank you man :smiley: worked fine

You did not base it off anything.
You copy and pasted it without fully understanding its use.

Wikis code
[lua]function set_team()

local frame = vgui.Create( “DFrame” )
frame:SetPos( ScrW() / 2, ScrH() / 2 ) --Set the window in the middle of the players screen/game window
frame:SetSize( 200, 210 ) --Set the size
frame:SetTitle( “Change Team” ) --Set title
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()

team_1 = vgui.Create( “DButton”, frame )
team_1:SetPos( frame:GetTall() / 2, 5 ) --Place it half way on the tall and 5 units in horizontal
team_1:SetSize( 50, 100 )
team_1:SetText( “Team 1” )
team_1.DoClick = function() --Make the player join team 1
RunConsoleCommand( “team_1” )
end

team_2 = vgui.Create( “DButton”, frame )
team_2:SetPos( frame:GetTall() / 2, 105 ) --Place it next to our previous one
team_2:SetSize( 50, 100 )
team_2:SetText( “Team 2” )
team_2.DoClick = function() --Make the player join team 2
RunConsoleCommand( “team_2” )
end

end
concommand.Add( “team_menu”, set_team )[/lua]

You copy and pasted and added a few more copy and pastes.

Yeah i read the code , i get most of the stuff as i know c++ (not very similar but close enough) and because it was there why should re-write all the code if i can just copy and paste bits and change it to fit me :smiley: , anyway thanks for youe help science

The point of rewriting the code is to learn and take it in.
Also, there are so many bad styles in that code.
I mean, what idiot puts the SetSize above SetPos, it then blows everything out of proportion.
So many others but I can’t type from this phone and I’ll rewrite the code tomorrow.

I see , some wise words there :smiley: , and if you do rewrite the code that would be awsome , if you have time you should write some lua tutorials , you seem to have alot knowledge on the topic

Since when did when did order of operations for a derma menu become bad style

It is somewhat subjective, but i also like to set positions before size. Doesn’t mean it’s bad style, though, necessarily.

When I can finally move which won’t be for some hours due to my muscles I will give you an example of what I mean.