How do I give myself permission?
Thank you, best script… have to do some fix with opening other menus stuck the player and have to QUIT but otherwise it’s dope AF
Can anyone tell me how I can make shops use this inventory UI for buying items? For example, you just drag the items into your inventory and it charges you based on the prices set up in the database? Please lmk if you guys can help out!
Someone just posted a version of this that includes shops on the forums in the release section.
Link?
Thanks man!
hi i need some help when i press f2 it open but i cant get out of it … whats the reason for this ?? how do i give myself permission
Guys i cant preview ui.html on the browser T^T i want to modify this
anyone have an issue if a player takes items directly out of the trunk it bypasses the inventory limit of the item thereby allowing them to carry an unlimited amount
I’m having an issue with the property inventory not displaying the items I put into it.
I have tried multiple different fixes for this, but can’t seem to figure it out.
Weapons work fine, but anything other than that won’t work.
Anybody have any idea why it’s doing this?
Thanks in advance.
Hello everyone, I have a problem with the script, i buy the food in stores and goes to the inventory but then when I go to use it does not recognize the item
weapons dont stack?
same here, seems there is no db related to property inventory its kinda weird…
I installed this resource with the trunk and glove box resources and got errors with the inventory resource and es extended client.lua’s so i uninstalled them and then just tried the inventory resource menu on its own with trunk and got errors again
Hello guys, i don’t understand i can use inventoryhud 2.3 and i want change put_stock or put_weapon but i get the error http://prntscr.com/oo55m3 – http://prntscr.com/oo571v
I use this code http://prntscr.com/oo56f5 what is my faulth and ı want to change everything for example motel and home ınventory menu how can ı do it ? I read this page but ı dont understand because my english ver bad
Hey @Trsak, I’m adding an extension for esx_inventoryhud that makes you use esx_shops with this eventory, I can already open the shop inventory in game but the problem is that I have no items in the menu!
So my problem is one function to set up the inventory
so this is my file “shops” from the inventoryhud scrip:
local shopData = nil
local ShopItems = {}
RegisterNetEvent("esx_inventoryhud:openShopInventory")
AddEventHandler(
"esx_inventoryhud:openShopInventory",
function(data, inventory)
setShopInventoryData(data, inventory)
openShopInventory()
end
)
function refreshShopInventory()
ESX.TriggerServerCallback(
"esx_shops:requestDBItems",
function(inventory)
setShopInventoryData(data, inventory)
end,
ESX.GetPlayerData().identifier
)
end
function setShopInventoryData(data, inventory)
--shopData = data
SendNUIMessage(
{
action = "setInfoText",
text = data.text
}
)
items = {}
SendNUIMessage(
{
action = "setShopInventoryItems",
itemList = inventory
}
)
end
function openShopInventory()
loadPlayerInventory()
isInInventory = true
SendNUIMessage(
{
action = "display",
type = "shop"
}
)
SetNuiFocus(true, true)
end
RegisterNUICallback("TakeFromShop", function(data, cb)
if IsPedSittingInAnyVehicle(playerPed) then
return
end
if type(data.number) == "number" and math.floor(data.number) == data.number then
TriggerServerEvent("esx_shops:buyItem", ESX.GetPlayerData().identifier, data.item.type, data.item.name, tonumber(data.number))
end
--Wait(150)
--refreshShopInventory()
Wait(150)
loadPlayerInventory()
cb("ok")
end
)
The function that I’m missing is the “setShopInventoryData”
this is the server side from esx_shops:
ESX = nil
local ShopItems = {}
local hasSqlRun = false
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
--[[
MySQL.ready(function()
MySQL.Async.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item', {}, function(shopResult)
for i=1, #shopResult, 1 do
if shopResult[i].name then
if ShopItems[shopResult[i].store] == nil then
ShopItems[shopResult[i].store] = {}
end
if shopResult[i].limit == -1 then
shopResult[i].limit = 30
end
table.insert(ShopItems[shopResult[i].store], {
label = shopResult[i].label,
item = shopResult[i].item,
price = shopResult[i].price,
limit = shopResult[i].limit
})
else
print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item))
end
end
end)
end)
--]]
-- Load items
AddEventHandler('onMySQLReady', function()
hasSqlRun = true
LoadShop()
end)
-- extremely useful when restarting script mid-game
Citizen.CreateThread(function()
Citizen.Wait(2000) -- hopefully enough for connection to the SQL server
if not hasSqlRun then
LoadShop()
hasSqlRun = true
end
end)
function LoadShop()
local itemResult = MySQL.Sync.fetchAll('SELECT * FROM items')
local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops')
local itemInformation = {}
for i=1, #itemResult, 1 do
if itemInformation[itemResult[i].name] == nil then
itemInformation[itemResult[i].name] = {}
end
itemInformation[itemResult[i].name].label = itemResult[i].label
itemInformation[itemResult[i].name].limit = itemResult[i].limit
end
for i=1, #shopResult, 1 do
if ShopItems[shopResult[i].store] == nil then
ShopItems[shopResult[i].store] = {}
end
if itemInformation[shopResult[i].item].limit == -1 then
itemInformation[shopResult[i].item].limit = 30
end
table.insert(ShopItems[shopResult[i].store], {
label = itemInformation[shopResult[i].item].label,
item = shopResult[i].item,
price = shopResult[i].price,
limit = itemInformation[shopResult[i].item].limit
})
end
end
--[[
ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb)
cb(ShopItems)
end)
--]]
ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb)
if not hasSqlRun then
TriggerClientEvent('esx:showNotification', source, 'The shop database has not been loaded yet, try again in a few moments.')
end
cb(ShopItems)
end)
RegisterServerEvent('esx_shops:buyItem')
AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local sourceItem = xPlayer.getInventoryItem(itemName)
amount = ESX.Math.Round(amount)
-- is the player trying to exploit?
if amount < 0 then
print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!')
return
end
-- get price
local price = 0
local itemLabel = ''
for i=1, #ShopItems[zone], 1 do
if ShopItems[zone][i].item == itemName then
price = ShopItems[zone][i].price
itemLabel = ShopItems[zone][i].label
break
end
end
price = price * amount
-- can the player afford this item?
if xPlayer.getMoney() >= price then
-- can the player carry the said amount of x item?
if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then
TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold'))
else
xPlayer.removeMoney(price)
xPlayer.addInventoryItem(itemName, amount)
TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)))
end
else
local missingMoney = price - xPlayer.getMoney()
TriggerClientEvent('esx:showNotification', _source, _U('not_enough', ESX.Math.GroupDigits(missingMoney)))
end
end)
and this on the client side of esx_shops
function OpenShopMenu(zone)
ESX.TriggerServerCallback(
"esx_shops:requestDBItems",
function(inventory)
TriggerEvent("esx_inventoryhud:openShopInventory", inventory)
end
)
end
Can you help me figure out the setShopInventoryData?
Thanks for your time!
police menu don’t active why?
Thank you for posting this fix, I was so confused why I couldn’t get my motel inventory to show.
When someone is downed and you search them and take a weapon, when they are revived they still have the weapon you took from them (DUPLICATES) does anyone know how to fix this please
EDIT: the problem has nothing to do with this script its a problem in es_extended, If anyone has the same issue just remove the 4 lines it says here https://github.com/ESX-Org/es_extended/pull/315/files