@adrianooo321-legacy (adrianooo321) posted a new topic, subject "Gamemode devwlopment team choosing menu problem". It read:

   Sorry for the typo in the title   
    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
    [code] 
         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 )
         
        
        
        
    [/code]
    
    And when i load gmod with the gamemode i get this in the console
    [code] 
        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
        
        
        
    [/code]

So @Science-legacy (Science) replied

    Gamemode folder names cannot have spaces.
    
    Fix that and it will work.
    
    And this should be just:  
    [lua]include( ‘shared.lua' )[/lua]  
    Not twice.

After which, @Feihc-legacy (Feihc) added

    adrianooo321:
    
    > Sorry for the typo in the title   
    >  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
    [code] 
    >      include( 'shared.lua' ) //LOAD THAT
    >     nclude( "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 )
    >      
    >     
    >     
    >     
    [/code]
    > 
    > And when i load gmod with the gamemode i get this in the console
    [code] 
    >     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
    >     
    >     
    >     
    [/code]
    
    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.

So @MilkWorm-legacy (MilkWorm) replied

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

After which, @adrianooo321-legacy (adrianooo321) added

    Feihc:
    
    > 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.
    
    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

Then @Science-legacy (Science) said

    adrianooo321:
    
    > 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.

@adrianooo321-legacy (adrianooo321) replied

    Science:
    
    > 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:
    [code] 
         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 ) 
        
        
    [/code]
    
    I get the following console output :
    [code] 
        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
        
        
        
    [/code]

To which @Science-legacy (Science) replied

    adrianooo321:
    
    > I read all of them and no it wasnt fixed but it changed the error now with this cl_init:
    [code] 
    >      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 ) 
    >     
    >     
    [/code]
    > 
    > I get the following console output :
    [code] 
    >     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
    >     
    >     
    >     
    [/code]
    
    [lua]concommand.Add( “team_menu”, set_team )[/lua]

After which, @adrianooo321-legacy (adrianooo321) added

    Science:
    
    > [lua]concommand.Add( “team_menu”, set_team )[/lua]
    
    Sorry but i dont understand i have that dont I ?

After which, @Science-legacy (Science) added

    adrianooo321:
    
    > 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()
    [code] 
        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 
        
    [/code]
    
    end)[/lua]

So @adrianooo321-legacy (adrianooo321) replied

    Science:
    
    > 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()
    [code] 
    >     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 
    >     
    [/code]
    > 
    > 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  worked fine

So @Science-legacy (Science) replied

    adrianooo321:
    
    > 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  , so yeah , thanks anyway 
    
    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.

After which, @adrianooo321-legacy (adrianooo321) added

    Science:
    
    > 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  , anyway thanks for youe help science

To which @Science-legacy (Science) replied

    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.

@adrianooo321-legacy (adrianooo321) replied

    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  , 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

So @King_Flawless-legacy (King Flawless) replied

    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
    
    Since when did when did order of operations for a derma menu become bad style

To which @s0beit-legacy (s0beit) replied

    King Flawless:
    
    > 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.

So @Science-legacy (Science) replied

    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.


{'source': 'discourse', 'url': 'https://forum.facepunch.com/t/gamemode-devwlopment-team-choosing-menu-problem/86036', 'title': 'Gamemode devwlopment team choosing menu problem', 'views': 575, 'has_accepted_answer': False, 'word_count': 2636, 'like_count': 0, 'reply_count': 17, 'participant_count': 6, 'posts': 18, 'tags': '', 'author': '@adrianooo321-legacy (adrianooo321)', 'participants': '@adrianooo321-legacy (adrianooo321), @Science-legacy (Science), @Feihc-legacy (Feihc), @MilkWorm-legacy (MilkWorm), @King_Flawless-legacy (King Flawless), @s0beit-legacy (s0beit)', 'image_url': [None], 'created_at': '2011-05-21T19:49:36.000Z', 'last_posted_at': '2011-05-23T06:25:15.000Z'}