diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..99e226f1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true +indent_size = 2 +indent_style = space \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/Interface/Keyboard.md b/docs/ox_inventory/Functions/Client/Interface/Keyboard.md deleted file mode 100644 index a509b48a..00000000 --- a/docs/ox_inventory/Functions/Client/Interface/Keyboard.md +++ /dev/null @@ -1,24 +0,0 @@ -Opens a keyboard input dialog. - -The `rows` param takes a table of strings where each string entry will represent -a single row. - -```lua --- header: string --- rows: table -exports.ox_inventory:Keyboard(header, rows) -``` -Returns a table of strings where the first index is going to be the first row of the dialog, -the second index the second row and so on. - -**Example:** -```lua -local input = exports.ox_inventory:Keyboard('Money transfer', {'Player name', 'Amount'}) - -if input then - local playerName = input[1] - local amount = tonumber(input[2]) - - if not playerName or not amount then return end -end -``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/Interface/Progress.md b/docs/ox_inventory/Functions/Client/Interface/Progress.md deleted file mode 100644 index 8f0e34d3..00000000 --- a/docs/ox_inventory/Functions/Client/Interface/Progress.md +++ /dev/null @@ -1,78 +0,0 @@ -Starts a progress bar that can callback a function upon completion or cancellation. - -Prevents actions such as opening the inventory, reloading, etc. - -```lua --- options: table --- completed: function -exports.ox_inventory:Progress(options, completed) -``` -Options table values: -```lua --- duration: number --- label: string --- useWhileDead: boolean (optional) --- canCancel: boolean (optional) --- anim: table (optional) - -- dict: string - -- clip: string - -- flag: number (optional - default is 49) --- scenario: string (optional) --- prop/propTwo: table (optional) - -- model: hash or string - -- bone: number (optional - default is 60309) - -- pos: vector3 (optional) - -- rot: vector3 (optional) --- disable: table (optional) - -- move: boolean (optional) - -- car: boolean (optional) - -- combat: boolean (optional) - -- mouse: boolean (optional) -``` -:::danger - -If you define a scenario while you have a defined anim table the scenario will be ignored. -::: - -**Example:** -```lua -exports.ox_inventory:Progress({ - duration = 2000, - label = 'Drinking water', - useWhileDead = false, - canCancel = true, - disable = { - car = true - }, - anim = { - dict = 'mp_player_intdrink', - clip = 'loop_bottle', - flag = 49, - }, - prop = { - model = 'prop_ld_flow_bottle', - pos = vector3(0.03, 0.03, 0.02), - rot = vector3(0.0, 0.0, -1.5), - bone = 58866 - }, -}, function(cancel) - if not cancel then - print("You drank some water - that'll quench ya!") - end -end) -``` - -### CancelProgress - -Cancels the currently active progress bar. - -```lua -exports.ox_inventory:CancelProgress() -``` - -### ProgressActive -Returns true or false whether the progress bar is currently active or not - -```lua -exports.ox_inventory:ProgressActive() -``` diff --git a/docs/ox_inventory/Functions/Client/Items.md b/docs/ox_inventory/Functions/Client/Items.md index f59aad15..50d48232 100644 --- a/docs/ox_inventory/Functions/Client/Items.md +++ b/docs/ox_inventory/Functions/Client/Items.md @@ -10,6 +10,6 @@ The following snippet can be used in crafting resources such as okokCrafting or local itemNames = {} for item, data in pairs(exports.ox_inventory:Items()) do - itemNames[item] = data.label + itemNames[item] = data.label end ``` \ No newline at end of file diff --git a/docs/ox_inventory/Guides/creatingItems.md b/docs/ox_inventory/Guides/creatingItems.md index b6d054f8..f35d7adc 100644 --- a/docs/ox_inventory/Guides/creatingItems.md +++ b/docs/ox_inventory/Guides/creatingItems.md @@ -157,24 +157,24 @@ The correct formatting is `export = resourceName.exportName`. ```lua exports('bandage', function(data, slot) - local playerPed = PlayerPedId() - local maxHealth = GetEntityMaxHealth(playerPed) - local health = GetEntityHealth(playerPed) + local playerPed = PlayerPedId() + local maxHealth = GetEntityMaxHealth(playerPed) + local health = GetEntityHealth(playerPed) - -- Does the ped need to heal? - if health < maxHealth then - -- Use the bandage - exports.ox_inventory:useItem(data, function(data) - -- The item has been used, so trigger the effects - if data then - SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16))) - exports.ox_inventory:notify({text = 'You feel better already'}) - end - end) - else - -- Don't use the item - exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'}) - end + -- Does the ped need to heal? + if health < maxHealth then + -- Use the bandage + exports.ox_inventory:useItem(data, function(data) + -- The item has been used, so trigger the effects + if data then + SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16))) + exports.ox_inventory:notify({text = 'You feel better already'}) + end + end) + else + -- Don't use the item + exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'}) + end end) ``` @@ -187,23 +187,23 @@ This can either be an export (recommended), or added to [items/server.lua](https ```lua exports('bandage', function(event, item, inventory, slot, data) if event == 'usingItem' then - local playerPed = GetPlayerPed(inventory.source) - local maxHealth = GetEntityMaxHealth(playerPed) - local health = GetEntityHealth(playerPed) + local playerPed = GetPlayerPed(inventory.source) + local maxHealth = GetEntityMaxHealth(playerPed) + local health = GetEntityHealth(playerPed) if health >= maxHealth then - TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\'t need a bandage right now'}) + TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\'t need a bandage right now'}) - -- Returning 'false' will prevent the item from being used + -- Returning 'false' will prevent the item from being used return false end - return + return elseif event == 'usedItem' then - return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'}) + return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'}) elseif event == 'buying' then - return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'}) + return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'}) end end) ``` diff --git a/docs/ox_inventory/Guides/stashes.md b/docs/ox_inventory/Guides/stashes.md index 495e3716..660116f8 100644 --- a/docs/ox_inventory/Guides/stashes.md +++ b/docs/ox_inventory/Guides/stashes.md @@ -14,8 +14,8 @@ We can set up custom stashes from outside the resource utilising the exported Re -- weight: number -- owner: string or boolean (optional) -- groups: table (optional) - -- name: string - -- grade: number + -- name: string + -- grade: number -- coords: vector or table (optional) ``` @@ -40,17 +40,17 @@ Below the value is hardset, but it could be loaded from the database (especially ```lua -- Server local stash = { - id = '42wallabyway', - label = '42 Wallaby Way', - slots = 50, - weight = 100000, - owner = 'char1:license' + id = '42wallabyway', + label = '42 Wallaby Way', + slots = 50, + weight = 100000, + owner = 'char1:license' } AddEventHandler('onServerResourceStart', function(resourceName) - if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName() then - exports.ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner) - end + if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName() then + exports.ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner) + end end) -- Client @@ -63,23 +63,23 @@ The following sample is based on esx_property's db data. local properties MySQL.query('SELECT * FROM `properties`', {}, function(result) - properties = result + properties = result end RegisterNetEvent('ox:loadStashes', function(id) local stash = properties[id] - if stash then - -- id: 1, name: WhispymoundDrive, label: 2677 Whispymound Drive, coords: {"x":118.748,"y":566.573,"z":175.697} - ox_inventory:RegisterStash(stash.name, stash.label, 50, 100000, true, false, json.encode(stash.room_menu)) - end + if stash then + -- id: 1, name: WhispymoundDrive, label: 2677 Whispymound Drive, coords: {"x":118.748,"y":566.573,"z":175.697} + ox_inventory:RegisterStash(stash.name, stash.label, 50, 100000, true, false, json.encode(stash.room_menu)) + end end) -- Client local ox_inventory = exports.ox_inventory if ox_inventory:openInventory('stash', property.id) == false then - TriggerServerEvent('ox:loadStashes') - ox_inventory:openInventory('stash', property.id) + TriggerServerEvent('ox:loadStashes') + ox_inventory:openInventory('stash', property.id) end ``` @@ -88,7 +88,7 @@ end We put together an example resource showcasing how to properly utilise the stash API:
diff --git a/docs/ox_inventory/config.md b/docs/ox_inventory/config.md index bbbfa28b..233da994 100644 --- a/docs/ox_inventory/config.md +++ b/docs/ox_inventory/config.md @@ -1,6 +1,6 @@ # Configuration -You can add these settings directly to your 'server.cfg', or add them to a separate file and call it with `exec`. +You can add these settings directly to your 'server.cfg', or add them to a separate file (i.e. inventory.cfg) and call it with `exec`. :::caution @@ -88,8 +88,4 @@ set datadog:site "datadoghq.com" # Set server hostname set datadog:hostname "FXServer" - -add_principal group.admin ox_inventory -add_ace resource.ox_inventory command.add_principal allow -add_ace resource.ox_inventory command.remove_principal allow ``` diff --git a/docs/ox_inventory/index.md b/docs/ox_inventory/index.md index 73bd6eab..ac989fe9 100644 --- a/docs/ox_inventory/index.md +++ b/docs/ox_inventory/index.md @@ -37,15 +37,15 @@ We provide full backwards compatibility with mysql-async and build for the curre ### Ox Lib -A resource designed to provide reusable functions that can be loaded into any resource with simple variable declarations rather than through fxmanifest. +Provides easily reusable functions that can be imported into your resource or called with exports. -**Currently used for:** +**Used in the inventory for** - SetInterval - Server Callbacks -- Table utilities (contains, matches) - Requesting models, animations, etc. -- Disabling control actions +- Marker management +- Notifications and progress bar