More progress on MP

This commit is contained in:
Fesiug 2024-09-16 00:26:04 -04:00
parent 8facb41acf
commit d2a87a52ca
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
5 changed files with 388 additions and 98 deletions

View File

@ -51,11 +51,15 @@ function ENT:Think()
end
end
if amtOnPoint > 0 then
local BlockPoints = false
local RoundActive = BennyGame:GetState() == BG_STATE_ACTIVE
if RoundActive and amtOnPoint > 0 then
-- People on point
if Contested then
-- Point is currently contested
BlockPoints = true -- Block points for this saboteur
else
if self:GetTeamOwned() == 0 and self:GetTeamTaking() != TeamOnPoint then
-- Clearing a neutral point
@ -80,6 +84,17 @@ function ENT:Think()
self:SetCapturePercent( 0 )
self:EmitSound("buttons/blip1.wav", 70, 100, 1)
end
BlockPoints = true -- Block points for this saboteur
for ply, edata in pairs(self.Memory) do
edata.xpcollected = (edata.xpcollected or 0) + (COLLECTED * 200)
local sap = math.floor(edata.xpcollected)
if sap >= 10 then
edata.xpcollected = edata.xpcollected - sap
ply:RewardXP( sap )
end
end
elseif self:GetTeamOwned() == TeamOnPoint then
-- Team that owns the point is on the point
@ -101,15 +116,12 @@ function ENT:Think()
self.LastCaptureTime = CurTime()
end
-- rewards
--for ply, edata in pairs(self.Memory) do
-- edata.xpcollected = (edata.xpcollected or 0) + (COLLECTED * 200)
-- local sap = math.floor(edata.xpcollected)
-- if sap >= 1 then
-- edata.xpcollected = edata.xpcollected - sap
-- ply:RewardXP( sap )
-- end
--end
if RoundActive and !BlockPoints and (self.nextpoints or 0) <= CurTime() and self:GetTeamOwned() > 0 then
-- self:EmitSound("buttons/button10.wav", 70, 100, 1)
self.nextpoints = math.floor( CurTime() + 1 )
BennyGame:AddScoreForTeam( self:GetTeamOwned(), 1 )
end
local per = self:GetCapturePercent()
@ -125,7 +137,6 @@ end
function ENT:Touch( ent )
if ent:IsPlayer() then
--print( ent, CurTime() )
ent:SetTouchedObjective( self )
ent:SetTouchedObjectiveTime( CurTime() )
if !self.Memory[ent] then

View File

@ -5,44 +5,85 @@ BennyGame = BennyGame or {}
BG_GTYPE_CAMPAIGN = 0
BG_GTYPE_MP = 1
local cGametype = CreateConVar("b-gametype", 1, nil, "0 for Campaign, 1 for MP")
local cGamemode = CreateConVar("b-gamemode", 2, nil, "MP:\n0 - TDM\n1 - FFA\n2 - Domination\n3 - CTF\n4 - Bomb\n5 - Hardpoint\n6 - Demolition")
local cGametype = CreateConVar("b-gametype", 1, nil, "0 for Campaign, 1 for MP")
local cGamemode = CreateConVar("b-gamemode", "dom", nil, "")
local cMinplayers = CreateConVar("b-g_minplayers", 2)
local cPregame = CreateConVar("b-g_pregame", 15)
local cPostgame = CreateConVar("b-g_postgame", 15)
local cIntermission = CreateConVar("b-g_intermission", 10)
function BennyGame:GetType()
return cGametype:GetBool() and BG_GTYPE_MP or BG_GTYPE_CAMPAIGN
end
BennyGame.TeamsInPlay = {
[4] = 1,
[3] = 2,
}
BennyGame.TeamToFaction = table.Flip( BennyGame.TeamsInPlay )
BennyGame.TeamCount = table.Count(BennyGame.TeamsInPlay)
BG_GMODE_TDM = 0
BG_GMODE_FFA = 1
BG_GMODE_DOMINATION = 2
BG_GMODE_CTF = 3
BG_GMODE_BOMB = 4
BG_GMODE_HARDPOINT = 5
BG_GMODE_DEMOLITION = 6
GM.TeamBased = BennyGame:GetType() == BG_GTYPE_MP
function BennyGame:GetMode()
return BG_GMODE_TDM
return cGamemode:GetString()
end
hook.Add("Initialize", "Benny_Initialize", function()
-- local mapscript = "benny_maps/" .. game.GetMap() .. "_init.lua"
-- AddCSLuaFile(mapscript)
-- include(mapscript)
end)
BennyGame.TeamsInPlay = {
4,
3,
}
BennyGame.TeamCount = #BennyGame.TeamsInPlay
hook.Add("InitPostEntity", "Benny_InitPostEntity", function()
-- local mapscript = "benny_maps/" .. game.GetMap() .. "_initpostentity.lua"
-- AddCSLuaFile(mapscript)
-- include(mapscript)
end)
BennyGame.Gamemodes = {
["free"] = {
name = "#Gamemode.free.Name",
description = "#Gamemode.free.Description",
},
["tdm"] = {
name = "#Gamemode.tdm.Name",
description = "#Gamemode.tdm.Description",
scorelimit = CreateConVar("b-g_tdm_scorelimit", 75 ),
timelimit = CreateConVar("b-g_tdm_timelimit", 10 ),
},
["ffa"] = {
name = "#Gamemode.ffa.Name",
description = "#Gamemode.ffa.Description",
scorelimit = CreateConVar("b-g_ffa_scorelimit", 30 ),
timelimit = CreateConVar("b-g_ffa_timelimit", 10 ),
},
["snd"] = {
name = "#Gamemode.snd.Name",
description = "#Gamemode.snd.Description",
scorelimit = CreateConVar("b-g_snd_scorelimit", 6 ),
timelimit = CreateConVar("b-g_snd_timelimit", 2.5 ),
},
["ctf"] = {
name = "#Gamemode.ctf.Name",
description = "#Gamemode.ctf.Description",
scorelimit = CreateConVar("b-g_ctf_scorelimit", 3 ),
timelimit = CreateConVar("b-g_ctf_timelimit", 10 ),
},
["dom"] = {
name = "#Gamemode.dom.Name",
description = "#Gamemode.dom.Description",
scorelimit = CreateConVar("b-g_dom_scorelimit", 1000 ),
timelimit = CreateConVar("b-g_dom_timelimit", 10 ),
},
["dem"] = {
name = "#Gamemode.dem.Name",
description = "#Gamemode.dem.Description",
scorelimit = CreateConVar("b-g_dem_scorelimit", 3 ),
timelimit = CreateConVar("b-g_dem_timelimit", 5 ),
},
["hp"] = {
name = "#Gamemode.hp.Name",
description = "#Gamemode.hp.Description",
scorelimit = CreateConVar("b-g_hp_scorelimit", 300 ),
timelimit = CreateConVar("b-g_hp_timelimit", 10 ),
},
}
local thetypes = {
"Float",
@ -104,12 +145,164 @@ hook.Add("InitPostEntity", "Benny_Gamestate_InitPostEntity", function()
BennyGame:Accessor( "RoundStartedAt", "Float", 0 )
BennyGame:Accessor( "PregameStartedAt", "Float", 0 )
BennyGame:Accessor( "RoundFinishedAt", "Float", 0 )
BennyGame:Accessor( "State", "Int", 0 )
BennyGame:Accessor( "Round", "Int", 1 )
BennyGame:Accessor( "SwappedAtRound", "Int", 1 )
BennyGame:Accessor( "State", "Int", 0 )
BennyGame:Accessor( "Round", "Int", 1 )
BennyGame:Accessor( "SwappedAtRound", "Int", 1 )
BennyGame:Accessor( "TimeExtension", "Int", 0 )
BennyGame:Accessor( "Team1_Score", "Int", 0 )
BennyGame:Accessor( "Team2_Score", "Int", 0 )
BennyGame:Accessor( "Team3_Score", "Int", 0 )
BennyGame:Accessor( "Team4_Score", "Int", 0 )
BennyGame:Accessor( "Team5_Score", "Int", 0 )
BennyGame:Accessor( "Team6_Score", "Int", 0 )
BennyGame:Accessor( "TeamsSwapped", "Bool", false )
end)
function BennyGame:GetScoreLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].scorelimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].scorelimit:GetInt()
end
function BennyGame:GetTimeLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].timelimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].timelimit:GetInt() + BennyGame:GetTimeExtension()
end
function BennyGame:GetPregameTime()
return cPregame:GetInt()
end
function BennyGame:GetPostgameTime()
return cPostgame:GetInt()
end
function BennyGame:GetIntermissionTime()
return cIntermission:GetInt()
end
function BennyGame:GetScoreForTeam( teamid )
return BennyGame["GetTeam" .. teamid .. "_Score"]( self )
end
function BennyGame:SetScoreForTeam( teamid, var )
return BennyGame["SetTeam" .. teamid .. "_Score"]( self, var )
end
function BennyGame:AddScoreForTeam( teamid, var )
if Nuke then return end
if BennyGame:GetState() != BG_STATE_ACTIVE then return end
self:SetScoreForTeam( teamid, self:GetScoreForTeam( teamid ) + (var or 1) )
if self:GetScoreForTeam( teamid ) >= BennyGame:GetScoreLimit() then
BennyGame:EndRound( BG_ER_SCORELIMIT, teamid )
end
end
BG_ER_TIMELIMIT = 0
BG_ER_SCORELIMIT = 1
BG_ER_NUKE = 2
function BennyGame:StartRound()
PrintMessage(HUD_PRINTCENTER, "Round start!")
BennyGame:SetState( BG_STATE_ACTIVE )
BennyGame:SetRoundStartedAt( CurTime() )
--game.CleanUpMap()
--for _, ply in player.Iterator() do
-- ply:Spawn()
--end
end
function BennyGame:EndRound( reason, forceteam )
local winningteam = forceteam
BennyGame:SetState( BG_STATE_POST )
BennyGame:SetRoundFinishedAt( CurTime() )
if !winningteam then
-- who has the most score
local HighestScore, HighestTeam = 0, 0
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
local ThisScore = BennyGame:GetScoreForTeam( RealTeamID )
if HighestScore < ThisScore then
HighestScore = ThisScore
HighestTeam = RealTeamID
print("highest score to do it to em", HighestScore, TEAMS[HighestTeam].name)
winningteam = HighestTeam
end
end
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
local ThisScore = BennyGame:GetScoreForTeam( RealTeamID )
if RealTeamID == HighestTeam then continue end
if HighestScore < ThisScore then
print("clearly there's been a failure", RealTeamID, ThisScore, HighestTeam, HighestScore)
elseif HighestScore == ThisScore then
print("this looks like a tie", RealTeamID, HighestTeam)
winningteam = 0
break
end
end
end
local TheFull = "["
TheFull = TheFull .. ((reason==0 and "TIME END!] ") or (reason==1 and "SCORE END!] ") or ("MISSING END!] "))
if winningteam == 0 then
TheFull = "It's a tie! "
else
TheFull = TheFull .. l8(TEAMS[winningteam].name) .. " wins! "
end
TheFull = TheFull .. cPostgame:GetInt() .. "s until the next round."
PrintMessage(HUD_PRINTCENTER, TheFull)
local roundtime = CurTime() - BennyGame:GetRoundStartedAt()
print( "That round lasted " .. math.ceil(roundtime) .. " seconds." )
end
concommand.Add("b-cheat_scoreset", function( ply, cmd, args )
if !args[1] then
print( "Needs a team ID." )
for index, data in ipairs( TEAMS ) do
print( index .. " - " .. data.id )
end
elseif !args[2] then
print( "Needs an integer." )
else
BennyGame:SetScoreForTeam( TEAMS_IDorName( args[1] ), args[2] )
print( "Team " .. args[1] .. " score now " .. BennyGame:GetScoreForTeam( TEAMS_IDorName( args[1] ) ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_scoreadd", function( ply, cmd, args )
if !args[1] then
print( "Needs a team ID." )
for index, data in ipairs( TEAMS ) do
print( index .. " - " .. data.id )
end
else
BennyGame:AddScoreForTeam( TEAMS_IDorName( args[1] ), args[2] )
print( "Team " .. args[1] .. " score now " .. BennyGame:GetScoreForTeam( TEAMS_IDorName( args[1] ) ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_setstate", function( ply, cmd, args )
if !args[1] then
print( "Needs an integer 0 waiting for palyers 1 pre 2 active 3 post" )
else
BennyGame:SetState( args[1] )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
hook.Add("Think", "Benny_Gamestate_Think", function()
if SERVER then
local World = Entity(0)
@ -127,19 +320,35 @@ hook.Add("Think", "Benny_Gamestate_Think", function()
count = count + 1
end
if count >= cMinplayers:GetInt() then
roundstate = BG_STATE_PRE
BennyGame:SetState( roundstate )
BennyGame:SetPregameStartedAt( CurTime() )
PrintMessage(HUD_PRINTCENTER, "Pregame. " .. cPregame:GetInt() .. "s until the round starts")
end
end
if roundstate == BG_STATE_PRE then
-- Pregame
if BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime() <= CurTime() then
BennyGame:StartRound()
end
elseif roundstate == BG_STATE_POST then
-- Postgame
if BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() <= CurTime() then
BennyGame:SetState( BG_STATE_WAITINGFORPLAYERS )
end
elseif roundstate == BG_STATE_ACTIVE then
-- Active round
if (BennyGame:GetRoundStartedAt()) <= CurTime() then
if (BennyGame:GetRoundStartedAt()+BennyGame:GetTimeLimit()) <= CurTime() then
-- Round time expired
BennyGame:EndRound( BG_ER_TIMELIMIT )
end
end

View File

@ -236,9 +236,9 @@ local fmlookup = {
}
local function QuickDrawBar( BARWIDE, BARTALL, faction_index, way )
--local faction_index = "mp_cia"
local faction_info = FACTIONS[faction_index]
local function QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, way )
local faction_info = FACTIONS[ TEAMS[RealTeamID].factionid ]
hCol( faction_info.COLOR_DARK )
hRect( 0, 0, BARWIDE, BARTALL )
hCol( faction_info.COLOR_MAIN )
@ -246,7 +246,10 @@ local function QuickDrawBar( BARWIDE, BARTALL, faction_index, way )
local count = 6
local perc = 6/count--0.23
local Score_Current = BennyGame:GetScoreForTeam( RealTeamID )
local Score_ToWin = BennyGame:GetScoreLimit()
local perc = Score_Current/Score_ToWin
local width = math.ceil( (BARWIDE-6)*perc )
if way then
hRect( BARWIDE - 3 - width, 3, width, BARTALL-6 )
@ -268,9 +271,15 @@ local function QuickDrawBar( BARWIDE, BARTALL, faction_index, way )
if way then
local x, y = hXY( BARWIDE - 5, 0 )
qt( faction_info.CHARNAME, "HUD_36", x, y, faction_info.COLOR_DARK, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_MAIN )
local x, y = hXY( BARWIDE, BARTALL )
qt( Score_Current .. " / " .. Score_ToWin, "HUD_24", x, y, faction_info.COLOR_MAIN, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_DARK )
else
local x, y = hXY( 5, 0 )
qt( faction_info.CHARNAME, "HUD_36", x, y, faction_info.COLOR_DARK, nil, nil, faction_info.COLOR_MAIN )
local x, y = hXY( 0, BARTALL )
qt( Score_Current .. " / " .. Score_ToWin, "HUD_24", x, y, faction_info.COLOR_MAIN, nil, nil, faction_info.COLOR_DARK )
end
-- Players alive
@ -477,12 +486,13 @@ function GM:HUDPaint()
--hRect( 0, 0, 1, 60 )
-- Score
for i=1, BennyGame.TeamCount do
local o = i-1
local lor =
S_Push( i%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, TEAMS[BennyGame.TeamToFaction[i]].factionid )
local count = 1
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
local o = count-1
S_Push( count%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, count%2==0 )
S_Pop()
count = count + 1
end
-- Timer
@ -493,9 +503,18 @@ function GM:HUDPaint()
hCol( COLOR_MAIN )
hORect( 2, 2, DISPLAYWIDE-4, DISPLAYTALL-4, 1 )
local d1, d2
local stupidtime = CurTime()
if BennyGame:GetState() == BG_STATE_ACTIVE then
local tt = string.FormattedTime( math.max( ROUNDEND-CurTime(), 0 ) )
stupidtime = BennyGame:GetRoundStartedAt() + BennyGame:GetTimeLimit() - CurTime()
elseif BennyGame:GetState() == BG_STATE_PRE then
stupidtime = BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime() - CurTime()
elseif BennyGame:GetState() == BG_STATE_POST then
stupidtime = BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() - CurTime()
end
if BennyGame:GetState() != BG_STATE_WAITINGFORPLAYERS then
local d1, d2
local tt = string.FormattedTime( math.max( stupidtime, 0 ) )
if tt.m > 0 then
d1 = string.format( "%01i:%02i", tt.m, tt.s )
d2 = false--tt.s
@ -506,9 +525,7 @@ function GM:HUDPaint()
d1 = string.format( "%02i", tt.s )
d2 = string.format( ".%02i", tt.ms )
end
end
if d1 then
surface.SetFont("HUD_48")
local twid = surface.GetTextSize(d1)
if d2 then
@ -525,6 +542,19 @@ function GM:HUDPaint()
end
end
local x, y = hXY( DISPLAYWIDE/2, -16 )
local TITLE
if BennyGame:GetState() == BG_STATE_PRE then
TITLE = "PREGAME"
elseif BennyGame:GetState() == BG_STATE_POST then
TITLE = "POSTGAME"
elseif BennyGame:GetState() == BG_STATE_WAITINGFORPLAYERS then
TITLE = "WAITING FOR PLAYERS"
end
if TITLE then
qt( TITLE, "HUD_16", x, y, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
end
if false then
local myteamwins = 2
local enemywins = 3

View File

@ -6,6 +6,34 @@ GM.Website = "N/A"
BENNY = {}
function BENNY.SimpleAutoComplete( cmd, args, ... ) -- just stole it from the wiki
local possibleArgs = { ... }
local autoCompletes = {}
--TODO: Handle "test test" "test test" type arguments
args = args:upper()
local arg = string.Split( args:TrimLeft(), " " )
local lastItem = nil
for i, str in pairs( arg ) do
if ( str == "" && ( lastItem && lastItem == "" ) ) then table.remove( arg, i ) end
lastItem = str
end -- Remove empty entries. Can this be done better?
local numArgs = #arg
local lastArg = table.remove( arg, numArgs )
local prevArgs = table.concat( arg, " " )
if ( #prevArgs > 0 ) then prevArgs = " " .. prevArgs end
local possibilities = possibleArgs[ numArgs ] or { lastArg }
for _, acStr in pairs( possibilities ) do
if ( !acStr:StartsWith( lastArg ) ) then continue end
table.insert( autoCompletes, cmd .. prevArgs .. " " .. acStr )
end
return autoCompletes
end
local AC, IN = AddCSLuaFile, include
local CL = SERVER and AddCSLuaFile or include

View File

@ -9,9 +9,11 @@ concommand.Add("b-cheat_setteam", function( ply, cmd, args )
print( index .. " - " .. data.id )
end
else
ply:SetTeam( args[1] )
ply:SetTeam( TEAMS_IDorName( args[1] ) )
end
end)
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
TEAMS = {
[0] = {
@ -64,7 +66,9 @@ TEAMS = {
},
}
TEAMS_IDtoTeam = {
-- "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],
@ -73,7 +77,8 @@ TEAMS_IDtoTeam = {
[TEAMS[6].id] = TEAMS[6],
}
TEAMS_FIDtoTeam = {
-- "mp_plasof" -> Team info
TEAMS_FIDtoData = {
[TEAMS[0].factionid] = TEAMS[0],
[TEAMS[1].factionid] = TEAMS[1],
[TEAMS[2].factionid] = TEAMS[2],
@ -83,68 +88,75 @@ TEAMS_FIDtoTeam = {
[TEAMS[6].factionid] = TEAMS[6],
}
-- Team 1 is CIA, Team 2 is HALO for now
TEAMS_Placeholder = {
[1] = "benny_playerstart_team1",
[2] = "benny_playerstart_team2",
[3] = "benny_playerstart_team3",
[4] = "benny_playerstart_team4",
[5] = "benny_playerstart_team5",
[6] = "benny_playerstart_team6",
-- 3 -> "PLASOF"
TEAMS_IDs = {
TEAMS[1].id,
TEAMS[2].id,
TEAMS[3].id,
TEAMS[4].id,
TEAMS[5].id,
TEAMS[6].id,
}
TEAMS_Current = {
[1] = 1,
[2] = 2,
}
-- "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 )
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 )
if IsValid( ent ) then return ent end
debug.Trace()
if IsValid( ent ) then print("win") return ent end
end
end
function GM:PlayerSelectTeamSpawn( TeamID, ply )
local SpawnPoints = team.GetSpawnPoints( TeamID )
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then 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 BennyGame:BestAutoJoinTeam()
local SmallestTeam = BennyGame.TeamToFaction[math.random( 1, BennyGame.TeamCount )]
local SmallestTeam = BennyGame.TeamsInPlay[math.random( 1, BennyGame.TeamCount )]
local SmallestPlayers = 1000
for id, TeamInPlayID in pairs( BennyGame.TeamsInPlay ) do
if ( id != TEAM_SPECTATOR && id != TEAM_UNASSIGNED && id != TEAM_CONNECTING ) then
local PlayerCount = team.NumPlayers( id )
if PlayerCount < SmallestPlayers or (PlayerCount == SmallestPlayers and id < SmallestTeam ) then
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 = id
SmallestTeam = RealTeamID
end
end
end