--bounty mode main script --by Braindawg --With a lot of help from royal local inWave = false local playerCount = 0 local maxRed = 6 local maxLowPlayer = 12 local maxHighPlayer = 18 local bluWin = ents.FindByClass("game_round_win") local gameRules = ents.FindByClass ("tf_gamerules") local wavebarResource = ents.FindByClass("tf_objective_resource") -- local announcer = ents.FindByName("announcer_relay") --had an idea for having the wave force start but probably gonna do things differently function OnWaveInit(wave) CheckPlayerCount() GetImportantSpots() end function OnWaveStart(wave) inWave = TickCount() CheckPlayerCount() player:AddCallback(ON_DEATH, function(ent) if player.m_iTeam == 3 then for _, player in pairs(chosenPlayers) do if player.m_iTeam == 2 then player:AddCurrency(25) end end end end) end --this function also handles the necesary ON_DEATH callback for adding money to RED function OnPlayerConnected(player) if not player:IsRealPlayer() then return end playerCount = playerCount + 1 print(playerCount) if playerCount >= ( maxLowPlayer / 2 ) then CheckPlayerCount() end --testing player:AddCallback(ON_SPAWN, function(ent) playerCount = playerCount + 1 print(playerCount) if playerCount >= ( maxLowPlayer / 2 ) then CheckPlayerCount() end end) end function OnPlayerDisconnected(player) if not player:IsRealPlayer() then return end playerCount = playerCount - 1 if playerCount < maxLowPlayer then CheckPlayerCount() end end --warmup and hunter selection function CheckPlayerCount() if not(inWave and chosenPlayers) then if playerCount < maxLowPlayer then util.PrintToChatAll(playerCount.." Players connected! "..(maxLowPlayer - playerCount).." more to begin..." ) -- announcer:AcceptInput( "CancelPending" ) elseif playerCount >= maxLowPlayer and playerCount < maxHighPlayer then util.PrintToChatAll("Enough players connected! Selecting hunters...") -- announcer:AcceptInput( "Trigger" ) local allPlayers = ents.GetAllPlayers() local chosenPlayers = {} for _, player in pairs(allPlayers) do if not player.m_iTeam == 3 and player:IsRealPlayer() then -- only switch BLU players goto continue end local chosen = math.random(1, #allPlayers / 2) if chosen then table.insert(chosenPlayers, player) if #chosenPlayers >= 6 then break end end ::continue:: end for _, player in pairs(chosenPlayers) do if player:IsRealPlayer() then player:AcceptInput( "$SetProp$m_iTeamNum", "2" ) player:AcceptInput( "$AddCurrency", "200" ) player:ForceRespawn() end end end end end --hijack the bomb arrow positions for warmup spawn points and capture zones, currently non functional function GetImportantSpots() local allPropsTable = ents.FindAllByClass("prop_dynamic") local holograms = ents.FindByClass("prop_dynamic") local points = {} -- print(holograms) for _, holograms in pairs(allPropsTable) do if holograms.m_ModelName == "models/props_mvm/robot_hologram.mdl" then local points = holograms:GetAbsOrigin() print(holograms) print(points) if not inWave then local dmspawn = ents.FindByName("dmspawn") dmspawn:Spawn() dmspawn:SetAbsOrigin(points) end end end end -- adjusts respawn times depending on how many players are connected -- function SetPlayerMode() -- if playerCount == maxHighPlayer then -- -- end -- end --stolen from stackoverflow function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end