diff --git a/client/main.lua b/client/main.lua index 51000ee92..e32c283b7 100644 --- a/client/main.lua +++ b/client/main.lua @@ -176,8 +176,9 @@ local function CloseTrunk() end ---Checks weight and size of the vehicle trunk local function GetTrunkSize(vehicleClass) + if not vehicleClass then vehicleClass = 'default' end local trunkSize = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace['default'] - return trunkSize[vehicleClass].maxweight, trunkSize[vehicleClass].slots + return trunkSize.maxWeight, trunkSize.slots end exports('GetTrunkSize', GetTrunkSize) diff --git a/html/images/404.png b/html/images/404.png new file mode 100644 index 000000000..b357034bd Binary files /dev/null and b/html/images/404.png differ diff --git a/html/images/amaretto.png b/html/images/amaretto.png new file mode 100644 index 000000000..114be22a4 Binary files /dev/null and b/html/images/amaretto.png differ diff --git a/html/images/amarettosour.png b/html/images/amarettosour.png new file mode 100644 index 000000000..4f89777f6 Binary files /dev/null and b/html/images/amarettosour.png differ diff --git a/html/images/ambeer.png b/html/images/ambeer.png new file mode 100644 index 000000000..05cbbbba0 Binary files /dev/null and b/html/images/ambeer.png differ diff --git a/html/images/b52.png b/html/images/b52.png new file mode 100644 index 000000000..1ffda738e Binary files /dev/null and b/html/images/b52.png differ diff --git a/html/images/beancoffee.png b/html/images/beancoffee.png new file mode 100644 index 000000000..577e0a901 Binary files /dev/null and b/html/images/beancoffee.png differ diff --git a/html/images/bellini.png b/html/images/bellini.png new file mode 100644 index 000000000..d6a895108 Binary files /dev/null and b/html/images/bellini.png differ diff --git a/html/images/bigfruit.png b/html/images/bigfruit.png new file mode 100644 index 000000000..d39a62e83 Binary files /dev/null and b/html/images/bigfruit.png differ diff --git a/html/images/bkamikaze.png b/html/images/bkamikaze.png new file mode 100644 index 000000000..3f9a9d068 Binary files /dev/null and b/html/images/bkamikaze.png differ diff --git a/html/images/bleeder.png b/html/images/bleeder.png new file mode 100644 index 000000000..5ea3cb9fc Binary files /dev/null and b/html/images/bleeder.png differ diff --git a/html/images/bratte.png b/html/images/bratte.png new file mode 100644 index 000000000..058d7d58a Binary files /dev/null and b/html/images/bratte.png differ diff --git a/html/images/brussian.png b/html/images/brussian.png new file mode 100644 index 000000000..32a9d54e9 Binary files /dev/null and b/html/images/brussian.png differ diff --git a/html/images/burger-coffee.png b/html/images/burger-coffee.png new file mode 100644 index 000000000..a16d50589 Binary files /dev/null and b/html/images/burger-coffee.png differ diff --git a/html/images/burgerbag.png b/html/images/burgerbag.png new file mode 100644 index 000000000..07ff3214f Binary files /dev/null and b/html/images/burgerbag.png differ diff --git a/html/images/burgerbun.png b/html/images/burgerbun.png new file mode 100644 index 000000000..b9f6c6f62 Binary files /dev/null and b/html/images/burgerbun.png differ diff --git a/html/images/burgermeat.png b/html/images/burgermeat.png new file mode 100644 index 000000000..2179849ae Binary files /dev/null and b/html/images/burgermeat.png differ diff --git a/html/images/burgerpatty.png b/html/images/burgerpatty.png new file mode 100644 index 000000000..d1b8d6bb8 Binary files /dev/null and b/html/images/burgerpatty.png differ diff --git a/html/images/caffeagra.png b/html/images/caffeagra.png new file mode 100644 index 000000000..b6f416ab6 Binary files /dev/null and b/html/images/caffeagra.png differ diff --git a/html/images/cappucc.png b/html/images/cappucc.png new file mode 100644 index 000000000..b576bae65 Binary files /dev/null and b/html/images/cappucc.png differ diff --git a/html/images/ccookie.png b/html/images/ccookie.png new file mode 100644 index 000000000..c05178f40 Binary files /dev/null and b/html/images/ccookie.png differ diff --git a/html/images/cheddar.png b/html/images/cheddar.png new file mode 100644 index 000000000..02bc3bdc5 Binary files /dev/null and b/html/images/cheddar.png differ diff --git a/html/images/cheesecake.png b/html/images/cheesecake.png new file mode 100644 index 000000000..ab217af8e Binary files /dev/null and b/html/images/cheesecake.png differ diff --git a/html/images/chickenbreast.png b/html/images/chickenbreast.png new file mode 100644 index 000000000..ae1450272 Binary files /dev/null and b/html/images/chickenbreast.png differ diff --git a/html/images/chickenwrap.png b/html/images/chickenwrap.png new file mode 100644 index 000000000..92149c26d Binary files /dev/null and b/html/images/chickenwrap.png differ diff --git a/html/images/chips.png b/html/images/chips.png new file mode 100644 index 000000000..bed75e77e Binary files /dev/null and b/html/images/chips.png differ diff --git a/html/images/chocolate.png b/html/images/chocolate.png new file mode 100644 index 000000000..fb3131628 Binary files /dev/null and b/html/images/chocolate.png differ diff --git a/html/images/cosmopolitan.png b/html/images/cosmopolitan.png new file mode 100644 index 000000000..964326e08 Binary files /dev/null and b/html/images/cosmopolitan.png differ diff --git a/html/images/cranberry.png b/html/images/cranberry.png new file mode 100644 index 000000000..7bb91c5ba Binary files /dev/null and b/html/images/cranberry.png differ diff --git a/html/images/creampie.png b/html/images/creampie.png new file mode 100644 index 000000000..54952db64 Binary files /dev/null and b/html/images/creampie.png differ diff --git a/html/images/cubasil.png b/html/images/cubasil.png new file mode 100644 index 000000000..bffb9c993 Binary files /dev/null and b/html/images/cubasil.png differ diff --git a/html/images/curaco.png b/html/images/curaco.png new file mode 100644 index 000000000..98e6514a7 Binary files /dev/null and b/html/images/curaco.png differ diff --git a/html/images/dusche.png b/html/images/dusche.png new file mode 100644 index 000000000..8f3cf90ce Binary files /dev/null and b/html/images/dusche.png differ diff --git a/html/images/ecoffee.png b/html/images/ecoffee.png new file mode 100644 index 000000000..e4e4dd8b5 Binary files /dev/null and b/html/images/ecoffee.png differ diff --git a/html/images/ecola.png b/html/images/ecola.png new file mode 100644 index 000000000..9713a4d43 Binary files /dev/null and b/html/images/ecola.png differ diff --git a/html/images/ecolalight.png b/html/images/ecolalight.png new file mode 100644 index 000000000..695fe3da3 Binary files /dev/null and b/html/images/ecolalight.png differ diff --git a/html/images/flusher.png b/html/images/flusher.png new file mode 100644 index 000000000..45b529b5a Binary files /dev/null and b/html/images/flusher.png differ diff --git a/html/images/frozennugget.png b/html/images/frozennugget.png new file mode 100644 index 000000000..18267e619 Binary files /dev/null and b/html/images/frozennugget.png differ diff --git a/html/images/gin.png b/html/images/gin.png new file mode 100644 index 000000000..4b8f83831 Binary files /dev/null and b/html/images/gin.png differ diff --git a/html/images/goatwrap.png b/html/images/goatwrap.png new file mode 100644 index 000000000..c724e280a Binary files /dev/null and b/html/images/goatwrap.png differ diff --git a/html/images/gunkaccino.png b/html/images/gunkaccino.png new file mode 100644 index 000000000..28e4cdac7 Binary files /dev/null and b/html/images/gunkaccino.png differ diff --git a/html/images/heartstopper.png b/html/images/heartstopper.png new file mode 100644 index 000000000..8e2077579 Binary files /dev/null and b/html/images/heartstopper.png differ diff --git a/html/images/highnoon.png b/html/images/highnoon.png new file mode 100644 index 000000000..b5faa2099 Binary files /dev/null and b/html/images/highnoon.png differ diff --git a/html/images/icecream.png b/html/images/icecream.png new file mode 100644 index 000000000..bcf5e03cc Binary files /dev/null and b/html/images/icecream.png differ diff --git a/html/images/icream.png b/html/images/icream.png new file mode 100644 index 000000000..37454f3c8 Binary files /dev/null and b/html/images/icream.png differ diff --git a/html/images/iflag.png b/html/images/iflag.png new file mode 100644 index 000000000..369ffeb8a Binary files /dev/null and b/html/images/iflag.png differ diff --git a/html/images/kamikaze.png b/html/images/kamikaze.png new file mode 100644 index 000000000..57dc49e16 Binary files /dev/null and b/html/images/kamikaze.png differ diff --git a/html/images/lemon.png b/html/images/lemon.png new file mode 100644 index 000000000..5c1ab4aa8 Binary files /dev/null and b/html/images/lemon.png differ diff --git a/html/images/lettuce.png b/html/images/lettuce.png new file mode 100644 index 000000000..7662ba55e Binary files /dev/null and b/html/images/lettuce.png differ diff --git a/html/images/lime.png b/html/images/lime.png new file mode 100644 index 000000000..2d94a6572 Binary files /dev/null and b/html/images/lime.png differ diff --git a/html/images/logger.png b/html/images/logger.png new file mode 100644 index 000000000..09ac8df7b Binary files /dev/null and b/html/images/logger.png differ diff --git a/html/images/longisland.png b/html/images/longisland.png new file mode 100644 index 000000000..aa371d4e1 Binary files /dev/null and b/html/images/longisland.png differ diff --git a/html/images/margarita.png b/html/images/margarita.png new file mode 100644 index 000000000..383a9b7d7 Binary files /dev/null and b/html/images/margarita.png differ diff --git a/html/images/meat.png b/html/images/meat.png new file mode 100644 index 000000000..0a6aa362e Binary files /dev/null and b/html/images/meat.png differ diff --git a/html/images/meatfree.png b/html/images/meatfree.png new file mode 100644 index 000000000..3a2c7a07d Binary files /dev/null and b/html/images/meatfree.png differ diff --git a/html/images/midori.png b/html/images/midori.png new file mode 100644 index 000000000..67adbcb7f Binary files /dev/null and b/html/images/midori.png differ diff --git a/html/images/milk.png b/html/images/milk.png new file mode 100644 index 000000000..d1a74b2b4 Binary files /dev/null and b/html/images/milk.png differ diff --git a/html/images/milkshake.png b/html/images/milkshake.png new file mode 100644 index 000000000..62b40d4e5 Binary files /dev/null and b/html/images/milkshake.png differ diff --git a/html/images/mint.png b/html/images/mint.png new file mode 100644 index 000000000..b7d876965 Binary files /dev/null and b/html/images/mint.png differ diff --git a/html/images/moneyshot.png b/html/images/moneyshot.png new file mode 100644 index 000000000..fae4bdc06 Binary files /dev/null and b/html/images/moneyshot.png differ diff --git a/html/images/nachos.png b/html/images/nachos.png new file mode 100644 index 000000000..b554fbde2 Binary files /dev/null and b/html/images/nachos.png differ diff --git a/html/images/nplate.png b/html/images/nplate.png new file mode 100644 index 000000000..fb89bcb74 Binary files /dev/null and b/html/images/nplate.png differ diff --git a/html/images/onion.png b/html/images/onion.png new file mode 100644 index 000000000..b56736751 Binary files /dev/null and b/html/images/onion.png differ diff --git a/html/images/orange.png b/html/images/orange.png new file mode 100644 index 000000000..f1a2e10fa Binary files /dev/null and b/html/images/orange.png differ diff --git a/html/images/oyster.png b/html/images/oyster.png new file mode 100644 index 000000000..828b88864 Binary files /dev/null and b/html/images/oyster.png differ diff --git a/html/images/peach.png b/html/images/peach.png new file mode 100644 index 000000000..2d75a7860 Binary files /dev/null and b/html/images/peach.png differ diff --git a/html/images/pinacolada.png b/html/images/pinacolada.png new file mode 100644 index 000000000..63a59bed2 Binary files /dev/null and b/html/images/pinacolada.png differ diff --git a/html/images/pinejuice.png b/html/images/pinejuice.png new file mode 100644 index 000000000..01c8fdcc4 Binary files /dev/null and b/html/images/pinejuice.png differ diff --git a/html/images/pisswaser1.png b/html/images/pisswaser1.png new file mode 100644 index 000000000..9a689893d Binary files /dev/null and b/html/images/pisswaser1.png differ diff --git a/html/images/pisswaser2.png b/html/images/pisswaser2.png new file mode 100644 index 000000000..767862ad9 Binary files /dev/null and b/html/images/pisswaser2.png differ diff --git a/html/images/pisswaser3.png b/html/images/pisswaser3.png new file mode 100644 index 000000000..5a44a46c2 Binary files /dev/null and b/html/images/pisswaser3.png differ diff --git a/html/images/popdonut.png b/html/images/popdonut.png new file mode 100644 index 000000000..c5726157f Binary files /dev/null and b/html/images/popdonut.png differ diff --git a/html/images/potatoes.png b/html/images/potatoes.png new file mode 100644 index 000000000..dbc002a8d Binary files /dev/null and b/html/images/potatoes.png differ diff --git a/html/images/prosecco.png b/html/images/prosecco.png new file mode 100644 index 000000000..4476370de Binary files /dev/null and b/html/images/prosecco.png differ diff --git a/html/images/rhinohorn.png b/html/images/rhinohorn.png new file mode 100644 index 000000000..99544aa91 Binary files /dev/null and b/html/images/rhinohorn.png differ diff --git a/html/images/rimjob.png b/html/images/rimjob.png new file mode 100644 index 000000000..7096da1fe Binary files /dev/null and b/html/images/rimjob.png differ diff --git a/html/images/rum.png b/html/images/rum.png new file mode 100644 index 000000000..3c00ca76c Binary files /dev/null and b/html/images/rum.png differ diff --git a/html/images/sangria.png b/html/images/sangria.png new file mode 100644 index 000000000..cd1989386 Binary files /dev/null and b/html/images/sangria.png differ diff --git a/html/images/sbullet.png b/html/images/sbullet.png new file mode 100644 index 000000000..b0cb76cb4 Binary files /dev/null and b/html/images/sbullet.png differ diff --git a/html/images/schnapps.png b/html/images/schnapps.png new file mode 100644 index 000000000..955b21a84 Binary files /dev/null and b/html/images/schnapps.png differ diff --git a/html/images/scotch.png b/html/images/scotch.png new file mode 100644 index 000000000..6229b8e7c Binary files /dev/null and b/html/images/scotch.png differ diff --git a/html/images/screwdriver.png b/html/images/screwdriver.png new file mode 100644 index 000000000..7af9d1fc4 Binary files /dev/null and b/html/images/screwdriver.png differ diff --git a/html/images/shotfries.png b/html/images/shotfries.png new file mode 100644 index 000000000..7c38a5a72 Binary files /dev/null and b/html/images/shotfries.png differ diff --git a/html/images/shotnuggets.png b/html/images/shotnuggets.png new file mode 100644 index 000000000..461eca80e Binary files /dev/null and b/html/images/shotnuggets.png differ diff --git a/html/images/shotrings.png b/html/images/shotrings.png new file mode 100644 index 000000000..2784cdfd6 Binary files /dev/null and b/html/images/shotrings.png differ diff --git a/html/images/slicedonion.png b/html/images/slicedonion.png new file mode 100644 index 000000000..ac4a48871 Binary files /dev/null and b/html/images/slicedonion.png differ diff --git a/html/images/slicedpotato.png b/html/images/slicedpotato.png new file mode 100644 index 000000000..51093daba Binary files /dev/null and b/html/images/slicedpotato.png differ diff --git a/html/images/sliders.png b/html/images/sliders.png new file mode 100644 index 000000000..52d407ff8 Binary files /dev/null and b/html/images/sliders.png differ diff --git a/html/images/softdrink.png b/html/images/softdrink.png new file mode 100644 index 000000000..fd5625092 Binary files /dev/null and b/html/images/softdrink.png differ diff --git a/html/images/speedball.png b/html/images/speedball.png new file mode 100644 index 000000000..ca0e993ca Binary files /dev/null and b/html/images/speedball.png differ diff --git a/html/images/sprunk.png b/html/images/sprunk.png new file mode 100644 index 000000000..7034d2e80 Binary files /dev/null and b/html/images/sprunk.png differ diff --git a/html/images/sprunklight.png b/html/images/sprunklight.png new file mode 100644 index 000000000..1e3245a35 Binary files /dev/null and b/html/images/sprunklight.png differ diff --git a/html/images/strawberry.png b/html/images/strawberry.png new file mode 100644 index 000000000..aa8316dcb Binary files /dev/null and b/html/images/strawberry.png differ diff --git a/html/images/strawdaquiri.png b/html/images/strawdaquiri.png new file mode 100644 index 000000000..54ca6ae21 Binary files /dev/null and b/html/images/strawdaquiri.png differ diff --git a/html/images/strawmargarita.png b/html/images/strawmargarita.png new file mode 100644 index 000000000..003b97c45 Binary files /dev/null and b/html/images/strawmargarita.png differ diff --git a/html/images/sugar.png b/html/images/sugar.png new file mode 100644 index 000000000..496453ab2 Binary files /dev/null and b/html/images/sugar.png differ diff --git a/html/images/tacos.png b/html/images/tacos.png new file mode 100644 index 000000000..5a7360173 Binary files /dev/null and b/html/images/tacos.png differ diff --git a/html/images/tequila.png b/html/images/tequila.png new file mode 100644 index 000000000..dfb6141cf Binary files /dev/null and b/html/images/tequila.png differ diff --git a/html/images/torpedo.png b/html/images/torpedo.png new file mode 100644 index 000000000..a44343c87 Binary files /dev/null and b/html/images/torpedo.png differ diff --git a/html/images/tots.png b/html/images/tots.png new file mode 100644 index 000000000..581de66ce Binary files /dev/null and b/html/images/tots.png differ diff --git a/html/images/triplesec.png b/html/images/triplesec.png new file mode 100644 index 000000000..b9ebb79fe Binary files /dev/null and b/html/images/triplesec.png differ diff --git a/html/images/vodka.png b/html/images/vodka.png index 302c840ba..23056d876 100644 Binary files a/html/images/vodka.png and b/html/images/vodka.png differ diff --git a/html/images/voodoo.png b/html/images/voodoo.png new file mode 100644 index 000000000..4e1a51e9c Binary files /dev/null and b/html/images/voodoo.png differ diff --git a/html/images/watermelon.png b/html/images/watermelon.png new file mode 100644 index 000000000..81ef27f88 Binary files /dev/null and b/html/images/watermelon.png differ diff --git a/html/images/woowoo.png b/html/images/woowoo.png new file mode 100644 index 000000000..effcd62b1 Binary files /dev/null and b/html/images/woowoo.png differ diff --git a/server/main.lua b/server/main.lua index 3050efe54..cb1400238 100644 --- a/server/main.lua +++ b/server/main.lua @@ -32,7 +32,7 @@ local function LoadInventory(source, citizenid) loadedInventory[item.slot] = { name = itemInfo['name'], amount = item.amount, - info = item.info or '', + info = item.info or itemInfo['info'], label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], @@ -164,7 +164,7 @@ local function AddItem(source, item, amount, slot, info) amount = tonumber(amount) or 1 slot = tonumber(slot) or GetFirstSlotByItem(Player.PlayerData.items, item) - info = info or {} + info = info or itemInfo["info"] if itemInfo['type'] == 'weapon' then info.serie = info.serie or tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4)) @@ -181,8 +181,8 @@ local function AddItem(source, item, amount, slot, info) return true elseif not itemInfo['unique'] and slot or slot and Player.PlayerData.items[slot] == nil then - Player.PlayerData.items[slot] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] } - Player.Functions.SetPlayerData('items', Player.PlayerData.items) + Player.PlayerData.items[slot] = { name = itemInfo['name'], amount = amount, info = info or itemInfo["info"], label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] } + Player.Functions.SetPlayerData("items", Player.PlayerData.items) if Player.Offline then return true end @@ -192,8 +192,8 @@ local function AddItem(source, item, amount, slot, info) elseif itemInfo['unique'] or (not slot or slot == nil) or itemInfo['type'] == 'weapon' then for i = 1, Config.MaxInventorySlots, 1 do if Player.PlayerData.items[i] == nil then - Player.PlayerData.items[i] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = i, combinable = itemInfo['combinable'] } - Player.Functions.SetPlayerData('items', Player.PlayerData.items) + Player.PlayerData.items[i] = { name = itemInfo['name'], amount = amount, info = info or itemInfo["info"], label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = i, combinable = itemInfo['combinable'] } + Player.Functions.SetPlayerData("items", Player.PlayerData.items) if Player.Offline then return true end @@ -610,14 +610,14 @@ local function AddToStash(stashId, slot, otherslot, itemName, amount, info) Stashes[stashId].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, } end @@ -627,14 +627,14 @@ local function AddToStash(stashId, slot, otherslot, itemName, amount, info) Stashes[stashId].items[otherslot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = otherslot, } else @@ -642,14 +642,14 @@ local function AddToStash(stashId, slot, otherslot, itemName, amount, info) Stashes[stashId].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, } end @@ -694,20 +694,26 @@ local function GetOwnedVehicleItems(plate) items[item.slot] = { name = itemInfo['name'], amount = tonumber(item.amount), - info = item.info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = item.info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = item.slot, } end end return items end +exports('GetOwnedVehicleItems', GetOwnedVehicleItems) +exports('GetUnownedVehicleItems', function(plate) + if not plate then return {} end + if Trunks[plate] then return Trunks[plate].items end + return {} +end) ---Save the items in a trunk ---@param plate string The plate to save the items from @@ -739,28 +745,50 @@ local function AddToTrunk(plate, slot, otherslot, itemName, amount, info) local ItemData = QBCore.Shared.Items[itemName] if not ItemData.unique then - if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then - Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount + amount + if Trunks[plate].items[slot] then + if Trunks[plate].items[slot].name == itemName then + Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount + amount + else + return false, "Slot Occupied" + end else local itemInfo = QBCore.Shared.Items[itemName:lower()] Trunks[plate].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, } end else - if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then - local itemInfo = QBCore.Shared.Items[itemName:lower()] - Trunks[plate].items[otherslot] = { + if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then + if otherslot > 0 then + local itemInfo = QBCore.Shared.Items[itemName:lower()] + Trunks[plate].items[otherslot] = { + name = itemInfo["name"], + amount = amount, + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], + slot = otherslot, + } + else + return false, "OtherSlot not specified" + end + local itemInfo = QBCore.Shared.Items[itemName:lower()] + Trunks[plate].items[otherslot] = { name = itemInfo['name'], amount = amount, info = info or '', @@ -773,37 +801,50 @@ local function AddToTrunk(plate, slot, otherslot, itemName, amount, info) image = itemInfo['image'], slot = otherslot, } - else - local itemInfo = QBCore.Shared.Items[itemName:lower()] - Trunks[plate].items[slot] = { + else + local itemInfo = QBCore.Shared.Items[itemName:lower()] + Trunks[plate].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, - } - end + } + end end + return true, "OK" end +exports('AddItemToTrunk', AddToTrunk) ---Remove the item from the trunk ---@param plate string plate of the car to remove the item from ---@param slot number Slot to remove the item from ---@param itemName string Name of the item to remove ---@param amount? number The amount to remove +---@return number The number of items remaining. Negative indicates error. local function RemoveFromTrunk(plate, slot, itemName, amount) amount = tonumber(amount) or 1 - if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then - if Trunks[plate].items[slot].amount > amount then - Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount - amount + if Trunks[plate].items[slot] then + if Trunks[plate].items[slot].name == itemName then + if Trunks[plate].items[slot].amount >= amount then + Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount - amount + if (Trunks[plate].items[slot].amount < 1) then + Trunks[plate].items[slot] = nil + return 0, "OK" + end + return Trunks[plate].items[slot].amount + else + Trunks[plate].items[slot] = nil + return 0, "OK" + end else - Trunks[plate].items[slot] = nil + return -1, "Mismatched Item" end else Trunks[plate].items[slot] = nil @@ -811,7 +852,9 @@ local function RemoveFromTrunk(plate, slot, itemName, amount) Trunks[plate].items[slot] = nil end end + return -1, "Item NonExist" end +exports('RemoveItemFromTrunk', RemoveFromTrunk) ---Get the items in the glovebox of a vehicle ---@param plate string The plate of the vehicle to check @@ -830,20 +873,26 @@ local function GetOwnedVehicleGloveboxItems(plate) items[item.slot] = { name = itemInfo['name'], amount = tonumber(item.amount), - info = item.info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = item.info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = item.slot, } end end return items end +exports('GetOwnedVehicleGloveboxItems', GetOwnedVehicleGloveboxItems) +exports('GetUnownedVehicleGloveboxItems', function(plate) + if not plate then return {} end + if Gloveboxes[plate] then return Gloveboxes[plate].items end + return {} +end) ---Save the items in a glovebox ---@param plate string The plate to save the items from @@ -882,14 +931,14 @@ local function AddToGlovebox(plate, slot, otherslot, itemName, amount, info) Gloveboxes[plate].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, } end @@ -899,14 +948,14 @@ local function AddToGlovebox(plate, slot, otherslot, itemName, amount, info) Gloveboxes[plate].items[otherslot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = otherslot, } else @@ -914,14 +963,14 @@ local function AddToGlovebox(plate, slot, otherslot, itemName, amount, info) Gloveboxes[plate].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, } end @@ -965,14 +1014,14 @@ local function AddToDrop(dropId, slot, itemName, amount, info) Drops[dropId].items[slot] = { name = itemInfo['name'], amount = amount, - info = info or '', - label = itemInfo['label'], - description = itemInfo['description'] or '', - weight = itemInfo['weight'], - type = itemInfo['type'], - unique = itemInfo['unique'], - useable = itemInfo['useable'], - image = itemInfo['image'], + info = info or itemInfo["info"], + label = itemInfo["label"], + description = itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], slot = slot, id = dropId, } @@ -1353,11 +1402,53 @@ RegisterNetEvent('QBCore:Server:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end) +-- Returns the first empty slot in the vehicle trunk +local function GetFirstEmptyTrunkSlot(vehicleClass, plate) + if not vehicleClass then vehicleClass = 'default' end + if not plate then return -2 end -- Indicates error with the plate number + if not Trunks[plate] then Trunks[plate] = {label = "Trunk-"..plate, items = {}} end + local trunkSize = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace['default'] + local maxSlots = trunkSize.slots or 0 + local slotUsed = {} + -- Sets all used slots to TRUE + for k,v in pairs (Trunks[plate].items) do + if v.slot then + slotUsed[tostring(v.slot)] = true + end + end + -- Returns on the first FALSE slot + for i = 1, maxSlots do + if not slotUsed[tostring(i)] and i <= maxSlots then + return i + end + end + return 0 -- Indicates that the Inventory is Full +end +exports('GetFirstEmptyTrunkSlot', GetFirstEmptyTrunkSlot) + +-- Returns the first slot containing the same item +local function GetFirstMatchingTrunkSlot(vehicleClass, plate, item) + if not plate then return -3 end -- Indicates there is a problem with the plate + if not item then return -2 end -- Indicates error with the item name + if QBCore.Shared.Items[item] then + if not Trunks[plate] then Trunks[plate] = {label = "Trunk-"..plate, items = {}} end + for itemName,itemData in pairs (Trunks[plate].items) do + if itemData.unique then break end + if itemData.name == item then + return itemData.slot + end + end + -- Item not found, return first empty slot + return GetFirstEmptyTrunkSlot(vehicleClass, plate) + end + return -1 -- Indicates the requested item or inventory does not exist +end +exports('GetFirstMatchingTrunkSlot', GetFirstMatchingTrunkSlot) + function addTrunkItems(plate, items) Trunks[plate] = {} Trunks[plate].items = items end - exports('addTrunkItems', addTrunkItems) function addGloveboxItems(plate, items)