manager.lua

--[[
    THIS FILE IS FOR SHARED FUNCTIONS AND VARIABLES
    THAT ARE USED IN BOTH THE SERVER AND CLIENT
    SCRIPTS.

    NOTE: Do not edit this file unless you know what you are doing.

    © 2023 Toxic Development. All rights reserved.
]]

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
generated by LDoc 1.4.6 Last updated 2023-12-18 07:18:17