Skip to content

Commit cacfbb3

Browse files
committed
Fix error when playing on a mission without end outpost
1 parent 13fc9f3 commit cacfbb3

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Lua/traitormodmisc.lua

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,24 @@ Hook.Add("think", "Traitormod.MiscThink", function ()
4949
if Traitormod.RoundEvents.IsEventActive("OutpostPirateAttack") then return end
5050
if Traitormod.SelectedGamemode == nil or Traitormod.SelectedGamemode.Name ~= "Secret" then return end
5151

52-
local targets = {}
53-
local outpost = Level.Loaded.EndOutpost.WorldPosition
5452

55-
for key, character in pairs(Character.CharacterList) do
56-
if character.IsRemotePlayer and character.IsHuman and not character.IsDead and Vector2.Distance(character.WorldPosition, outpost) < 5000 then
57-
table.insert(targets, character)
53+
if Level.Loaded ~= nil and Level.Loaded.EndOutpost ~= nil then
54+
local targets = {}
55+
local outpost = Level.Loaded.EndOutpost.WorldPosition
56+
57+
for key, character in pairs(Character.CharacterList) do
58+
if character.IsRemotePlayer and character.IsHuman and not character.IsDead and Vector2.Distance(character.WorldPosition, outpost) < 5000 then
59+
table.insert(targets, character)
60+
end
5861
end
59-
end
6062

61-
if #targets > 0 then
62-
peopleInOutpost = peopleInOutpost + 1
63-
end
63+
if #targets > 0 then
64+
peopleInOutpost = peopleInOutpost + 1
65+
end
6466

65-
if peopleInOutpost > 30 then
66-
Traitormod.RoundEvents.TriggerEvent("OutpostPirateAttack")
67+
if peopleInOutpost > 30 then
68+
Traitormod.RoundEvents.TriggerEvent("OutpostPirateAttack")
69+
end
6770
end
6871
end)
6972

0 commit comments

Comments
 (0)