Skip to content

Commit

Permalink
tweak(server/shops): warn when item is grade-restricted, but has no job
Browse files Browse the repository at this point in the history
If the shop jobs/groups is nil, but grade is defined on a slot, purchasing the item ends up throwing an error.

Set the grade to nil but give a warning about the item.
  • Loading branch information
thelindat committed May 20, 2022
1 parent 6178d9e commit 7bf7c7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ game 'gta5'
--[[ Resource Information ]]--
name 'ox_inventory'
author 'Overextended'
version '2.8.4'
version '2.8.5'
repository 'https://github.com/overextended/ox_inventory'
description 'What even is an "ESX.Items" anyway?'

Expand Down
14 changes: 14 additions & 0 deletions modules/shops/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ for shopName, shopDetails in pairs(data('shops')) do
}
for j = 1, Shops[shopName][i].slots do
local slot = Shops[shopName][i].items[j]

if slot.grade and not shopDetails.groups then
print(('^1attempted to restrict slot %s (%s) to grade %s, but %s has no job restriction^0'):format(i, slot.name, slot.grade, shopDetails.name))
slot.grade = nil
end

local Item = Items(slot.name)

if Item then
slot = {
name = Item.name,
Expand Down Expand Up @@ -51,7 +58,14 @@ for shopName, shopDetails in pairs(data('shops')) do
}
for i = 1, Shops[shopName].slots do
local slot = Shops[shopName].items[i]

if slot.grade and not shopDetails.groups then
print(('^1attempted to restrict slot %s (%s) to grade %s, but %s has no job restriction^0'):format(i, slot.name, slot.grade, shopDetails.name))
slot.grade = nil
end

local Item = Items(slot.name)

if Item then
slot = {
name = Item.name,
Expand Down

0 comments on commit 7bf7c7d

Please sign in to comment.