Skip to content

Commit

Permalink
fix(items): set prop as array when using propTwo
Browse files Browse the repository at this point in the history
Resolves #1594 #1586.
Should be noted propTwo is deprecated (just use an array for prop).
  • Loading branch information
thelindat committed Jan 23, 2024
1 parent 5203545 commit 8f565f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
4 changes: 0 additions & 4 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ lib.callback.register('ox_inventory:usingItem', function(data)
item.anim = Animations.anim[item.anim]
end

if item.propTwo then
item.prop = { item.prop, item.propTwo }
end

if item.prop then
if item.prop[1] then
for i = 1, #item.prop do
Expand Down
34 changes: 24 additions & 10 deletions modules/items/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,44 @@ local function newItem(data)
end

if isServer then
---@cast data OxServerItem
serverData = data.server
data.client = nil

if serverData?.export then
data.cb = useExport(string.strsplit('.', serverData.export))
end

if not data.durability then
if data.degrade or (data.consume and data.consume ~= 0 and data.consume < 1) then
data.durability = true
end
end

if not serverData then goto continue end

if serverData.export then
data.cb = useExport(string.strsplit('.', serverData.export))
end
else
---@cast data OxClientItem
clientData = data.client
data.server = nil
data.count = 0

if clientData?.export then
data.export = useExport(string.strsplit('.', clientData.export))
end
if not clientData then goto continue end

if clientData?.image then
clientData.image = clientData.image:match('^[%w]+://') and clientData.image or ('%s/%s'):format(client.imagepath, clientData.image)
end
if clientData.export then
data.export = useExport(string.strsplit('.', clientData.export))
end

if clientData.image then
clientData.image = clientData.image:match('^[%w]+://') and clientData.image or ('%s/%s'):format(client.imagepath, clientData.image)
end

if clientData.propTwo then
clientData.prop = clientData.prop and { clientData.prop, clientData.propTwo } or clientData.propTwo
clientData.propTwo = nil
end
end

::continue::
ItemList[data.name] = data
end

Expand Down

0 comments on commit 8f565f8

Please sign in to comment.