diff --git a/Example/Lua/traitormod/autorun/traitormod.lua b/Example/Lua/traitormod/autorun/traitormod.lua index ac1b40fd5..b34ea412d 100644 --- a/Example/Lua/traitormod/autorun/traitormod.lua +++ b/Example/Lua/traitormod/autorun/traitormod.lua @@ -8,8 +8,12 @@ traitormod.gamemodes = {} traitormod.disableRadioChat = false +local endingRound = false +local roundEndDelay = 0 + local traitorAssignDelay = 0 local traitorsAssigned = true +local traitorsRoundStartAssigned = false local warningClients = {} local config = dofile("lua/traitormod/traitorconfig.lua") @@ -203,10 +207,11 @@ traitormod.assignNormalTraitors = function(amount) for key, va in pairs(traitormod.selectedCodeResponses) do mess = mess .. "\"" .. va .. "\" " end - - mess = mess .. "\n(You can type in local chat !traitor, to check this information again.)" end + mess = mess .. "\n(You can type in local chat !traitor, to check this information again.)" + + Game.Log(value.name .. " Was assigned to be traitor, his first mission is to kill " .. traitormod.roundtraitors[value].objectiveTarget.name, 6) @@ -353,6 +358,8 @@ Hook.Add("roundEnd", "traitor_end", function() end + traitorsRoundStartAssigned = false + endingRound = false traitormod.roundtraitors = {} traitormod.selectedCodeResponses = {} traitormod.selectedCodePhrases = {} @@ -366,8 +373,32 @@ Hook.Add("think", "traitor_think", function() traitormod.assignNormalTraitors(amount) traitorsAssigned = true + traitorsRoundStartAssigned = true end + if endingRound == true and roundEndDelay < Timer.GetTime() then + Game.ExecuteCommand('endgame') + + endingRound = false + end + + if traitorsRoundStartAssigned and config.endRoundWhenAllTraitorsDie then + local num = 0 + + for key, value in pairs(traitormod.roundtraitors) do + if key.IsDead == false then num = num + 1 end + end + + if num == 0 then + Game.SendMessage('All traitors died! Ending round in ' .. config.endRoundDelayInSeconds .. ' seconds.', 1) + + endingRound = true + roundEndDelay = Timer.GetTime() + config.endRoundDelayInSeconds + traitorsRoundStartAssigned = false + end + end + + for key, value in pairs(Player.GetAllCharacters()) do if warningClients[value] == nil then diff --git a/Example/Lua/traitormod/traitorconfig.lua b/Example/Lua/traitormod/traitorconfig.lua index 03b06028e..cb97bf41d 100644 --- a/Example/Lua/traitormod/traitorconfig.lua +++ b/Example/Lua/traitormod/traitorconfig.lua @@ -15,6 +15,9 @@ config.amountCodewords = 2 config.traitorSpawnDelay = 60 config.nextMissionDelay = 60 +config.endRoundWhenAllTraitorsDie = false +config.endRoundDelayInSeconds = 60 + config.traitorShipEnabled = true -- set this to false for the respawn shuttles to work config.traitorShipChance = 15 config.traitorShipGodModeDistance = 4000