Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ww2 = ww2 or {}
- local round = round or {}
- local flag = flag or {}
- util.AddNetworkString("ww2_upwinner")
- round.cfg = {}
- round.cfg.preparetime = 15
- round.cfg.godtime = 10
- round.cfg.respawntime = 15
- round.cfg.endingtime = 15
- round.cfg.defendtime = 9999
- round.winner = 0
- function round.Setup()
- roundstared = false
- preparing = false
- end
- function round.SpawnPlayers()
- for k, ply in pairs(player.GetAll()) do
- ply:SetFrags(0)
- ply:SetDeaths(0)
- ply.Killed = 0
- ply:StripWeapons()
- if ply:GetTeam() == 1 then
- ply:SetTeam(ply:GetTeam())
- ply:SetupSpawn()
- ply:GodEnable()
- ply:SetNoCollideWithTeammates(true)
- ply:SetPos(table.Random(ww2.getTeamSpawnes(ply:GetTeam())))
- ply:SetFreezed(true)
- elseif ply:GetTeam() == 2 then
- ply:SetTeam(ply:GetTeam())
- ply:SetupSpawn()
- ply:GodEnable()
- ply:SetNoCollideWithTeammates(true)
- ply:SetPos(table.Random(ww2.getTeamSpawnes(ply:GetTeam())))
- ply:SetFreezed(true)
- end
- end
- end
- function round.DisablePlayersGod()
- for k, v in pairs(ww2.AlivePlayers()) do
- if v:HasGodMode() then
- v:GodDisable()
- v:SetNoCollideWithTeammates(false)
- end
- end
- end
- function round.ChangePlayerTeam()
- if #ww2.GetSovietPlayers() > #ww2.GetNaziPlayers() then
- local ply = table.Random(ww2.GetSovietPlayers())
- ply:SetWTeam(1)
- ply:SetWClass("newbie_rus", 1)
- elseif #ww2.GetNaziPlayers() > #ww2.GetSovietPlayers() then
- local ply = table.Random(ww2.GetNaziPlayers())
- ply:SetWTeam(2)
- ply:SetWClass("newbie_rus", 2)
- end
- end
- function round.DoBalanceTeam()
- if #ww2.GetSovietPlayers() > #ww2.GetNaziPlayers() then
- for i = 1, #ww2.GetSovietPlayers() - #ww2.GetNaziPlayers() do
- round.ChangePlayerTeam()
- end
- elseif #ww2.GetNaziPlayers() > #ww2.GetSovietPlayers() then
- for i = 1, #ww2.GetNaziPlayers() - #ww2.GetSovietPlayers() do
- round.ChangePlayerTeam()
- end
- end
- end
- function round.UnFreezeAll()
- for k, v in pairs(ww2.AlivePlayers()) do
- v:SetFreezed(false)
- end
- end
- function round.Begin() -- инициализация раунда
- -- ресет тикетов
- ww2.ResetTickets()
- ww2.UpdateTickets()
- -- ресет спавнов
- ww2.ClearSpawnPos()
- ww2.CreateSpawnes()
- -- ресет флагов
- flag.ClearOldFlags()
- flag.OnRoundStart()
- -- обновляем инфу о флагах у игроков
- for k, v in pairs(player.GetAll()) do
- ww2.LoadFlags(v)
- end
- -- закрываем все клиентские меню у игроков
- ww2.CloseAllMenues()
- -- очищаем регдоллы по карте
- ww2.CleanUpRagdolls()
- -- ресетаем XP
- xp.ResetPerming()
- ----------------------------------
- timer.Remove("UpdatePrepTime")
- timer.Remove("WW2_round_prepare")
- timer.Remove("WW2_round_goddisable")
- timer.Remove("WW2_ticket")
- timer.Remove("UpdateRoundTime")
- timer.Remove("ww2_restartGAME")
- timer.Remove('UpdateRTime')
- ----------------------------------
- -- общая чистка карты (декали и т.д.)
- game.CleanUpMap()
- roundstared = false
- preparing = true
- -- VAR
- SetGlobalString("DefeatType", "")
- SetGlobalInt("DUR_TIME", 0)
- SetGlobalBool("RoundStarted", false)
- --
- -- ресетаем настройки раунда, балансируем команды и спавним игроков
- round.ShowupEnd(false)
- round.SetWinner(0)
- round.DoBalanceTeam()
- round.SpawnPlayers()
- -- хз чё это, но если есть, значит так нужно.
- timer.Create("UpdatePrepTime", 0.1, round.cfg.preparetime * 10, function()
- SetGlobalInt("PREP_TIME", timer.TimeLeft("WW2_round_prepare"))
- end)
- -- функция пушдефенда, работает только в пушдефенде
- onRoundStart()
- -- старт раунда после подготовки
- timer.Create("WW2_round_prepare", round.cfg.preparetime, 1, function()
- round.UnFreezeAll()
- roundstared = true
- preparing = false
- if gm.GetCurGMIndex() == "capture" then
- ww2.InitTicketSystem()
- elseif gm.GetCurGMIndex() == "defende" then
- ww2.InitTicketDefend()
- end
- SetGlobalBool("RoundStarted", roundstared)
- timer.Create("WW2_round_goddisable", round.cfg.godtime, 1, function()
- round.DisablePlayersGod()
- end)
- if gm.GetCurGMIndex() == 'capture' then
- timer.Create("UpdateRoundTime", 1, 0, function()
- SetGlobalInt("DUR_TIME", GetGlobalInt("DUR_TIME") + 1)
- end)
- elseif gm.GetCurGMIndex() == 'defende' then
- timer.Create("UpdateRoundTime", round.cfg.defendtime, 1, function()
- round.SetWinType('defend')
- round.End('pushed')
- end)
- timer.Create("UpdateRTime", 0.1, 0, function()
- SetGlobalInt("DUR_TIME", timer.TimeLeft("UpdateRoundTime"))
- end)
- end
- end)
- end
- function round.SetWinner(team)
- round.winner = team
- end
- function round.GetWinner()
- return round.winner
- end
- function round.UpdateWinner()
- net.Start("ww2_upwinner")
- net.WriteInt(round.GetWinner(), 5)
- net.Broadcast()
- end
- function round.ShowupEnd(bShow)
- SetGlobalBool("Ending", bShow)
- end
- function round.SetWinType(type)
- SetGlobalString("DefeatType", tostring(type))
- end
- function round.End(reasontype)
- SetGlobalString("ReasonType", reasontype)
- ww2.CloseAllMenues() -- закрываем все менюшкии
- if reasontype == "tickets" then -- если раунд закончился по тикетам
- ww2.SetSpectatorsAll()
- ww2.FreezeAll()
- xp.permingXP()
- if ww2.GetTickets(1) > ww2.GetTickets(2) then
- SetGlobalBool("Ending", true)
- round.SetWinner(1)
- round.ShowupEnd(true)
- timer.Remove("WW2_ticket")
- timer.Stop("UpdateRoundTime")
- ww2.ResetTickets()
- timer.Create("ww2_restartGAME", round.cfg.endingtime, 1, function()
- round.Begin()
- ww2.UnFreezeAll()
- xp.ResetPerming()
- end)
- timer.Create("UpdateEndTime", 0.1, round.cfg.endingtime * 10, function()
- SetGlobalInt("END_TIME", timer.TimeLeft("ww2_restartGAME"))
- end)
- round.UpdateWinner()
- elseif ww2.GetTickets(2) > ww2.GetTickets(1) then
- SetGlobalBool("Ending", true)
- round.SetWinner(2)
- round.ShowupEnd(true)
- timer.Remove("WW2_ticket")
- timer.Stop("UpdateRoundTime")
- ww2.ResetTickets()
- timer.Create("ww2_restartGAME", round.cfg.endingtime, 1, function()
- round.Begin()
- ww2.UnFreezeAll()
- xp.ResetPerming()
- end)
- timer.Create("UpdateEndTime", 0.1, round.cfg.endingtime * 10, function()
- SetGlobalInt("END_TIME", timer.TimeLeft("ww2_restartGAME"))
- end)
- round.UpdateWinner()
- end
- elseif reasontype == "pushed" then
- if GetGlobalString("DefeatType") == "push" then
- ww2.SetSpectatorsAll()
- ww2.FreezeAll()
- xp.permingXP()
- SetGlobalBool("Ending", true)
- round.SetWinner(ww2.GetPushTeam())
- round.ShowupEnd(true)
- timer.Remove("WW2_ticket")
- timer.Stop("UpdateRoundTime")
- ww2.ResetTickets()
- timer.Create("ww2_restartGAME", round.cfg.endingtime, 1, function()
- round.Begin()
- ww2.UnFreezeAll()
- xp.ResetPerming()
- end)
- timer.Create("UpdateEndTime", 0.1, round.cfg.endingtime * 10, function()
- SetGlobalInt("END_TIME", timer.TimeLeft("ww2_restartGAME"))
- end)
- round.UpdateWinner()
- elseif GetGlobalString("DefeatType") == "defend" then
- ww2.SetSpectatorsAll()
- ww2.FreezeAll()
- xp.permingXP()
- SetGlobalBool("Ending", true)
- round.SetWinner(ww2.GetDefendTeam())
- round.ShowupEnd(true)
- timer.Remove("WW2_ticket")
- timer.Stop("UpdateRoundTime")
- ww2.ResetTickets()
- timer.Create("ww2_restartGAME", round.cfg.endingtime, 1, function()
- round.Begin()
- ww2.UnFreezeAll()
- xp.ResetPerming()
- end)
- timer.Create("UpdateEndTime", 0.1, round.cfg.endingtime * 10, function()
- SetGlobalInt("END_TIME", timer.TimeLeft("ww2_restartGAME"))
- end)
- round.UpdateWinner()
- end
- end
- team.AddScore(round.GetWinner(), 1)
- ww2.MapSelection()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement