[FREE] Cloud Resources - Shop

Upgrade your FiveM server with our cutting-edge shop system that combines sleek design, high performance, and high customizability.

:star:丨Features

  • Modern & Intuitive Design: A visually stunning interface that enhances your players’ shopping experience.
  • Easy Installation & Setup: Get started in minutes with a hassle-free configuration process.
  • Optimized for High Performance: Experience lag-free gameplay with a lightweight and efficient design.
  • Fully Customizable: Tailor every aspect of the shop system to perfectly fit your server’s unique needs.

:inbox_tray:丨Download

[GitHub] Download

:camera_flash:丨Preview

:gear:・Code is Accessible: Yes
:credit_card:・Subscription-based: No
:hammer_and_wrench:・Supported Frameworks: ESX / QBCore / Custom
:warning:・Dependencies: ox_lib
:question:・Support: Discord Server
:balance_scale:・License: CC BY-NC
:page_facing_up:・Lines of Code: ≈1.800+
19 Likes

Fire Free Shop Script :fire: :fire: :fire: :fire:

1 Like

It’s a shame you can’t use the web because he doesn’t really release the JS. I think that’s because it’s not (open source), otherwise it looks good.

1 Like

im gonna make it avaible soon, the downside is just that some scummy developers will probably use that code to create a shop for there own and then sell it

(tho btw you can format the css so you can still edit the style, it’s just the JS that is fully compiled)

1 Like

You have that no matter what you do, they give stuff on their own, no matter where they got it from, you can see it here in the forum

Yes, I realize that, but you can’t do anything to the JS if you want to change something

1 Like

yea i know it’s a shame, but like i said i will create a branch soon where i will release the fronted source code

1 Like

is it possible for a Weapon shop to set it that only Players with a weapon license can buy a weapon?

1 Like

As of right now, no, but a license requirement is already planned and will be implemented in the next few days.

Looks good

1 Like

really nice design

1 Like

Great script :100:

Should be pretty easy to add new specific shops with this.

Edit - I’m getting this error when attempting to purchase any items.


Also, this would be great UI for a pawnshop or just store we can sell too in general.

1 Like

Yeah I couldn’t figure it out lol

1 Like

It works perfectly, thank you for this great script, I will use it, thanks amigo. :call_me_hand:t2: :blush:

1 Like

Please open a ticket in our Discord server for support: Cloud Resources

I think I had the same problem, I made some modifications but it is in Spanish, although I don’t think it will affect it. I hope it helps you. Replace the code in /bridge/server/qbcore.lua

local Config = require("shared.sh_config")
local Locales = require("shared.sh_locales")

-- Verifica que el framework sea qbcore
if Config.Framework ~= "qbcore" then return end

local QBCore = exports["qb-core"]:GetCoreObject()

local inShop = {}

-- Obtener el jugador por su ID
local function GetPlayerId(source)
    if not source or source == 0 then return nil end
    return QBCore.Functions.GetPlayer(source)
end

-- Verifica si el jugador puede llevar una cierta cantidad de un artículo
local function CanCarryItem(source, itemName, itemQuantity)
    -- Usando qb-inventory para verificar si puede llevar el artículo
    return exports["qb-inventory"]:CanAddItem(source, itemName, itemQuantity)
end

-- Agregar un artículo al inventario del jugador
local function AddItem(source, itemName, itemQuantity)
    -- Usando qb-inventory para agregar el artículo
    return exports["qb-inventory"]:AddItem(source, itemName, itemQuantity, false, false, "cloud-shop:AddItem")
end

-- Verificar si el jugador tiene una licencia específica
local function HasLicense(source, licenseType)
    if not source or source == 0 then return false end
    if not licenseType then return false end

    local Player = GetPlayerId(source)
    if not Player then return false end

    return Player.PlayerData.metadata.licences[licenseType] ~= nil
end

-- Comprar una licencia para el jugador
local function BuyLicense(source, shopData)
    if not source or source == 0 then return false, "Fuente inválida" end
    if not shopData or next(shopData) == nil then return false, "Datos de la tienda inválidos o vacíos" end
    if not inShop[source] then return false, "No estás en la tienda" end

    local Player = GetPlayerId(source)
    if not Player then return false, "Jugador no encontrado" end

    local licenseType = shopData.License.Type
    local amount = shopData.License.Price

    -- Obtener dinero disponible en efectivo y banco
    local moneyAvailable = Player.Functions.GetMoney("cash")  -- Usamos "cash" para dinero en efectivo
    local bankAvailable = Player.Functions.GetMoney("bank")  -- Usamos "bank" para dinero del banco

    local accountType
    if moneyAvailable >= amount then
        accountType = "cash"  -- Usamos "cash" si hay suficiente efectivo
    elseif bankAvailable >= amount then
        accountType = "bank"  -- Usamos "bank" si hay suficiente dinero en la cuenta bancaria
    else
        ServerNotify(source, Locales.License.NoMoney:format(licenseType), "error")
        return false, "No tienes suficiente dinero"
    end

    -- Quitar el dinero del jugador
    Player.Functions.RemoveMoney(accountType, amount)

    -- Agregar la licencia al jugador
    local licenseTable = Player.PlayerData.metadata.licences
    licenseTable[licenseType] = true
    Player.Functions.SetMetaData("licences", licenseTable)

    ServerNotify(source, Locales.License.PurchaseSuccess:format(licenseType, amount), "info")
    return true, "Licencia comprada con éxito"
end

-- Si no se usa armas como artículos ni ox_inventory
if not Config.WeaponAsItem then
    -- Función para verificar si el jugador tiene un arma
    function HasWeapon(source, weaponName)
        -- Implementa la lógica para verificar si el jugador tiene el arma
    end

    -- Función para agregar un arma al jugador
    function AddWeapon(source, weaponName)
        -- Implementa la lógica para agregar el arma al jugador
    end
end

-- Procesar la transacción de compra en la tienda
local function ProcessTransaction(source, type, cartArray)
    if not source or source == 0 then return false, "Fuente inválida" end
    if not cartArray or #cartArray == 0 then return false, "Carrito vacío o inválido" end
    if not inShop[source] then return false, "No estás en la tienda" end

    local Player = GetPlayerId(source)
    if not Player then return false, "Jugador no encontrado" end

    -- Determinar el tipo de cuenta (banco o efectivo)
    local accountType = (type == "bank" and "bank") or "cash"  -- Usamos "cash" si el tipo es "cash", de lo contrario "bank"
    local totalCartPrice = 0

    for _, item in ipairs(cartArray) do
        -- Obtener la cantidad de dinero disponible
        local availableMoney = Player.Functions.GetMoney(accountType) or 0  -- Aseguramos que availableMoney sea un número
        local totalItemPrice = (item.price * item.quantity) or 0  -- Aseguramos que totalItemPrice sea un número

        -- Verificar que el dinero disponible sea suficiente para la compra
        if availableMoney >= totalItemPrice then
            -- Si el artículo es un arma y no se permite como artículo
            if item.name:sub(1, 7):lower() == "weapon_" and not Config.WeaponAsItem then
                if not HasWeapon(source, item.name) then
                    -- Quitar el dinero del jugador
                    Player.Functions.RemoveMoney(accountType, totalItemPrice)
                    AddWeapon(source, item.name)
                    totalCartPrice = totalCartPrice + totalItemPrice
                else
                    ServerNotify(source, Locales.Notification.HasWeapon:format(item.label), "error")
                end
            else
                -- Verificar si el jugador puede llevar el artículo
                if CanCarryItem(source, item.name, item.quantity) then
                    -- Quitar el dinero del jugador y agregar el artículo
                    Player.Functions.RemoveMoney(accountType, totalItemPrice)
                    AddItem(source, item.name, item.quantity)
                    totalCartPrice = totalCartPrice + totalItemPrice
                else
                    ServerNotify(source, Locales.Notification.CantCarry:format(item.label), "error")
                end
            end
        else
            ServerNotify(source, Locales.Notification.NoMoney:format(item.label), "error")
        end
    end

    if totalCartPrice > 0 then
        ServerNotify(source, Locales.Notification.PurchaseSuccess:format(totalCartPrice), "success")
        return true, ("Artículo(s) comprado(s) por $%s"):format(totalCartPrice)
    end
    return false, "No se compraron artículos"
end

-- Registro de los callbacks para la tienda
lib.callback.register("cloud-shop:server:HasLicense", HasLicense)
lib.callback.register("cloud-shop:server:BuyLicense", function(source, shopData)
    local success, reason = BuyLicense(source, shopData)
    return success, reason
end)
lib.callback.register("cloud-shop:server:ProcessTransaction", function(source, type, cartArray)
    local success, reason = ProcessTransaction(source, type, cartArray)
    return success, reason
end)
lib.callback.register("cloud-shop:server:InShop", function(source, status)
    inShop[source] = status
end)
2 Likes

This actually did work for me, thanks.

2 Likes

I’m glad it worked for you; I think it’s because instead of “cash,” “money” is used in a combined function.

1 Like

Yes, that was the issue! Thanks to your feedback, it’s now fixed in the latest update.

2 Likes

Hey, no problem amigo, excellent work! :blush:

1 Like