2024-09-15 15:41:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
concommand.Add("b-cheat_setteam", function( ply, cmd, args )
|
|
|
|
if !ply or !ply:IsValid() then return end
|
|
|
|
|
2024-09-15 18:18:31 -04:00
|
|
|
if !args[1] then
|
|
|
|
print( "Needs an integer." )
|
|
|
|
for index, data in ipairs( TEAMS ) do
|
|
|
|
print( index .. " - " .. data.id )
|
|
|
|
end
|
|
|
|
else
|
2024-09-16 21:15:11 -04:00
|
|
|
ply:SetTeam( TEAMS_IDorName( tonumber(args[1]) or args[1] ) )
|
2024-09-15 18:18:31 -04:00
|
|
|
end
|
2024-09-16 00:26:04 -04:00
|
|
|
end, function( cmd, args )
|
|
|
|
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
|
|
|
|
end )
|
2024-09-15 15:41:34 -04:00
|
|
|
|
|
|
|
TEAMS = {
|
2024-09-15 18:18:31 -04:00
|
|
|
[0] = {
|
|
|
|
name = "unassigned",
|
|
|
|
description = "unassigned",
|
|
|
|
factionid = "unassigned",
|
|
|
|
id = "UNASSIGNED",
|
|
|
|
},
|
2024-09-15 15:41:34 -04:00
|
|
|
{
|
|
|
|
name = "#Team.cia.Name",
|
|
|
|
description = "#Team.cia.Description",
|
|
|
|
factionid = "mp_cia",
|
|
|
|
id = "CIA",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "#Team.halo.Name",
|
|
|
|
description = "#Team.halo.Description",
|
|
|
|
factionid = "mp_halo",
|
|
|
|
id = "HALO",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "#Team.plasof.Name",
|
|
|
|
description = "#Team.plasof.Description",
|
|
|
|
factionid = "mp_plasof",
|
|
|
|
id = "PLASOF",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "#Team.arng.Name",
|
|
|
|
description = "#Team.arng.Description",
|
|
|
|
factionid = "mp_arng",
|
|
|
|
id = "ARNG",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "#Team.militia.Name",
|
|
|
|
description = "#Team.militia.Description",
|
|
|
|
factionid = "mp_militia",
|
|
|
|
id = "MILITIA",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "#Team.viper.Name",
|
|
|
|
description = "#Team.viper.Description",
|
|
|
|
factionid = "mp_viper",
|
|
|
|
id = "VIPER",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "campaign",
|
|
|
|
description = "internal campaign faction",
|
|
|
|
factionid = "campaign",
|
|
|
|
id = "CAMPAIGN",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
-- "PLASOF" -> Team info
|
|
|
|
TEAMS_IDtoData = {
|
|
|
|
[TEAMS[0].id] = TEAMS[0],
|
2024-09-15 15:41:34 -04:00
|
|
|
[TEAMS[1].id] = TEAMS[1],
|
|
|
|
[TEAMS[2].id] = TEAMS[2],
|
|
|
|
[TEAMS[3].id] = TEAMS[3],
|
|
|
|
[TEAMS[4].id] = TEAMS[4],
|
|
|
|
[TEAMS[5].id] = TEAMS[5],
|
|
|
|
[TEAMS[6].id] = TEAMS[6],
|
|
|
|
}
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
-- "mp_plasof" -> Team info
|
|
|
|
TEAMS_FIDtoData = {
|
2024-09-15 18:18:31 -04:00
|
|
|
[TEAMS[0].factionid] = TEAMS[0],
|
2024-09-15 15:41:34 -04:00
|
|
|
[TEAMS[1].factionid] = TEAMS[1],
|
|
|
|
[TEAMS[2].factionid] = TEAMS[2],
|
|
|
|
[TEAMS[3].factionid] = TEAMS[3],
|
|
|
|
[TEAMS[4].factionid] = TEAMS[4],
|
|
|
|
[TEAMS[5].factionid] = TEAMS[5],
|
|
|
|
[TEAMS[6].factionid] = TEAMS[6],
|
|
|
|
}
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
-- 3 -> "PLASOF"
|
|
|
|
TEAMS_IDs = {
|
|
|
|
TEAMS[1].id,
|
|
|
|
TEAMS[2].id,
|
|
|
|
TEAMS[3].id,
|
|
|
|
TEAMS[4].id,
|
|
|
|
TEAMS[5].id,
|
|
|
|
TEAMS[6].id,
|
2024-09-15 15:41:34 -04:00
|
|
|
}
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
-- "PLASOF" -> 3
|
|
|
|
TEAM_IDs2 = table.Flip( TEAMS_IDs )
|
|
|
|
|
|
|
|
function TEAMS_IDorName( id )
|
|
|
|
if isnumber( id ) then
|
|
|
|
return id
|
|
|
|
else
|
|
|
|
return TEAM_IDs2[string.upper(id)]
|
|
|
|
end
|
|
|
|
end
|
2024-09-15 15:41:34 -04:00
|
|
|
|
|
|
|
function GM:CreateTeams()
|
|
|
|
for index, data in ipairs( TEAMS ) do
|
|
|
|
team.SetUp( index, data.name, Color( 0, 0, 255 ) )
|
2024-09-16 00:26:04 -04:00
|
|
|
team.SetSpawnPoint( index, {"benny_playerstart_team" .. index} )
|
2024-09-15 15:41:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
team.SetSpawnPoint( TEAM_SPECTATOR, "worldspawn" )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function GM:PlayerSelectTeamSpawn( TeamID, ply )
|
|
|
|
local SpawnPoints = team.GetSpawnPoints( TeamID )
|
2024-09-16 16:57:20 -04:00
|
|
|
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then return end
|
2024-09-15 15:41:34 -04:00
|
|
|
|
|
|
|
local ChosenSpawnPoint = nil
|
|
|
|
|
|
|
|
for i = 0, 6 do
|
|
|
|
ChosenSpawnPoint = table.Random( SpawnPoints )
|
|
|
|
if ( hook.Call( "IsSpawnpointSuitable", GAMEMODE, ply, ChosenSpawnPoint, i == 6 ) ) then
|
|
|
|
return ChosenSpawnPoint
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return ChosenSpawnPoint
|
2024-09-15 18:18:31 -04:00
|
|
|
end
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
function GM:PlayerSelectSpawn( ply, transition )
|
|
|
|
if ( transition ) then return end
|
|
|
|
|
|
|
|
if BennyGame:GetType() == BG_GTYPE_MP then
|
|
|
|
local ent = self:PlayerSelectTeamSpawn( ply:Team(), ply )
|
2024-09-16 16:57:20 -04:00
|
|
|
if IsValid( ent ) then return ent end
|
2024-09-16 00:26:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-15 18:18:31 -04:00
|
|
|
function BennyGame:BestAutoJoinTeam()
|
2024-09-16 00:26:04 -04:00
|
|
|
local SmallestTeam = BennyGame.TeamsInPlay[math.random( 1, BennyGame.TeamCount )]
|
2024-09-15 18:18:31 -04:00
|
|
|
local SmallestPlayers = 1000
|
|
|
|
|
2024-09-16 00:26:04 -04:00
|
|
|
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
|
|
|
|
if ( RealTeamID != TEAM_SPECTATOR && RealTeamID != TEAM_UNASSIGNED && RealTeamID != TEAM_CONNECTING ) then
|
|
|
|
local PlayerCount = team.NumPlayers( RealTeamID )
|
|
|
|
if PlayerCount < SmallestPlayers or (PlayerCount == SmallestPlayers and RealTeamID < SmallestTeam ) then
|
2024-09-15 18:18:31 -04:00
|
|
|
SmallestPlayers = PlayerCount
|
2024-09-16 00:26:04 -04:00
|
|
|
SmallestTeam = RealTeamID
|
2024-09-15 18:18:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return SmallestTeam
|
2024-09-15 15:41:34 -04:00
|
|
|
end
|