Full View config.server.lua

SV = {}

SV.Webhooks = {
    ['SHOP'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
    ['SELL'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
    ['ITEM_HARVEST'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
    ['ITEM_EXCHANGE'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
    ['ITEM_SELL'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
    ['STORAGE'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxxx",
}

SV.WebhookText = {
    ['TITLE.SHOP'] = "πŸ’Έ JOB - SHOP",
    ['DESCRIPTION.SHOP'] = "Player **%s** **[%s]** bought **%s** **(%s)** for **%s$** from **%s** shop.\n\n**Job**: %s (%s)\n**Grade**: %s (%s)",

    ['TITLE.SELL'] = "πŸ’Έ JOB - SELL",
    ['DESCRIPTION.SELL'] = "Player **%s** **[%s]** sell **%s** **(%s)** for **%s$**.\n\n**Job**: %s (%s)\n**Grade**: %s (%s)",

    ['TITLE.ITEM_HARVEST'] = "πŸ’Έ JOB - ITEM HARVEST",
    ['DESCRIPTION.ITEM_HARVEST'] = "Player **%s** **[%s]**\n\n**Harvested**: %s\n**Job**: %s (%s)\n**Grade**: %s (%s)",
    
    ['TITLE.ITEM_EXCHANGE'] = "πŸ’Έ JOB - ITEM EXCHANGE",
    ['DESCRIPTION.ITEM_EXCHANGE'] = "Player **%s** **[%s]**\n\n**Recieved**: %s\n**For**: %s\n**Job**: %s (%s)\n**Grade**: %s (%s)",
    
    ['TITLE.ITEM_SELL'] = "πŸ’Έ JOB - ITEM SELL",
    ['DESCRIPTION.ITEM_SELL'] = "Player **%s** **[%s]**\n\n**Recieved**: %s\n**For**: %s (%sx)\n**Job**: %s (%s)\n**Grade**: %s (%s)",
    
    ['TITLE.STORAGE'] = "πŸ’Έ JOB - STORAGE",
    ['DESCRIPTION.STORAGE_PUT'] = "Player **%s** **[%s]** put **%s** **(%s)** to **%s** storage.\n\n**Job**: %s (%s)\n**Grade**: %s (%s)",
    ['DESCRIPTION.STORAGE_PULL'] = "Player **%s** **[%s]** pull **%s** **(%s)** from **%s** storage.\n\n**Job**: %s (%s)\n**Grade**: %s (%s)",
}

SV.Webhook = function(webhook_id, title, description, color, footer)
    local DiscordWebHook = SV.Webhooks[webhook_id]
    local embeds = {
        {
            ["title"] = title,
            ["type"] = "rich",
            ["description"] = description,
            ["color"] = color,
            ["footer"] = {
                ["text"] = footer..' - '..os.date(),
            },
        }
    }
    PerformHttpRequest(DiscordWebHook, function(err, text, headers) end, 'POST', json.encode({username = name, embeds = embeds}), {['Content-Type'] = 'application/json'})
end

SV.getIdentifier = function(xPlayer)
    if Config.Core == "ESX" then
        return xPlayer.identifier
    elseif Config.Core == "QB-Core" then
        return xPlayer.PlayerData.citizenid
    end
    return nil
end

SV.getPlayerJob = function(xPlayer, type)
    if Config.Core == "ESX" then
        if type == "name" then
            return xPlayer.job.name
        end
        if type == "label" then
            return xPlayer.job.label
        end
        if type == "grade" then
            return xPlayer.job.grade
        end
        if type == "grade_label" then
            return xPlayer.job.grade_label
        end
    elseif Config.Core == "QB-Core" then
        if type == "name" then
            return xPlayer.PlayerData.job.name
        end
        if type == "label" then
            return xPlayer.PlayerData.job.label
        end
        if type == "grade" then
            return xPlayer.PlayerData.job.grade
        end
        if type == "grade_label" then
            return xPlayer.PlayerData.job.grade.name
        end
    end
    return nil
end

SV.getPlayerGang = function(type)
    if Config.Core == "ESX" then
        if type == "name" then
            return xPlayer.job2.name
        end
        if type == "label" then
            return xPlayer.job2.label
        end
        if type == "grade" then
            return xPlayer.job2.grade
        end
        if type == "grade_label" then
            return xPlayer.job2.grade_label
        end
    elseif Config.Core == "QB-Core" then
        if type == "name" then
            return xPlayer.PlayerData.gang.name
        end
        if type == "label" then
            return xPlayer.PlayerData.gang.label
        end
        if type == "grade" then
            return xPlayer.PlayerData.gang.grade
        end
        if type == "grade_label" then
            return xPlayer.PlayerData.gang.grade.name
        end
    end
    return nil
end

SV.CheckCountOfItem = function(xPlayer, item, count)
    if Config.Core == "ESX" then
        return xPlayer.getInventoryItem(item).count >= count
    elseif Config.Core == "QB-Core" then
        return xPlayer.Functions.GetItemByName(item).amount >= count
    end
end

SV.GetInventory = function(xPlayer)
    if Config.Core == "ESX" then
        return xPlayer.getInventory()
    elseif Config.Core == "QB-Core" then
        return xPlayer.PlayerData.items
    end
end

SV.GetItemLabel = function (xPlayer, item)
    if Config.Core == "ESX" then
        return ESX.GetItemLabel(item)
    elseif Config.Core == "QB-Core" then

    end
end

SV.GetInventoryItem = function(xPlayer, item)
    if Config.Core == "ESX" then
        return xPlayer.getInventoryItem(item)
    elseif Config.Core == "QB-Core" then
        return xPlayer.Functions.GetItemByName(item)
    end
end

SV.AddInventoryItem = function(xPlayer, item, count)
    if Config.Core == "ESX" then
        xPlayer.addInventoryItem(item, count)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.AddItem(item, count)
    end
end

SV.RemoveInventoryItem = function(xPlayer, item, count)
    if Config.Core == "ESX" then
        xPlayer.removeInventoryItem(item, count)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.RemoveItem(item, count)
    end
end

SV.AddCash = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.addAccountMoney('money', amount)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.AddMoney('cash', amount)
    end
end

SV.AddBank = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.addAccountMoney('bank', amount)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.AddMoney('bank', amount)
    end
end

SV.AddBlackMoney = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.addAccountMoney('black_money', amount)
    elseif Config.Core == "QB-Core" then

    end
end

SV.RemoveCash = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.removeAccountMoney('money', amount)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.RemoveMoney('cash', amount)
    end
end

SV.RemoveBank = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.removeAccountMoney('bank', amount)
    elseif Config.Core == "QB-Core" then
        xPlayer.Functions.RemoveMoney('bank', amount)
    end
end

SV.RemoveBlackMoney = function(xPlayer, amount)
    if Config.Core == "ESX" then
        xPlayer.removeAccountMoney('black_money', amount)
    elseif Config.Core == "QB-Core" then

    end
end

Last updated