πŸ“Editable

(SERVER) utils.lua

local Framework, frameworkName = getFramework()

function getPlayer(source)
    if frameworkName == "esx" then
        return Framework.GetPlayerFromId(source)
    else
        return Framework.Functions.GetPlayer(source)
    end
end

function addItem(Player, item, count)
    if frameworkName == "esx" then
        Player.addInventoryItem(item, count)
    else
        Player.Functions.AddItem(item, count)
    end
end

function removeItem(Player, item, count)
    if frameworkName == "esx" then
        Player.removeInventoryItem(item, count)
    else
        Player.Functions.RemoveItem(item, count)
    end
end

function registerUsableItem(itemName, callback)
    if frameworkName == "esx" then
        Framework.RegisterUsableItem(itemName, callback)
    elseif frameworkName == "qb" then
        Framework.Functions.CreateUseableItem(itemName, callback)
    end
end

function getItem(Player, item)
    if frameworkName == "esx" then
        return Player.getInventoryItem(item)
    else
        return Player.Functions.GetItemByName(item)
    end
end

function getMoney(Player, method)
    if frameworkName == "esx" then
        if method == "cash" then
            return Player.getMoney()
        else
            return Player.getAccount('bank').money
        end
    else
        if method == "cash" then
            return Player.PlayerData.money["cash"]
        else
            return Player.PlayerData.money["bank"]
        end
    end
end

function addMoney(Player, method, money)
    if frameworkName == "esx" then
        if method == "cash" then
            Player.addMoney(money)
        else
            Player.AddAccountMoney('bank', money)
        end
    else
        if method == "cash" then
            Player.Functions.AddMoney('cash', money)
        else
            Player.Functions.AddMoney('bank', money)
        end
    end
end

function removeMoney(Player, method, money)
    if frameworkName == "esx" then
        if method == "cash" then
            Player.removeMoney(money)
        else
            Player.removeAccountMoney('bank', money)
        end
    else
        if method == "cash" then
            Player.Functions.RemoveMoney("cash", money)
        else
            Player.Functions.RemoveMoney('bank', money)
        end
    end
end

function getName(identifier, Player)
    if identifier then
        if frameworkName == "esx" then
            local Info = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {["@identifier"] = identifier})
            return Info[1].firstname.." "..Info[1].lastname
        else
            if Player then 
                return Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname
            else
                return "Not Found"
            end
        end
    else
        return "Not Found"
    end
end

GetJsonData = function()
    local data = LoadResourceFile(GetCurrentResourceName(), 'data.json')
    if data then
        return json.decode(data)
    else
        return {}
    end
end

(CLIENT) grounds.lua

(CLIENT) notify.lua

Last updated