164 lines
3.7 KiB
Lua
164 lines
3.7 KiB
Lua
|
|
|
|
concommand.Add("b-cheat_setteam", function( ply, cmd, args )
|
|
if !ply or !ply:IsValid() then return end
|
|
|
|
if !args[1] then
|
|
print( "Needs an integer." )
|
|
for index, data in ipairs( TEAMS ) do
|
|
print( index .. " - " .. data.id )
|
|
end
|
|
else
|
|
ply:SetTeam( TEAMS_IDorName( args[1] ) )
|
|
end
|
|
end, function( cmd, args )
|
|
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
|
|
end )
|
|
|
|
TEAMS = {
|
|
[0] = {
|
|
name = "unassigned",
|
|
description = "unassigned",
|
|
factionid = "unassigned",
|
|
id = "UNASSIGNED",
|
|
},
|
|
{
|
|
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",
|
|
},
|
|
}
|
|
|
|
-- "PLASOF" -> Team info
|
|
TEAMS_IDtoData = {
|
|
[TEAMS[0].id] = TEAMS[0],
|
|
[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],
|
|
}
|
|
|
|
-- "mp_plasof" -> Team info
|
|
TEAMS_FIDtoData = {
|
|
[TEAMS[0].factionid] = TEAMS[0],
|
|
[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],
|
|
}
|
|
|
|
-- 3 -> "PLASOF"
|
|
TEAMS_IDs = {
|
|
TEAMS[1].id,
|
|
TEAMS[2].id,
|
|
TEAMS[3].id,
|
|
TEAMS[4].id,
|
|
TEAMS[5].id,
|
|
TEAMS[6].id,
|
|
}
|
|
|
|
-- "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
|
|
|
|
function GM:CreateTeams()
|
|
for index, data in ipairs( TEAMS ) do
|
|
team.SetUp( index, data.name, Color( 0, 0, 255 ) )
|
|
team.SetSpawnPoint( index, {"benny_playerstart_team" .. index} )
|
|
end
|
|
|
|
team.SetSpawnPoint( TEAM_SPECTATOR, "worldspawn" )
|
|
|
|
end
|
|
|
|
function GM:PlayerSelectTeamSpawn( TeamID, ply )
|
|
print( TeamID )
|
|
local SpawnPoints = team.GetSpawnPoints( TeamID )
|
|
PrintTable( SpawnPoints )
|
|
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then print("fail")return end
|
|
|
|
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
|
|
end
|
|
|
|
function GM:PlayerSelectSpawn( ply, transition )
|
|
if ( transition ) then return end
|
|
|
|
if BennyGame:GetType() == BG_GTYPE_MP then
|
|
local ent = self:PlayerSelectTeamSpawn( ply:Team(), ply )
|
|
debug.Trace()
|
|
if IsValid( ent ) then print("win") return ent end
|
|
end
|
|
end
|
|
|
|
function BennyGame:BestAutoJoinTeam()
|
|
local SmallestTeam = BennyGame.TeamsInPlay[math.random( 1, BennyGame.TeamCount )]
|
|
local SmallestPlayers = 1000
|
|
|
|
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
|
|
SmallestPlayers = PlayerCount
|
|
SmallestTeam = RealTeamID
|
|
end
|
|
end
|
|
end
|
|
return SmallestTeam
|
|
end |