Gamemode question (Just look, its in the right area)

First of all, yes this isn’t the game modes section, but this question fits here better than in the gamemodes.

This is my cl_init.lua file

include( ‘shared.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 )

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 RED” )
team_1.DoClick = function() --Make the player join team 1
RunConsoleCommand( “team_1” )

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 BLUE” )
team_2.DoClick = function() --Make the player join team 2
RunConsoleCommand( “team_2” )

concommand.Add( “team_menu”, set_team )

This is my init.lua file

AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include( ‘shared.lua’ )

// Serverside only stuff goes here

Name: gamemode:PlayerLoadout( )
Desc: Give the player the default spawning weapons/ammo
function GM:PlayerInitialSpawn( ply )

RunConsoleCommand( "team_menu" ) --Run the console command when the player first spawns


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

ply:StripWeapons() -- This command strips all weapons from the player.

if ply:Team() == 1 then --If the player is on team "Team RED"...
	ply:Give("weapon_crowbar") -- ...then give them the Crow Bar.

elseif ply:Team() == 2 then -- Otherwise, if the player is on team "Team BLUE"...
	ply:Give("weapon_stunstick") -- ...then give them the Stun Stick.

end -- This ends the if/elseif.

end – This ends the function

function team_1( ply )

ply:SetTeam( 1 )


function team_2( ply )

ply:SetTeam( 2 )


concommand.Add( “team_1”, team_1 )
concommand.Add( “team_2”, team_2 )

And this is my shared.lua file

GM.Author = “C-UNIT”
GM.Email = “N/A”
GM.Website = “N/A”

team.SetUp( 1, “TeamRED”, Color( 255, 55, 0, 155, 1 ) ) – for team red
team.SetUp( 1, “TeamBLUE”, Color( 0, 0, 255 ) ) – for team blue

My game mode is when you first join a menu comes up, and you choose team red or team blue, if you go team blue, you get a stun stick, if you go red you get a crow bar, but when i join the menu comes up, and when i click team read or team blue, nothing happens i have to exit out of the pop-up box that lets you choose, and i have no weapons at all, and you are always team blue, no matter what, any ideas?

You may want to kill the player after he/she selected team use ply:KillSilent()

ply:KillSilent() in the init.lua?

and under what InitialSpawn? PlayerSpawn?

And im pretty sure that isnt the problem, like all that happens is you click the button, and nothing happens so you click the X to exit out of the team choose menu, and you are always team blue, with no weapons

[Editline]2:05 PM[/Editline]
I think i just found out what was wrong…

team.SetUp( 1, “TeamRED”, Color( 255, 55, 0, 155, 1 ) ) – for team red
team.SetUp( 1, “TeamBLUE”, Color( 0, 0, 255 ) ) – for team blue

Both are “team.SetUp( 1” not “team.SetUp( 1” and “team.SetUp( 2”

It should work fine without doing anything Tobba said.

Yeah, change them to:
team.SetUp( 1, “TeamRED”, Color( 255, 55, 0, 155, 1 ) ) – for team red
team.SetUp( 2, “TeamBLUE”, Color( 0, 0, 255 ) ) – for team blue

Or you could even do:


team.SetUp( TEAM_RED, “TeamRED”, Color( 255, 55, 0, 155, 1 ) ) – for team red
team.SetUp( TEAM_BLUE, “TeamBLUE”, Color( 0, 0, 255 ) ) – for team blue [/lua]

And then you would do:

ply:SetTeam( TEAM_RED )
Etc. Then you would be able to remember them more easily, instead of remembering 1, 2 and so on.

Just as a example, it isn’t necessary.

Ok, well i will probably leave them how they are for the sake of not having to go in and edit, i fixed them and you can now be either team red or team blue, but, you still have all your weapons stripped, and you are not given a Crowbar(if on red team) or a Stun Stick (if on blue team)

Ok, Wow, your not gonna believe this but, it actually give you your weapons when you get killed. So Tobba was right. Now What’s the command to make it so you die everytime you try changing teams?
Because i tried
team_1.DoClick = function()

Wow, ok umm i made it so that it kills you everytime that you change teams… Now the last thing i need is how to make it so that when you click the team button, it closes the menu…

Bump :smiley:

Does anyone know how to make it so when you click button1 or button2 (team_1 / team_2) it closes the derma menu on top of also carrying out the other functions i have set