Full View config.server.lua

SV = {}

SV.Webhooks = {
    ['WITHDRAW'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['REMOVE_MARKETPLACE'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['PLACED_MARKETPLACE'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['CHANGED_NAME'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['CHANGED_DESCRIPTION'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['UPDATED_DISCOUNT'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['UPDATED_PRODUCT_PRICE'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['PUTTED_ITEM'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['PULLED_ITEM'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
    ['BOUGHT_ITEM'] = "https://discord.com/api/webhooks/xxxxxxxxxxxxxx",
}

SV.WebhookText = {
    ['TITLE.WITHDRAW_CASH'] = "πŸ’Έ WITHDRAW CASH",
    ['DESCRIPTION.WITHDRAW_CASH'] = "Player %s [%s] withdraw %s$ from market with ID %s",

    ['TITLE.REMOVE_MARKETPLACE'] = "❌ REMOVE MARKETPLACE",
    ['DESCRIPTION.REMOVE_MARKETPLACE'] = "Player %s [%s] removed marketplace with ID %s",
    ['DESCRIPTION.REMOVE_MARKETPLACE_ADMIN'] = "Administrator %s [%s] removed marketplace with ID %s",
    
    ['TITLE.PLACED_MARKETPLACE'] = "πŸ—οΈ PLACED MARKETPLACE",
    ['DESCRIPTION.PLACED_MARKETPLACE'] = "Player %s [%s] placed marketplace with ID %s\n**TYPE**: %s\n**NAME**: %s\n**DESCRIPTION**: %s\n**COORDS**: %s",
    
    ['TITLE.CHANGED_NAME'] = "⌨️ CHANGED NAME",
    ['DESCRIPTION.CHANGED_NAME'] = "Player %s [%s] changed name from %s to %s on marketplace ID %s",
    
    ['TITLE.CHANGED_DESCRIPTION'] = "⌨️ CHANGED DESCRIPTION",
    ['DESCRIPTION.CHANGED_DESCRIPTION'] = "Player %s [%s] changed description from %s to %s on marketplace ID %s",
    
    ['TITLE.ENABLED_DISCOUNT'] = "🎫 ENABLED DISCOUNT",
    ['DESCRIPTION.ENABLED_DISCOUNT'] = "Player %s [%s] enabled discount -%s on marketplace ID %s",

    ['TITLE.DISABLED_DISCOUNT'] = "🎫 DISABLED DISCOUNT",
    ['DESCRIPTION.DISABLED_DISCOUNT'] = "Player %s [%s] disabled discount on marketplace ID %s",

    ['TITLE.UPDATED_PRODUCT_PRICE'] = "πŸ’² UPDATED PRODUCT PRICE",
    ['DESCRIPTION.UPDATED_PRODUCT_PRICE'] = "Player %s [%s] updated price for item %s from %s$ to %s$ on marketplace ID %s",

    ['TITLE.PUTTED_ITEM'] = "🀲 PUTTED ITEM",
    ['DESCRIPTION.PUTTED_ITEM'] = "Player %s [%s] putted item %s %sx on marketplace ID %s",
    
    ['TITLE.PULLED_ITEM'] = "🫳 PULLED ITEM",
    ['DESCRIPTION.PULLED_ITEM'] = "Player %s [%s] pulled item %s %sx from marketplace ID %s",

    ['TITLE.BOUGHT_ITEM'] = "πŸ’° BOUGHT ITEM",
    ['DESCRIPTION.BOUGHT_ITEM'] = "Player %s [%s] bought item %s %sx from marketplace ID %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.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
        return xPlayer.Functions.GetItemByName(item).label
    end
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.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

if Config.MarketplacesOnItem then
    if Config.Core == "ESX" then
        for k, v in pairs(Config.MarketplaceItems) do
            if k and v then
                ESX.RegisterUsableItem(v.item, function(source)
                    TriggerClientEvent("vms_marketplaces:usedItem", source, k, v.item)
                end)
            end
        end
    elseif Config.Core == "QB-Core" then
        for k, v in pairs(Config.MarketplaceItems) do
            if k and v then
                QBCore.Functions.CreateUseableItem(v.item, function(source, item)
                    TriggerClientEvent("vms_marketplaces:usedItem", source, k, v.item)
                end)
            end
        end
    end
end

Last updated