VHS-PLAYEROWNEDSTORES - [ESX, QBCore, Qbox]

Tebex Store
Preview Video - vhs-playerownedstores
VoidHubScripts - Discord

We’re excited to release another free resource for the FiveM community, we released player owned stores as it was something I always wanted on my own servers many years ago, it’s a basic script that allows businesses to list items for sale and when sold deposits moneys into there society / business accounts, we’ve included webhooks as well as a way to edit listed items after they’ve been listed, increase / decreasing stock & price editing.

Features

  • Create unlimited stores, for each business / job
  • Set management perms based on job and grade
  • Add Items based on the items in a players inventory
  • Edit existing items, increase or decrease stock and prices
  • Added webhooks to stock & who is using / increase stock
  • Edit blips, stores names, locations, peds
  • Free support as always

vhs_multi-jobs_5

Paid:
[+] VHS-WOODCUTTING
[+] VHS-MINING
[+] VHS-CRAFTING
[+] VHS-LEVELS
[+] VHS-BLACKMARKET

[+] VHS-FISHING
Free:
[+] VHS-RECYCLE
[+] VHS-MULTIJOBS
[+] VHS-NPCDRUGSALES

Code is accessible Yes
Subscription-based No
Lines (approximately) 200-300+
Requirements ox_lib, ox_target or qb-target
Support Yes
10 Likes


Why can’t I add items to the store?

Most likely a framework specific issue, what are you running?

qbcore

We sorted it out a couple hours ago it’s on github now qbcore data mismatch has been fixed

So this script works perfectly for what i needed it for. Appreciate it. Only issue i see, is if you have an open slot in your inventory, it wont show past that open spot.

All good, looking I’ll look into we’ve received alot of tremendous feedback, we’re going to be pushing some updates in the next hour or so

1 Like

sounds good. loving it so far. last one i tried screwed with the actual job and their inventory. this one works perfectly. other than this little thing lol. amazing work.

Updates:

[+] Allowlist Items
[+] Added player ownerships based on citizenid / identifer
[+] Fixed retrieving items with ox_inventory

attempt to index a nil value (local ‘input’) while canceling dialog box(fix)

RegisterNetEvent('vhs-stores:open')
AddEventHandler('vhs-stores:open', function(name, config, data, hasItems)
    if hasItems then
        local menuOptions = {}
        for item, data in pairs(data.items) do
            table.insert(menuOptions, { 
                title = ItemLabel(item) .. ' - $' .. data.price, 
                description = 'Stock Available - (' .. data.amount .. 'x)', 
                icon = InventoryImagePath .. item .. ".png", 
                args = { price = data.price, item = item, amount = data.amount },
                onSelect = function()
                    local input = lib.inputDialog('Purchase ' .. ItemLabel(item), { 
                        {type = 'number', description = 'Amount to purchase', icon = 'hashtag', min = 1, max = data.amount, required = true, default = 1} -- Set default value to 1
                    })
                    
                    -- Check if input is nil (canceled) before proceeding
                    if input == nil then
                        --print('Input canceled or closed by user.')
                        return -- Stop further execution
                    end

                    -- Proceed only if input is valid and not empty
                    if input[1] then
                        local buy = lib.callback.await('vhs-store:buyItem', false, name, item, data.price, input[1])
                    else
                        print('No valid amount entered.')
                    end
                end,
            })
        end
        lib.registerContext({ id = 'store_'.. name, title = config.menu.title, options = menuOptions })
        lib.showContext('store_'.. name)
    else
        lib.registerContext({ id = 'store_'.. name, title = config.menu.title, options = {{ title = 'No Items Available' }}})
        lib.showContext('store_'.. name)
    end
end)
1 Like

Filter inventory items based on the store’s allowed items

function addStock(name)
    local storeConfig = Stores[name]
    if not storeConfig or not storeConfig.allowedItems.useAllowed then
        return
    end
    local inv = lib.callback.await('vhs-stores:getInv', false)
    if inv then
        local menuOptions = {}
        -- Filter inventory items based on the store's allowed items
        for _, item in ipairs(inv) do
            if table.contains(storeConfig.allowedItems.list, string.lower(item.name)) then
                table.insert(menuOptions, { 
                    title = item.label .. ' - (' .. item.count .. 'x)', 
                    icon = InventoryImagePath .. string.lower(item.name) .. ".png",  
                    args = { store = name, item = string.lower(item.name), label = item.name, amount = item.count },
                    onSelect = function()
                        local input = lib.inputDialog('Add ' .. item.label .. ' as Product', { 
                            {type = 'number', label = 'Price', description = 'Set the price of stock', required = true, min = 1}, 
                            {type = 'slider', label = 'Stock Amount', description = 'Set the amount of stock', icon = 'hashtag', min = 1, max = item.count, required = true,} 
                        })
                        local setup = lib.callback.await('vhs-store:setItem', false, input[1], input[2], string.lower(item.name), name)
                    end
                })
            end
        end
        lib.registerContext({ id = 'sstore_' .. name, title = '➕ Select Item to Setup', options = menuOptions })
        lib.showContext('sstore_' .. name)
    end
end
1 Like

I’m having a problem that when i buy an item i dont recive the item?

Could you try to do it with ox_inventory instead of ox_lib? Something like wasabi_oxshops have, that would be cool!

Great stuff, we’ll add the fixes to github if you want, great work!

1 Like

Yeah we looked at doing that, it seems possible, only issues I had in trying to do it was with qb-inventory, as it has the ability to createshops, but no ability to edit them or update them, I mean we could do it directly through SQL assuming they store there shops in SQL, but we’d need the ability to update stores live based on stock options, honestly might just create a UI for the playerowned stores in the next couple days, I’m really not a fan of all these ox_lib context menus, I mean they’re not bad but it could be much nicer.

1 Like

is it possible that you put the items that comes from your inventory and drag it to the shop rather than a pre allowed items that was put in config?


This error occurs when I edit a product and select a product

What framework, I’ll sort it out?

Does this support metadata for the items?

Nope, esx doesn’t have metadata for items unless using ox_inventory we might add it for ox_inventory & qb-inventories