manager.lua
local function CFXManager()
function Logger(args, color, multiline, print_to_chat)
if print_to_chat then
TriggerClientEvent('chat:addMessage', -1, {
color = color or { 255, 0, 0 },
multiline = multiline or true,
args = args
});
else
return print(args)
end
end
function Version()
local current = GetResourceMetadata(GetCurrentResourceName(), 'version', 0)
local latest = CheckManagerForUpdates().latest
return { current = current, latest = latest }
end
function HasAcePermission(source, permission)
return IsPlayerAceAllowed(source, permission) or false
end
function CheckManagerForUpdates()
local repo = 'toxic-development/cfx_manager'
local current = Version()
local latest = nil
PerformHttpRequest('https://api.github.com/repos/' .. repo .. '/releases/latest', function(err, text, headers)
local data = json.decode(text)
local changes = data.body
latest = data.tag_name
return { current = current, latest = latest, changes = changes }
end, 'GET', '', { ['Content-Type'] = 'application/json' })
end
end