From f0324ca2e098ae0161b8db81b750585c55a39f55 Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:20:25 +0200 Subject: [PATCH 1/5] Create qb.md --- docs/ox_inventory/Getting Started/qb.md | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/ox_inventory/Getting Started/qb.md diff --git a/docs/ox_inventory/Getting Started/qb.md b/docs/ox_inventory/Getting Started/qb.md new file mode 100644 index 00000000..1f0aca8f --- /dev/null +++ b/docs/ox_inventory/Getting Started/qb.md @@ -0,0 +1,52 @@ +# QBCore + +Ox Inventory provides a complete suite of tools to replace the built-in items and inventory system from QBCore, and is not intended to be used with resources designed around it. + +- Stashes from resources such as qb-policejob, qb-ambulancejob, etc. should be removed, they are not compatible +- qb-inventory should be removed for optimal compatibility, if you didn't remove it, qb-core will not function properly and will show errors. +- qb-shops and qb-weapons automatically get stopped by Ox Inventory, so you don't have to worry about those, just don't start them manually after as they will conflict. + +## Optional optimisation + +All item related functions from Player, such as `xPlayer.Functions.GetItemByName`, have been modified for compatibility purposes; however they are considered deprecated. + +The reasoning is fairly simple - there's now additional function references and overhead to consider. Fortunately, the new Inventory functions can be used directly and offer a great deal of improvements over the old ones. + +You should read through the functions section for further information, but the following should give you a decent idea. + + + + +```lua +local acetone = Player.Functions.GetItemByName('acetone') +local antifreeze = Player.Functions.GetItemByName('antifreeze') +local sudo = Player.Functions.GetItemByName('sudo') +if acetone?.amount > 2 and antifreeze?.amount > 4 and sudo?.amount > 9 then + Player.Functions.RemoveItem("acetone", 3) + Player.Functions.RemoveItem("antifreeze", 5) + Player.Functions.RemoveItem("sudo", 10) +end +``` + + + + +Add the following code somewhere in your resource to cache the exports metatable. + +```lua +local ox_inventory = exports.ox_inventory +``` + +You will be able to reference any functions exposed through the export. + +```lua +local items = ox_inventory:Search(source, 'count', {'acetone', 'antifreeze', 'sudo'}) +if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then + ox_inventory:RemoveItem(source, 'acetone', 3) + ox_inventory:RemoveItem(source, 'antifreeze', 5) + ox_inventory:RemoveItem(source, 'sudo', 10) +end +``` + + + From 6642cea9c4e69786de411c38e2fc7fc7ef74da7e Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:32:15 +0200 Subject: [PATCH 2/5] feat: qb conversion --- docs/ox_inventory/Getting Started/index.md | 45 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/docs/ox_inventory/Getting Started/index.md b/docs/ox_inventory/Getting Started/index.md index 88abe2aa..7b923be4 100644 --- a/docs/ox_inventory/Getting Started/index.md +++ b/docs/ox_inventory/Getting Started/index.md @@ -133,7 +133,7 @@ You can compile it youself by following the [build guide](./Guides/inventory_ui) Use a compatible version of [ESX Legacy](https://github.com/esx-framework/esx-legacy) (1.6.0+) -Execute the query inside [install.sql](https://github.com/overextended/ox_inventory/blob/main/setup/install.sql) and [vehicle.sql](https://github.com/overextended/ox_inventory/blob/main/setup/vehicle.sql) +Execute the query inside [install.sql](https://github.com/overextended/ox_inventory/blob/main/setup/install.sql) Start order should look like the following: @@ -150,9 +150,8 @@ start ox_inventory Use a compatible version of [ESX Legacy](https://github.com/esx-framework/esx-legacy) (1.6.0+) Execute the query inside [install.sql](https://github.com/overextended/ox_inventory/blob/main/setup/install.sql) -and [vehicle.sql](https://github.com/overextended/ox_inventory/blob/main/setup/vehicle.sql) Open `fxmanifest.lua` and uncomment `server_script 'setup/convert.lua'` -Start the server and execute the `convertinventory` command from the console +Start the server and execute the `convertinventory esx` command from the console Remove the conversion file Start order should look like the following: @@ -162,7 +161,42 @@ start oxmysql start es_extended start ox_lib start ox_inventory -everything else +... +``` + + + + +Use the latest source code of [qb-core](https://github.com/qbcore-framework/qb-core) +To disable the weapon animation of qb-smallresources, use the latest source code of [qb-smallresources](https://github.com/qbcore-framework/qb-smallresources) (it will only disable if qb-inventory is **not** present inside the resources folder) +Execute the query inside [install.sql](https://github.com/overextended/ox_inventory/blob/main/setup/install.sql) + +Start order should look like the following: + +``` +start oxmysql +start qb-core +start ox_lib +start ox_inventory +... +``` + + + + +Use the latest source code of [qb-core](https://github.com/qbcore-framework/qb-core) +Execute the query inside [install.sql](https://github.com/overextended/ox_inventory/blob/main/setup/install.sql) +Open `fxmanifest.lua` and uncomment `server_script 'setup/convert.lua'` +Start the server and execute the `convertinventory qb` command from the console +Remove the conversion file + +Start order should look like the following: + +``` +start oxmysql +start qb-core +start ox_lib +start ox_inventory ... ``` @@ -170,9 +204,8 @@ everything else Execute the query inside [upgrade.sql](https://github.com/overextended/ox_inventory/blob/main/setup/upgrade.sql) -and [vehicle.sql](https://github.com/overextended/ox_inventory/blob/main/setup/vehicle.sql) Open `fxmanifest.lua` and uncomment `server_script 'setup/convert.lua'` -Start the server and execute the `convertinventory` linden command from the console +Start the server and execute the `convertinventory linden` command from the console Remove the conversion file From 91ac1ab40672a13fd142aef13d06b26024804612 Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:34:07 +0200 Subject: [PATCH 3/5] feat: qb conversion for item registration --- docs/ox_inventory/Guides/creatingItems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ox_inventory/Guides/creatingItems.md b/docs/ox_inventory/Guides/creatingItems.md index 33d5a023..38948fc5 100644 --- a/docs/ox_inventory/Guides/creatingItems.md +++ b/docs/ox_inventory/Guides/creatingItems.md @@ -147,7 +147,7 @@ A modified burger item, which gives you notifications on add and remove argument ## Making the item usable -If you are using ESX you can continue using `ESX.RegisterUsableItem` if desired. +If you are using ESX you can continue using `ESX.RegisterUsableItem` (for QBCore that is `QBCore.Functions.CreateUseableItem`) if desired. Using the built-in system is more secure and provides simple progressbar support. An item will be usable when client variables are added to [data/items.lua](https://github.com/overextended/ox_inventory/blob/main/data/items.lua), or has a registered item callback. Item callbacks can be added by defining an export (recommended), or by adding it to [items/client.lua](https://github.com/overextended/ox_inventory/blob/main/modules/items/client.lua#L33). From 5e857372b97fd864f78a094cfbfa3fe3012d3827 Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:37:35 +0200 Subject: [PATCH 4/5] feat(ClearInventory): keep argument --- .../Functions/Server/Inventory/ClearInventory.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md index 312ff72b..78c1ac81 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md +++ b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md @@ -1,11 +1,7 @@ -Clears the specified inventory. +Clears the specified inventory. The `keep` argument is either a string or an array of strings containing the name(s) of the item(s) to keep in the inventory after clearing. ```lua -- inv: string or number --- keep: nil +-- keep:? string or string[] exports.ox_inventory:ClearInventory(inv, keep) ``` -:::caution - -The `keep` argument is still unsupported and won't do anyting. -::: \ No newline at end of file From 198212095be54ad3b3f777dff0f12a672257718f Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:40:08 +0200 Subject: [PATCH 5/5] feat(ox_inventory/config): qb framework type --- docs/ox_inventory/config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ox_inventory/config.md b/docs/ox_inventory/config.md index e9f48c50..a64b4458 100644 --- a/docs/ox_inventory/config.md +++ b/docs/ox_inventory/config.md @@ -14,7 +14,7 @@ Convars **must** be set before starting ox_inventory. The values below are _defaults_ and should not be explicitly set unless changing the value. ```yml -# Activate specific event handlers and functions (supported: ox, esx) +# Activate specific event handlers and functions (supported: ox, esx, qb) setr inventory:framework "esx" # Load specific language file from data/locales @@ -23,7 +23,7 @@ setr inventory:locale "en" # Number of slots for player inventories setr inventory:slots 50 -# Maximum carry capacity for players, in kilograms +# Maximum carry capacity for players, in grams (will be automatically converted to kilograms in-game) setr inventory:weight 30000 # Weapons will reload after reaching 0 ammo