Can't figure out what I'm doing wrong with my gamemode, and I've triple-checked EVERYTHING

3KB Gamemode RAR here.

Specifically, there’s something wrong in cl_init (or “not cl_init”, i the RAR, since I was double-checking that it WAS actually the lua files that were causing the script errors) whenever I try to join a team, it’s trying to join team “atfr_set_team” instead of any of the existing teams, and I’ve checked (and double checked, and triple checked) that all the arguments are in the right order (and it doesn’t call the console command if I change the first argument to anything else, and the var is perfectly fine when I pass it in).

I eagerly await someone posting the insanely bloody obvious mistake which I’ve somehow missed several times over several hours, proceeded by some general cussing, further proceeded by a return to sanity. AAAAAAAAAAAAAAAAAAAAAAARGH

Please read that and it will help out a lot, as in not putting server stuff in the client file and such. I hope i helped and good luck.

Thanks, but I’ve already read that several times. I tried moving the entire “set team” (but not “choose team”, since that’s just the GUI and all the tutorials with one do that in cl_init) thing to init (from cl_init), but it doesn’t actually change anything, it’s still having the chosen_team parameter set as “atfr_set_team” in the atfr_set_team function. Any other ideas on what the problem/solution is? I’ve already gone through and checked all the basic stuff that I could think of.

shared.lua
[lua]

GM.Name = “Abyss’s TF2 ripoff”
GM.Author = “Abyss”
GM.Email = “N/A”
GM.Website = “N/A”
GM.Help = “Join a team, pick a class, kill stuff. Or spectate. It’s TF2.”

GM.Data = {}

DeriveGamemode( “base” )

team.SetUp(1, “Spectator”, Color(0,0,0,255) )
team.SetUp(2, “RED”, Color(255,0,0,255) )
team.SetUp(3, “BLU”, Color(0,0,255,255) )

GM.TeamBased = true

function GM:Initialize()

self.BaseClass.Initialize( self )

end
[/lua]

init.lua
[lua]

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

include( ‘shared.lua’ )

include( ‘shared.lua’ )

// Clientside only stuff goes here

–[[function set_team(ply)
if chosen_team == “Spectator” then
–Player:SetTeam( Integer team index )
ply:SetTeam( 1 )
Msg( "teamchoice is " … chosen_team … "! Joining that team!
" )
end
if chosen_team == “RED” then
ply:SetTeam( 2 )
Msg( "teamchoice is " … chosen_team … "! Joining that team!
" )
end
if chosen_team == “BLU” then
ply:SetTeam( 3 )
Msg( "teamchoice is " … chosen_team … "! Joining that team!
" )
end
//Msg( "YOU SHOULD NOT BE ABLE TO READ THIS.
" )
//Msg( "chosen team is " … chosen_team … ".
" )
–Msg( "player prints out to " … ply … ".
" )
end–]]

function set_team_spectate( ply )
ply:SetTeam( 1 )
ply:ChatPrint( “You are on team spectate” )
end

function set_team_red( ply )
ply:SetTeam( 2 )
ply:Give(“weapon_crowbar”)
ply:ChatPrint( “You are on team Red” )
end
function set_team_blu(ply)
ply:SetTeam( 3 )
ply:Give(“weapon_physcannon”)
ply:ChatPrint( “You are on team Blu” )
end

concommand.Add( “atfr_set_team_red”, set_team_red )-- concommand.Add( “stringname”, function name )
concommand.Add( “atfr_set_team_blu”, set_team_blu )-- concommand.Add( “stringname”, function name )
concommand.Add( “atfr_set_team_spectate”, set_team_spectate )-- concommand.Add( “stringname”, function name )

– Serverside only stuff goes here
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply )

ply:SetGravity( 1 )
ply:SetMaxHealth( 100, true )
ply:SetWalkSpeed( 325 )
ply:SetRunSpeed( 325 )

end

function GM:PlayerInitialSpawn( ply )

RunConsoleCommand( "atfr_choose_team" )--RunConsoleCommand( "stringname of a concommand.Add" )

end
/---------------------------------------------------------
Name: gamemode:PlayerLoadout( )
Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------
/
function GM:PlayerLoadout( ply )
ply:StripWeapons()
if ply:Team() == 2 then
ply:GiveAmmo( 255, “Pistol”, true )
ply:Give( “weapon_crowbar” )
ply:Give( “weapon_pistol” )
ply:Give( “weapon_crossbow” )
end

if ply:Team() == 3 then
	ply:Give( "weapon_physcannon" )
end	

--ply:Give( "empty_weapon" )

end
[/lua]

cl_init.lua
[lua]
include( ‘shared.lua’ )

function choose_team(ply)

Msg("choosing team!")

--change these

local rlx = 80 --red length
local rly = 20 --red height

local sly = 20 --spectator button length

local x1 = 10	
local x3 = 10
local x5 = 10

local y1 = 40
local y3 = 10
local y5 = 10
--don't change these

local blx = rlx --blu button length (should be same as red button length)
local bly = rly


local team_choice = nil
local x2 = rlx
local x4 = rlx

local y2 = rly
local y4 = sly


local rx  = x1 --red button position (ie top left corner of button)
local ry  = y1

local bx  = x1 + x2 + x3 --blu button position
local by  = y1

local sx  = x1 --spectator button position
local sy  = y1 + y2 + y3
local slx = x2 + x3 + x4 --spectator button length


local size_x = x1 + x2 + x3 + x4 + x5
local size_y = y1 + y2 + y3 + y4 + y5

TeamChooser = vgui.Create( "DFrame" )
TeamChooser:SetPos( (ScrW() / 2) - (size_x / 2), (ScrH() / 2) - (size_y / 2) )
TeamChooser:SetSize( size_x, size_y )
TeamChooser:SetTitle("Pick a team.")
TeamChooser:SetVisible(true)
TeamChooser:SetDraggable(false)
TeamChooser:ShowCloseButton(true)
TeamChooser:MakePopup()

red_button  = vgui.Create( "DButton", TeamChooser )
blu_button  = vgui.Create( "DButton", TeamChooser )
spec_button = vgui.Create( "DButton", TeamChooser )

red_button:SetPos( rx, ry )
red_button:SetSize( rlx, rly )
red_button:SetText( "RED" )
red_button.DoClick = function()
	Msg( "team chosen as RED!

" )
–RunConsoleCommand( String Command [, String argument 1, String argument 2, …] )
–RunConsoleCommand( “atfr_set_team_red”, ply) --, team_choice )
RunConsoleCommand( “atfr_set_team_red” ) --team_choice )
end

blu_button:SetPos( bx, by )
blu_button:SetSize( blx, bly )
blu_button:SetText( "BLU" )
blu_button.DoClick = function()
	Msg( "Button click! team chosen as BLU!

" )
–RunConsoleCommand( String Command [, String argument 1, String argument 2, …] )
RunConsoleCommand( “atfr_set_team_blu” )
end

spec_button:SetPos( sx, sy )
spec_button:SetSize( slx, sly )
spec_button:SetText( "Spec" )
spec_button.DoClick = function()
	Msg( "Button click! team chosen as Spec!

" )
–RunConsoleCommand( String Command [, String argument 1, String argument 2, …] )
RunConsoleCommand( “atfr_set_team_spectate” )
end

--RunConsoleCommand( "atfr_set_team", ply, team_choice )

end

concommand.Add( "atfr_choose_team", choose_team)

[/lua]

compare those to yours and try and find out where you messed up. Sorry that i didn’t comment all your mistakes. Hope this helps.