From 6e253a9ff564ab99caf4c8a9bbcc15955041b01f Mon Sep 17 00:00:00 2001 From: guava Date: Mon, 22 May 2017 06:12:52 +0200 Subject: [PATCH] Duplicity support for mapmanager_server --- .../mapmanager/mapmanager_server.lua | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/resources/[managers]/mapmanager/mapmanager_server.lua b/resources/[managers]/mapmanager/mapmanager_server.lua index c7e4599..594e786 100644 --- a/resources/[managers]/mapmanager/mapmanager_server.lua +++ b/resources/[managers]/mapmanager/mapmanager_server.lua @@ -21,7 +21,36 @@ AddEventHandler('getResourceInitFuncs', function(isPreParse, add) end) end) +local function refreshResources() + local numResources = GetNumResources() + + for i = 0, numResources - 1 do + local resource = GetResourceByFindIndex(i) + + if GetNumResourceMetadata(resource, 'resource_type') > 0 then + local type = GetResourceMetadata(resource, 'resource_type', 0) + local params = json.decode(GetResourceMetadata(resource, 'resource_type_extra', 0)) + + if type == 'map' then + maps[resource] = params + elseif type == 'gametype' then + gametypes[resource] = params + end + end + end +end + +AddEventHandler('onResourceListRefresh', function() + refreshResources() +end) + +refreshResources() + AddEventHandler('onResourceStarting', function(resource) + if GetNumResourceMetadata(resource, 'map') then + -- todo: add file + end + if maps[resource] then if getCurrentMap() and getCurrentMap() ~= resource then if doesMapSupportGameType(getCurrentGameType(), resource) then @@ -80,8 +109,10 @@ AddEventHandler('onResourceStart', function(resource) if doesMapSupportGameType(currentGameType, resource) then if TriggerEvent('onMapStart', resource, maps[resource]) then if maps[resource].name then + print('Started map ' .. maps[resource].name) SetMapName(maps[resource].name) else + print('Started map ' .. resource) SetMapName(resource) end @@ -270,4 +301,4 @@ function doesMapSupportGameType(gameType, map) end return maps[map].gameTypes[gameType] -end +end \ No newline at end of file