----------------------------
-- CakeScript (March 29, 2008)
-- by LuaBanana
--
-- Alpha Version
-- team_data.lua
----------------------------

Teams = {}

-- ALWAYS have this.

function CAKE.AddTeam(name, color, defaultmodel, defaultmodelpath, partialmodel, weapons, ammo, flagkey, doorgroup, canbroadcast, public, salary, business, radiogroup, id)

	local n = id or (#Teams + 1)
	
	Teams[n] = {};
	Teams[n]["name"] = name or "Noname"; -- Team Name
	Teams[n]["color"] = color or Color(0, 255, 0, 255); -- Team Color, will show up when someone is talking in OOC/when you look at them.
	Teams[n]["DefaultModel"] = defaultmodel or false; -- Do they have a default model that they get when they spawn?
	Teams[n]["DefaultModelPath"] = defaultmodelpath or ""; -- What's the path to their default model?
	Teams[n]["PartialModel"] = partialmodel or false; -- Is their model path PARTIAL?
	Teams[n]["Weapons"] = weapons or {}; -- What weapons do they spawn with?
	Teams[n]["Ammo"] = ammo or {}; -- What ammo do they spawn with?
	Teams[n]["FlagKey"] = flagkey or "nokey"; -- What flag key is used when using rp_flag?
	Teams[n]["DoorGroup"] = doorgroup or 0; -- What doors can they open?
	Teams[n]["CanBroadcast"] = canbroadcast or false; -- Can use /bc?
	Teams[n]["public"] = public or false;
	Teams[n]["salary"] = salary or 25;
	Teams[n]["business"] = business or false;
	Teams[n]["radiogroup"] = radiogroup or {};

	for k, v in pairs(player.GetAll()) do
	
		CAKE.InitTeams(v);
		
	end
	
end

function CAKE.InitTeams(ply)

	for k, v in pairs(Teams) do
	
		team.SetUp(k, v["name"], v["color"]);
		
		-- Send the team to client
		umsg.Start("setupteam", ply);
		
			umsg.Long(k);
			umsg.String(v["name"]);
			umsg.Long(v["color"].r);
			umsg.Long(v["color"].g);
			umsg.Long(v["color"].b);
			umsg.Long(v["color"].a);
			umsg.Bool(v["public"]);
			umsg.Long(v["salary"]);
			umsg.String(v["FlagKey"]);
			umsg.Bool(v["business"]);
			
		umsg.End();
	end
	
end

-- Always have this
CAKE.AddTeam("Citizen", Color( 0, 255, 0, 255 ), false, "", false, {}, {}, "citizen", {}, false, true, 10, true, {});