From bfad62487c08237f6227546b98878fd05ec08474 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 16 Oct 2021 03:32:22 +0200 Subject: [PATCH 1/2] Update gamemodestopper.lua --- [editor]/editor_main/gamemodestopper.lua | 35 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/[editor]/editor_main/gamemodestopper.lua b/[editor]/editor_main/gamemodestopper.lua index 8023fba7c..16cbf083c 100644 --- a/[editor]/editor_main/gamemodestopper.lua +++ b/[editor]/editor_main/gamemodestopper.lua @@ -1,5 +1,5 @@ function isResourceRunning(res) - return getResourceState(res)=="running" + return getResourceState(res) == "running" end function isGamemode(res) @@ -10,17 +10,28 @@ function isMap(res) return exports.mapmanager:isMap(res) end -addEventHandler("onResourceStart", getResourceRootElement(), - function() - for index,resource in ipairs(getResources()) do - if isResourceRunning(resource) and (isGamemode(resource) or isMap(resource)) then - if hasObjectPermissionTo(getThisResource(), "function.stopResource") then - stopResource(resource) - else - outputDebugString("Editor: Unable to stop running gamemodes (no access to function.stopResource)") - return - end +function onResourceStart(startedResource) + local stopPermission = hasObjectPermissionTo(startedResource, "function.stopResource") + + if not stopPermission then + outputDebugString("Editor: Unable to stop running gamemodes (no access to function.stopResource)") + + return false + end + + local resourcesTable = getResources() + + for resourceID = 1, #resourcesTable do + local resourceElement = resourcesTable[resourceID] + local resourceRunning = isResourceRunning(resourceElement) + + if resourceRunning then + local gamemodeOrMap = isGamemode(resourceElement) or isMap(resourceElement) + + if gamemodeOrMap then + stopResource(resourceElement) end end end -) +end +addEventHandler("onResourceStart", resourceRoot, onResourceStart) \ No newline at end of file From 3063712ac88d489eecae0263bf6ae086959ff6b5 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Tue, 16 Nov 2021 13:27:35 +0100 Subject: [PATCH 2/2] Update gamemodestopper.lua --- [editor]/editor_main/gamemodestopper.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/[editor]/editor_main/gamemodestopper.lua b/[editor]/editor_main/gamemodestopper.lua index 16cbf083c..7b36f8246 100644 --- a/[editor]/editor_main/gamemodestopper.lua +++ b/[editor]/editor_main/gamemodestopper.lua @@ -11,9 +11,7 @@ function isMap(res) end function onResourceStart(startedResource) - local stopPermission = hasObjectPermissionTo(startedResource, "function.stopResource") - - if not stopPermission then + if not hasObjectPermissionTo(startedResource, "function.stopResource") then outputDebugString("Editor: Unable to stop running gamemodes (no access to function.stopResource)") return false @@ -23,9 +21,8 @@ function onResourceStart(startedResource) for resourceID = 1, #resourcesTable do local resourceElement = resourcesTable[resourceID] - local resourceRunning = isResourceRunning(resourceElement) - if resourceRunning then + if isResourceRunning(resourceElement) then local gamemodeOrMap = isGamemode(resourceElement) or isMap(resourceElement) if gamemodeOrMap then