mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2026-11-10 13:57:18 +01:00
Code modernize (#234)
* refactor: declare exports at runtime and drop the player-data provides alias Signed-off-by: Mathu-lmn <[email protected]> * refactor: pass handlers directly to RegisterNetEvent Signed-off-by: Mathu-lmn <[email protected]> * refactor: use CreateThread/Wait without the Citizen prefix Signed-off-by: Mathu-lmn <[email protected]> * chore: remove trailing whitespace, stray lines and unused locals Signed-off-by: Mathu-lmn <[email protected]> --------- Signed-off-by: Mathu-lmn <[email protected]>
This commit is contained in:
@@ -6,25 +6,13 @@ author 'Cfx.re <[email protected]>'
|
||||
description 'A flexible handler for game type/map association.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_scripts {
|
||||
"mapmanager_shared.lua",
|
||||
"mapmanager_client.lua"
|
||||
}
|
||||
client_script 'mapmanager_client.lua'
|
||||
|
||||
server_scripts {
|
||||
"mapmanager_shared.lua",
|
||||
"mapmanager_server.lua"
|
||||
}
|
||||
server_script 'mapmanager_server.lua'
|
||||
|
||||
shared_script 'mapmanager_shared.lua'
|
||||
|
||||
fx_version 'cerulean'
|
||||
games { 'gta5', 'rdr3' }
|
||||
|
||||
server_export "getCurrentGameType"
|
||||
server_export "getCurrentMap"
|
||||
server_export "changeGameType"
|
||||
server_export "changeMap"
|
||||
server_export "doesMapSupportGameType"
|
||||
server_export "getMaps"
|
||||
server_export "roundEnded"
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
|
||||
@@ -40,8 +40,8 @@ AddEventHandler('onClientResourceStart', function(res)
|
||||
loadMap(res)
|
||||
|
||||
-- defer this to the next game tick to work around a lack of dependencies
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(15)
|
||||
CreateThread(function()
|
||||
Wait(15)
|
||||
|
||||
if maps[res] then
|
||||
TriggerEvent('onClientMapStart', res)
|
||||
|
||||
@@ -12,14 +12,14 @@ local function refreshResources()
|
||||
if GetNumResourceMetadata(resource, 'resource_type') > 0 then
|
||||
local type = GetResourceMetadata(resource, 'resource_type', 0)
|
||||
local params = json.decode(GetResourceMetadata(resource, 'resource_type_extra', 0))
|
||||
|
||||
|
||||
local valid = false
|
||||
|
||||
|
||||
local games = GetNumResourceMetadata(resource, 'game')
|
||||
if games > 0 then
|
||||
for j = 0, games - 1 do
|
||||
local game = GetResourceMetadata(resource, 'game', j)
|
||||
|
||||
|
||||
if game == GetConvar('gamename', 'gta5') or game == 'common' then
|
||||
valid = true
|
||||
end
|
||||
@@ -313,3 +313,11 @@ function doesMapSupportGameType(gameType, map)
|
||||
|
||||
return maps[map].gameTypes[gameType]
|
||||
end
|
||||
|
||||
exports('getCurrentGameType', getCurrentGameType)
|
||||
exports('getCurrentMap', getCurrentMap)
|
||||
exports('changeGameType', changeGameType)
|
||||
exports('changeMap', changeMap)
|
||||
exports('doesMapSupportGameType', doesMapSupportGameType)
|
||||
exports('getMaps', getMaps)
|
||||
exports('roundEnded', roundEnded)
|
||||
|
||||
@@ -74,7 +74,7 @@ function parseMap(file, owningResource)
|
||||
}
|
||||
|
||||
setmetatable(env, mt)
|
||||
|
||||
|
||||
local fileData = LoadResourceFile(owningResource, file)
|
||||
local mapFunction, err = load(fileData, file, 't', env)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user