File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change 1
1
function isResourceRunning (res )
2
- return getResourceState (res )== " running"
2
+ return getResourceState (res ) == " running"
3
3
end
4
4
5
5
function isGamemode (res )
@@ -10,17 +10,25 @@ function isMap(res)
10
10
return exports .mapmanager :isMap (res )
11
11
end
12
12
13
- addEventHandler (" onResourceStart" , getResourceRootElement (),
14
- function ()
15
- for index ,resource in ipairs (getResources ()) do
16
- if isResourceRunning (resource ) and (isGamemode (resource ) or isMap (resource )) then
17
- if hasObjectPermissionTo (getThisResource (), " function.stopResource" ) then
18
- stopResource (resource )
19
- else
20
- outputDebugString (" Editor: Unable to stop running gamemodes (no access to function.stopResource)" )
21
- return
22
- end
13
+ function onResourceStart (startedResource )
14
+ if not hasObjectPermissionTo (startedResource , " function.stopResource" ) then
15
+ outputDebugString (" Editor: Unable to stop running gamemodes (no access to function.stopResource)" )
16
+
17
+ return false
18
+ end
19
+
20
+ local resourcesTable = getResources ()
21
+
22
+ for resourceID = 1 , # resourcesTable do
23
+ local resourceElement = resourcesTable [resourceID ]
24
+
25
+ if isResourceRunning (resourceElement ) then
26
+ local gamemodeOrMap = isGamemode (resourceElement ) or isMap (resourceElement )
27
+
28
+ if gamemodeOrMap then
29
+ stopResource (resourceElement )
23
30
end
24
31
end
25
32
end
26
- )
33
+ end
34
+ addEventHandler (" onResourceStart" , resourceRoot , onResourceStart )
You can’t perform that action at this time.
0 commit comments