@@ -20,9 +20,12 @@ local function inputBox(action, shopName, item, maxAmount)
2020 end
2121end
2222
23- local function openSellMenu (shopName )
23+ local function openItemsToSellMenu (shopName )
2424 local itemsForSale = lib .callback .await (' red40_mining:server:getSellableItems' , false , shopName )
2525 local sellOptions = {}
26+ if not itemsForSale or # itemsForSale == 0 then
27+ return Notify (locale (' error.no_items_to_sell' ), ' error' )
28+ end
2629 for i = 1 , # itemsForSale do
2730 local item = itemsForSale [i ]
2831 sellOptions [# sellOptions + 1 ] = {
@@ -42,11 +45,14 @@ local function openSellMenu(shopName)
4245 lib .showContext (' red40_mining_sell_menu' )
4346end
4447
45- local function openBuyMenu (shopName )
46- local itemsForSale = lib .callback .await (' red40_mining:server:getShopItems' , false , shopName )
48+ local function openItemsToBuyMenu (shopName )
49+ local itemsToBuy = lib .callback .await (' red40_mining:server:getShopItems' , false , shopName )
4750 local buyOptions = {}
48- for i = 1 , # itemsForSale do
49- local item = itemsForSale [i ]
51+ if not itemsToBuy or # itemsToBuy == 0 then
52+ return Notify (locale (' error.no_items_to_buy' ), ' error' )
53+ end
54+ for i = 1 , # itemsToBuy do
55+ local item = itemsToBuy [i ]
5056 local label = Items [item .name ] and Items [item .name ].label or item .name
5157 buyOptions [# buyOptions + 1 ] = {
5258 title = locale (' menu.buy_item' , label ),
@@ -95,7 +101,7 @@ local function createPedPoint(point)
95101 label = locale (' target.buy' ),
96102 icon = ' fa-solid fa-box' ,
97103 onSelect = function ()
98- openBuyMenu (point .shopName )
104+ openItemsToBuyMenu (point .shopName )
99105 end ,
100106 }
101107 end
@@ -105,7 +111,7 @@ local function createPedPoint(point)
105111 label = locale (' target.sell' ),
106112 icon = ' fa-solid fa-hand-holding-dollar' ,
107113 onSelect = function ()
108- openSellMenu (point .shopName )
114+ openItemsToSellMenu (point .shopName )
109115 end ,
110116 }
111117 end
@@ -189,11 +195,11 @@ local function createPedPoint(point)
189195 lib .showTextUI (textLocale )
190196 end
191197 end
192- if IsControlJustReleased (0 , config .useKey ) then
193- openSellMenu (point .shopName )
198+ if IsControlJustReleased (0 , config .useKey ) and point . pedBuys then
199+ openItemsToSellMenu (point .shopName )
194200 end
195- if IsControlJustReleased (0 , config .useKey2 ) then
196- openBuyMenu (point .shopName )
201+ if IsControlJustReleased (0 , config .useKey2 ) and point . pedSells then
202+ openItemsToBuyMenu (point .shopName )
197203 end
198204 else
199205 local textOpen , text = lib .isTextUIOpen ()
0 commit comments