mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-02-10 23:53:34 +08:00
Duplicity support for mapmanager_server
This commit is contained in:
parent
b6b736ceb7
commit
6e253a9ff5
@ -21,7 +21,36 @@ AddEventHandler('getResourceInitFuncs', function(isPreParse, add)
|
|||||||
end)
|
end)
|
||||||
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)
|
AddEventHandler('onResourceStarting', function(resource)
|
||||||
|
if GetNumResourceMetadata(resource, 'map') then
|
||||||
|
-- todo: add file
|
||||||
|
end
|
||||||
|
|
||||||
if maps[resource] then
|
if maps[resource] then
|
||||||
if getCurrentMap() and getCurrentMap() ~= resource then
|
if getCurrentMap() and getCurrentMap() ~= resource then
|
||||||
if doesMapSupportGameType(getCurrentGameType(), resource) then
|
if doesMapSupportGameType(getCurrentGameType(), resource) then
|
||||||
@ -80,8 +109,10 @@ AddEventHandler('onResourceStart', function(resource)
|
|||||||
if doesMapSupportGameType(currentGameType, resource) then
|
if doesMapSupportGameType(currentGameType, resource) then
|
||||||
if TriggerEvent('onMapStart', resource, maps[resource]) then
|
if TriggerEvent('onMapStart', resource, maps[resource]) then
|
||||||
if maps[resource].name then
|
if maps[resource].name then
|
||||||
|
print('Started map ' .. maps[resource].name)
|
||||||
SetMapName(maps[resource].name)
|
SetMapName(maps[resource].name)
|
||||||
else
|
else
|
||||||
|
print('Started map ' .. resource)
|
||||||
SetMapName(resource)
|
SetMapName(resource)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -270,4 +301,4 @@ function doesMapSupportGameType(gameType, map)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return maps[map].gameTypes[gameType]
|
return maps[map].gameTypes[gameType]
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user