0 Members and 1 Guest are viewing this topic.
ballcarrier = 0EntTeam = {}TEAMCOLOR = {}TEAMCOLOR[1] = "50 150 255"TEAMCOLOR[2] = "255 200 0"TEAMCOLOR[3] = "50 255 150"TEAMCOLOR[4] = "255 100 100"function GAMEMODE:ShowHelp(ply)umsg.Start( "showhelp", ply)umsg.End()endfunction GAMEMODE:ShowTeam(ply)umsg.Start( "showteam", ply)umsg.End()endfunction GAMEMODE:ShowSpare1(ply) if !ply:IsAdmin() and !ply:IsSuperAdmin() then return end umsg.Start( "showadminpanel",ply) umsg.End()endfunction GAMEMODE:ShowSpare2(ply) if DM_MODE == false then ply:PrintMessage(4,"You can only use that menu during deathmatch!") return end umsg.Start("buymenu",ply) umsg.End()endfunction PickTeam(ply, command, args) if !args[1] or !ply.changeteams then return false end if EVEN_TEAMS then if NUM_TEAMS == 4 then if tonumber(args[1]) == 1 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_BLUE) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 2 then if team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_YELLOW) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 3 then if team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_GREEN) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 4 then if team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_RED) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end end elseif NUM_TEAMS == 3 then if tonumber(args[1]) == 1 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_BLUE) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 2 then if team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_YELLOW) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 3 then if team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_GREEN) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end end elseif NUM_TEAMS == 2 then if tonumber(args[1]) == 1 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_BLUE) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end elseif tonumber(args[1]) == 2 then if team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_YELLOW) ply.spawn = nil ply:Kill() ply.changeteams = false else ply:PrintMessage(4, "Teams would be too uneven if you switched.") end end end else ply:SetTeam(tonumber(args[1])) end for i,v in ipairs(TEAMCOLOR) do if ply:Team() == i then ply:Fire("color",v,0) ply.changeteams = false end endendconcommand.Add("changeteam",PickTeam)function RefillTeams() --admin changed number of teams for index,ply in pairs(player.GetAll()) do ply:SetTeam(0) ply.spawn = nil if ply:Alive() then ply:Kill() end if NUM_TEAMS == 4 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_YELLOW) elseif team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_GREEN) elseif team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_RED) end elseif NUM_TEAMS == 3 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) then ply:SetTeam(TEAM_YELLOW) elseif team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_GREEN) end elseif NUM_TEAMS == 2 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_YELLOW) end end for i,v in ipairs(TEAMCOLOR) do if ply:Team() == i then ply:Fire("color",v,0) end end endendfunction SendMoney(ply) umsg.Start("getmoney",ply) umsg.Long(ply.money) umsg.End()endfunction GAMEMODE:PlayerInitialSpawn(ply) if CHOOSETEAM == false then --this looks very crappy to me but i am lazy so i am gonna leave it if NUM_TEAMS == 4 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_YELLOW) elseif team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_RED) then ply:SetTeam(TEAM_GREEN) elseif team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_GREEN) and team.NumPlayers(TEAM_RED) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_RED) end elseif NUM_TEAMS == 3 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_GREEN) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) and team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_GREEN) then ply:SetTeam(TEAM_YELLOW) elseif team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_YELLOW) and team.NumPlayers(TEAM_GREEN) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_GREEN) end elseif NUM_TEAMS == 2 then if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_YELLOW) then ply:SetTeam(TEAM_BLUE) elseif team.NumPlayers(TEAM_YELLOW) <= team.NumPlayers(TEAM_BLUE) then ply:SetTeam(TEAM_YELLOW) end end for i,v in ipairs(TEAMCOLOR) do if ply:Team() == i then ply:Fire("color",v,0) end end else ply:Spectate() umsg.Start( "joinmenu", ply) umsg.End() end if DM_MODE then umsg.Start("changetodm", ply) umsg.End() else umsg.Start("changetobuild", ply) umsg.End() end ply.money = STARTING_MONEY ply.changeteams = true SendMoney(ply)end