From 724c7e356d4fc710e17c21ec46eaa360dd41ca14 Mon Sep 17 00:00:00 2001 From: DokaDoka Date: Sun, 11 Dec 2022 15:00:43 +1100 Subject: [PATCH] formatting and typos --- docs/index.md | 2 +- docs/ox_core/Getting Started/concepts.md | 2 +- docs/ox_core/Getting Started/config.md | 4 +- docs/ox_core/Getting Started/imports.md | 10 +-- docs/ox_core/Getting Started/index.md | 8 +-- docs/ox_core/Player/Client/events.md | 2 - docs/ox_core/Player/Server/events.md | 2 +- docs/ox_core/Player/Server/methods.md | 6 +- docs/ox_core/Vehicle/Server/callbacks.md | 1 - docs/ox_core/Vehicle/Server/index.md | 5 +- docs/ox_core/Vehicle/Server/methods.md | 2 +- .../Functions/Client/Inventory/Search.md | 1 + docs/ox_inventory/Functions/Client/Items.md | 4 +- .../Functions/Client/Statebags/invBusy.md | 4 +- .../Functions/Client/Statebags/invOpen.md | 4 +- .../Functions/Client/Utils/weaponWheel.md | 1 + .../Functions/Client/displayMetadata.md | 2 + .../Functions/Client/openInventory.md | 1 + .../Functions/Client/setStashTarget.md | 1 + docs/ox_inventory/Functions/Client/useItem.md | 3 +- docs/ox_inventory/Functions/Client/useSlot.md | 1 + docs/ox_inventory/Functions/Server/Hooks.md | 2 +- .../Functions/Server/Inventory/AddItem.md | 1 + .../Server/Inventory/CanCarryAmount.md | 1 + .../Server/Inventory/CanCarryItem.md | 2 + .../Server/Inventory/CanCarryWeight.md | 1 + .../Functions/Server/Inventory/CanSwapItem.md | 1 + .../Server/Inventory/ClearInventory.md | 1 + .../Server/Inventory/ConfiscateInventory.md | 1 + .../Server/Inventory/ConvertItems.md | 9 ++- .../Functions/Server/Inventory/CustomDrop.md | 1 + .../Server/Inventory/GetCurrentWeapon.md | 1 + .../Server/Inventory/GetInventory.md | 18 +++--- .../Server/Inventory/GetInventoryItems.md | 2 + .../Functions/Server/Inventory/GetItem.md | 2 + .../Server/Inventory/GetItemSlots.md | 1 + .../Functions/Server/Inventory/GetSlot.md | 18 +++--- .../Server/Inventory/RegisterStash.md | 7 ++- .../Server/Inventory/ReturnInventory.md | 1 + .../Functions/Server/Inventory/Search.md | 2 +- .../Server/Inventory/SetDurability.md | 2 + .../Functions/Server/Inventory/SetMetadata.md | 3 + .../Functions/Server/Inventory/SwapSlots.md | 1 + docs/ox_inventory/Functions/Server/Items.md | 4 +- .../Functions/Server/setPlayerInventory.md | 1 + docs/ox_inventory/Getting Started/config.md | 2 +- docs/ox_inventory/Getting Started/index.md | 18 +++--- docs/ox_inventory/Getting Started/issues.md | 8 +-- docs/ox_inventory/Guides/crafting.md | 62 +++++++++---------- docs/ox_inventory/Guides/creatingItems.md | 24 +++---- docs/ox_inventory/Guides/index.md | 2 +- docs/ox_inventory/Guides/shops.md | 2 + docs/ox_inventory/Guides/stashes.md | 2 + docs/ox_lib/ACL/Server.md | 26 +++++--- docs/ox_lib/AddCommand/Server.md | 1 + docs/ox_lib/AddKeybind/Client.md | 4 +- docs/ox_lib/Cache/Client.md | 2 +- docs/ox_lib/Callback/Client.md | 4 +- docs/ox_lib/DisableControls/Client.md | 8 +++ docs/ox_lib/GetClosestPlayer/Client.md | 2 + docs/ox_lib/GetClosestVehicle/Client.md | 1 + docs/ox_lib/GetNearbyPlayers/Client.md | 2 + docs/ox_lib/GetNearbyVehicles/Client.md | 2 + docs/ox_lib/Interface/Client/alert.md | 10 ++- docs/ox_lib/Interface/Client/clipboard.md | 2 + docs/ox_lib/Interface/Client/context.md | 30 ++++++--- docs/ox_lib/Interface/Client/input.md | 35 ++++++----- docs/ox_lib/Interface/Client/menu.md | 29 ++++++--- docs/ox_lib/Interface/Client/notify.md | 22 +++++-- docs/ox_lib/Interface/Client/progress.md | 32 +++++++--- docs/ox_lib/Interface/Client/skillcheck.md | 8 ++- docs/ox_lib/Interface/Client/textui.md | 21 ++++--- docs/ox_lib/Locale/Shared.md | 13 ++-- docs/ox_lib/Logger/Server.md | 26 ++++---- docs/ox_lib/Points/Client.md | 4 +- docs/ox_lib/Raycast/Client.md | 2 + docs/ox_lib/Streaming/Client.md | 17 +++-- docs/ox_lib/VehicleProperties/Client.md | 15 +++-- docs/ox_lib/Version/Server.md | 6 +- docs/ox_lib/Version/Shared.md | 6 +- docs/ox_lib/Zones/Client.md | 32 +++++----- docs/ox_lib/index.md | 21 ++++--- docs/ox_target/Getting Started/index.md | 2 +- docs/ox_target/Usage/Globals.md | 2 +- docs/ox_target/Usage/Target.md | 7 +-- docs/ox_target/Usage/Zones.md | 22 +++---- docs/ox_target/Usage/index.md | 44 ++++++------- docs/oxmysql/Getting Started/benchmark.md | 14 +++-- docs/oxmysql/Getting Started/index.md | 22 +++---- docs/oxmysql/Getting Started/issues.md | 7 ++- docs/oxmysql/Getting Started/placeholders.md | 2 +- docs/oxmysql/Usage/index.md | 6 +- docs/oxmysql/Usage/insert.md | 4 ++ docs/oxmysql/Usage/prepare.md | 10 ++- docs/oxmysql/Usage/query.md | 9 ++- docs/oxmysql/Usage/scalar.md | 5 ++ docs/oxmysql/Usage/single.md | 5 ++ docs/oxmysql/Usage/transaction.md | 2 +- docs/oxmysql/Usage/update.md | 5 ++ 99 files changed, 515 insertions(+), 305 deletions(-) diff --git a/docs/index.md b/docs/index.md index c3a9ce6c..5a2d2925 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,7 +9,7 @@ and click the "Edit this page" at the bottom and submit a Pull Request. ## Support our team -Our projects will always remain free and open-source, with our core developers working voluntarily. +Our projects will always remain free and open-source, with our core developers working voluntarily. If you love what we do and want to help us continue, why not show your appreciation with a donation?
diff --git a/docs/ox_core/Getting Started/concepts.md b/docs/ox_core/Getting Started/concepts.md index 0350aa3e..2a723895 100644 --- a/docs/ox_core/Getting Started/concepts.md +++ b/docs/ox_core/Getting Started/concepts.md @@ -4,7 +4,7 @@ We'll try to explain some technical but core concepts used in ox_core here. ## Classes -Lua doesn't have support for true clases, but rather prototype-based inheritance. +Lua doesn't have support for true classes, but rather prototype-based inheritance. A prototype can hold its own variables and methods, which another object (an instance) can reference or call. ```lua diff --git a/docs/ox_core/Getting Started/config.md b/docs/ox_core/Getting Started/config.md index 59da8efe..b3014550 100644 --- a/docs/ox_core/Getting Started/config.md +++ b/docs/ox_core/Getting Started/config.md @@ -1,8 +1,8 @@ # Config -Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/). +Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/). -```yml +```yaml # Players must have a valid identifier to join the server. Used to fetch userid from the database. set ox:primaryIdentifier "fivem" diff --git a/docs/ox_core/Getting Started/imports.md b/docs/ox_core/Getting Started/imports.md index cd056fda..6cb9a137 100644 --- a/docs/ox_core/Getting Started/imports.md +++ b/docs/ox_core/Getting Started/imports.md @@ -14,14 +14,14 @@ Lua imports can be defined as part of fxmanifest, or loaded with the load functi ```lua client_scripts { - '@ox_core/imports/client.lua', - 'client/main.lua', + '@ox_core/imports/client.lua', + 'client/main.lua', } server_scripts { - '@oxmysql/lib/MySQL.lua', - '@ox_core/imports/server.lua', - 'server/main.lua', + '@oxmysql/lib/MySQL.lua', + '@ox_core/imports/server.lua', + 'server/main.lua', } ``` diff --git a/docs/ox_core/Getting Started/index.md b/docs/ox_core/Getting Started/index.md index 62e70b2d..199d33aa 100644 --- a/docs/ox_core/Getting Started/index.md +++ b/docs/ox_core/Getting Started/index.md @@ -10,12 +10,12 @@ import TabItem from '@theme/TabItem'; :::caution -This resource is **not production ready**. Breaking changes are guaranteed, and support is limited. +This resource is **not production ready**. Breaking changes are guaranteed, and support is limited. Documentation may fall behind and be rendered obsolete. ::: -We **strongly** recommend using Git to help with version control and separating your own changes from the original source code. +We **strongly** recommend using Git to help with version control and separating your own changes from the original source code. Refer to [GitHub's guide to setting up Git](https://docs.github.com/en/get-started/quickstart/set-up-git#setting-up-git). You can also download a Git GUI client, such as [GitKraken](https://www.gitkraken.com/), to improve your workflow and more easily maintain changes. @@ -38,7 +38,7 @@ These resources are required for ox_core to function, and must start before it. - Open a terminal, command prompt, etc. and navigate to your resources folder. - Execute the following commands -``` +```bash npm install --location=global pnpm git clone https://github.com/overextended/ox_core.git cd web @@ -72,7 +72,7 @@ Phone with many built-in apps such as Twitter, Marketplace, and Notes; with supp ### pefcl -Banking and financing, with support for multiple, unique, and shared accounts. +Banking and financing, with support for multiple, unique, and shared accounts. If using it with [ox_inventory](https://github.com/overextended/ox_inventory), open `pefcl/config.json` and enable framework integration. ```json diff --git a/docs/ox_core/Player/Client/events.md b/docs/ox_core/Player/Client/events.md index 70323d93..2832081e 100644 --- a/docs/ox_core/Player/Client/events.md +++ b/docs/ox_core/Player/Client/events.md @@ -38,8 +38,6 @@ Triggered when the player's grade in a group is modified on the server with `pla RegisterNetEvent('ox:setGroup', function(source, group, grade) end) ``` - - ### ox:licenseAdded Triggered when the player has been granted a license. diff --git a/docs/ox_core/Player/Server/events.md b/docs/ox_core/Player/Server/events.md index 39c38be3..543c274e 100644 --- a/docs/ox_core/Player/Server/events.md +++ b/docs/ox_core/Player/Server/events.md @@ -44,7 +44,7 @@ Triggered when a player has been granted a license. AddEventHandler('ox:licenseAdded', function(source, name) end) ``` -### ox:licenseAdded +### ox:licenseRemoved Triggered when a player's license is revoked. diff --git a/docs/ox_core/Player/Server/methods.md b/docs/ox_core/Player/Server/methods.md index db2a5b42..86c17aee 100644 --- a/docs/ox_core/Player/Server/methods.md +++ b/docs/ox_core/Player/Server/methods.md @@ -21,7 +21,7 @@ player.set(key, value, replicated) ## player.setdb -Update the player's metadata and store in the DB, optionally syncing it with the client. +Update the player's metadata and store in the DB, optionally syncing it with the client. Note: These values are not synced to the client on login; you will need to use `player.set`. ```lua @@ -77,7 +77,7 @@ Returns the player's current grade for a given group. player.getGroup() ``` -## player.getGroup +## player.getGroups Returns an object of all groups the player is in, with the current grade as the value. @@ -87,7 +87,7 @@ player.getGroups() ## player.hasGroup -Check if the player is a member of a given group, and returns the matching group name and grade. +Check if the player is a member of a given group, and returns the matching group name and grade. The filter can be a string, array, or object where key is the group, and value is the minimum grade. ```lua diff --git a/docs/ox_core/Vehicle/Server/callbacks.md b/docs/ox_core/Vehicle/Server/callbacks.md index 4d222437..ed98269b 100644 --- a/docs/ox_core/Vehicle/Server/callbacks.md +++ b/docs/ox_core/Vehicle/Server/callbacks.md @@ -12,4 +12,3 @@ lib.callback.await('ox:getNearbyVehicles', playerId, radius) - playerId: `number` - radius?: `number` - diff --git a/docs/ox_core/Vehicle/Server/index.md b/docs/ox_core/Vehicle/Server/index.md index 360e0cc9..d2e053c1 100644 --- a/docs/ox_core/Vehicle/Server/index.md +++ b/docs/ox_core/Vehicle/Server/index.md @@ -27,7 +27,7 @@ end ## Ox.CreateVehicle -Spawns a vehicle and returns the instance of CVehicle. +Spawns a vehicle and returns the instance of CVehicle. If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id. ```lua @@ -43,8 +43,9 @@ if vehicleId then end ``` -If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database. +If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database. Setting the owner as false creates a non-persistent vehicle. + ```lua local vehicle = Ox.CreateVehicle({ model = 'sultanrs', diff --git a/docs/ox_core/Vehicle/Server/methods.md b/docs/ox_core/Vehicle/Server/methods.md index 057afbeb..9ee821e4 100644 --- a/docs/ox_core/Vehicle/Server/methods.md +++ b/docs/ox_core/Vehicle/Server/methods.md @@ -86,7 +86,7 @@ vehicle.setGroup(group) ## vehicle.setPlate -Sets the vehicle's plate, used in the database to ensure uniqueness. Does not necessarily match the plate property (i.e. fake plates). +Sets the vehicle's plate, used in the database to ensure uniqueness. Does not necessarily match the plate property (i.e. fake plates). Plate is always formatted to 8 characters. ```lua diff --git a/docs/ox_inventory/Functions/Client/Inventory/Search.md b/docs/ox_inventory/Functions/Client/Inventory/Search.md index abb94167..61c417ca 100644 --- a/docs/ox_inventory/Functions/Client/Inventory/Search.md +++ b/docs/ox_inventory/Functions/Client/Inventory/Search.md @@ -6,6 +6,7 @@ Searches the inventory for an item, or list of items, with the result varying ba ```lua exports.ox_inventory:Search(search, item, metadata) ``` + * search: `'slots'` or `'count'` * `'slots'` returns a table of slots where the item was found at. * `'count'` returns the count of the specified item in player's inventory. If searching for multiple items diff --git a/docs/ox_inventory/Functions/Client/Items.md b/docs/ox_inventory/Functions/Client/Items.md index 50d48232..0fe82d8e 100644 --- a/docs/ox_inventory/Functions/Client/Items.md +++ b/docs/ox_inventory/Functions/Client/Items.md @@ -9,7 +9,7 @@ The following snippet can be used in crafting resources such as okokCrafting or ```lua local itemNames = {} -for item, data in pairs(exports.ox_inventory:Items()) do +for item, data in pairs(exports.ox_inventory:Items()) do itemNames[item] = data.label end -``` \ No newline at end of file +``` diff --git a/docs/ox_inventory/Functions/Client/Statebags/invBusy.md b/docs/ox_inventory/Functions/Client/Statebags/invBusy.md index ce324111..e488bf43 100644 --- a/docs/ox_inventory/Functions/Client/Statebags/invBusy.md +++ b/docs/ox_inventory/Functions/Client/Statebags/invBusy.md @@ -10,8 +10,8 @@ Returns whether the player's inventory is currently running an action (i.e. usin local isInventoryBusy = LocalPlayer.state.invBusy if isInventoryBusy then - -- Do stuff when busy + -- Do stuff when busy else - -- Do stuff when not busy + -- Do stuff when not busy end ``` diff --git a/docs/ox_inventory/Functions/Client/Statebags/invOpen.md b/docs/ox_inventory/Functions/Client/Statebags/invOpen.md index c9b6892f..8a1b3c20 100644 --- a/docs/ox_inventory/Functions/Client/Statebags/invOpen.md +++ b/docs/ox_inventory/Functions/Client/Statebags/invOpen.md @@ -10,7 +10,7 @@ Returns whether the player's inventory is currently open or not. local isInventoryOpen = LocalPlayer.state.invOpen if isInventoryOpen then - -- Do stuff when open + -- Do stuff when open else - -- Do stuff when closed + -- Do stuff when closed end diff --git a/docs/ox_inventory/Functions/Client/Utils/weaponWheel.md b/docs/ox_inventory/Functions/Client/Utils/weaponWheel.md index 92c275ec..065a3072 100644 --- a/docs/ox_inventory/Functions/Client/Utils/weaponWheel.md +++ b/docs/ox_inventory/Functions/Client/Utils/weaponWheel.md @@ -5,4 +5,5 @@ Mostly used for weaponised vehicles, though could be called for "minigames" ```lua local exports.ox_inventory:weaponWheel(state) ``` + * state: `boolean` diff --git a/docs/ox_inventory/Functions/Client/displayMetadata.md b/docs/ox_inventory/Functions/Client/displayMetadata.md index a910cd76..085fccb7 100644 --- a/docs/ox_inventory/Functions/Client/displayMetadata.md +++ b/docs/ox_inventory/Functions/Client/displayMetadata.md @@ -3,6 +3,7 @@ Sets a metadata property to display in the tooltip. ```lua exports.ox_inventory:displayMetadata(metadata, value) ``` + * metadata: `table` or `string` * If metadata is a string then it's the metadata property you want to display, value is **not** optional then. * Can be a table of key-value pairs, key being the metadata property and value being the label for that property. @@ -10,6 +11,7 @@ exports.ox_inventory:displayMetadata(metadata, value) * Label for the string metadata property to be displayed. **Example:** + ```lua exports.ox_inventory:displayMetadata('mustard', 'Mustard') ``` diff --git a/docs/ox_inventory/Functions/Client/openInventory.md b/docs/ox_inventory/Functions/Client/openInventory.md index 259c02a7..5ca102a5 100644 --- a/docs/ox_inventory/Functions/Client/openInventory.md +++ b/docs/ox_inventory/Functions/Client/openInventory.md @@ -6,6 +6,7 @@ Opens an inventory using the passed data. ```lua exports.ox_inventory:openInventory(invType, data) ``` + * invType: `string` * `'player'` * `'shop'` diff --git a/docs/ox_inventory/Functions/Client/setStashTarget.md b/docs/ox_inventory/Functions/Client/setStashTarget.md index b6928045..c3537969 100644 --- a/docs/ox_inventory/Functions/Client/setStashTarget.md +++ b/docs/ox_inventory/Functions/Client/setStashTarget.md @@ -3,6 +3,7 @@ Forces the secondary-inventory key to open the passed inventory. Can be useful t ```lua exports.ox_inventory:setStashTarget(id, owner) ``` + * id: `string` or `number` * Stash id. * owner?: `string` or `number` diff --git a/docs/ox_inventory/Functions/Client/useItem.md b/docs/ox_inventory/Functions/Client/useItem.md index f26fc924..d2b76680 100644 --- a/docs/ox_inventory/Functions/Client/useItem.md +++ b/docs/ox_inventory/Functions/Client/useItem.md @@ -1,9 +1,10 @@ -Uses the passed item, then triggers the callback function. +Uses the passed item, then triggers the callback function. Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.). ```lua exports.ox_inventory:useItem(data, cb) ``` + * data: `table` * cb?: `function` diff --git a/docs/ox_inventory/Functions/Client/useSlot.md b/docs/ox_inventory/Functions/Client/useSlot.md index 3482b20f..bb7c9cbd 100644 --- a/docs/ox_inventory/Functions/Client/useSlot.md +++ b/docs/ox_inventory/Functions/Client/useSlot.md @@ -3,4 +3,5 @@ Uses the item in the given inventory slot. ```lua exports.ox_inventory:useSlot(slot) ``` + * slot: `number` diff --git a/docs/ox_inventory/Functions/Server/Hooks.md b/docs/ox_inventory/Functions/Server/Hooks.md index 4d171c61..9106ae49 100644 --- a/docs/ox_inventory/Functions/Server/Hooks.md +++ b/docs/ox_inventory/Functions/Server/Hooks.md @@ -24,7 +24,7 @@ By returning `false`, you can cancel the action and revert the inventory state. - source: `number` - action: `'move'` or `'stack'` or `'swap'` or `'give'` - fromInventory: `number` or `string` -- toInventory:` number` or `string` +- toInventory: `number` or `string` - fromType: `string` - toType: `string` - fromSlot: `table` diff --git a/docs/ox_inventory/Functions/Server/Inventory/AddItem.md b/docs/ox_inventory/Functions/Server/Inventory/AddItem.md index a4011b9a..1d876c57 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/AddItem.md +++ b/docs/ox_inventory/Functions/Server/Inventory/AddItem.md @@ -5,6 +5,7 @@ Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximu ```lua exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb) ``` + - inv: `table` or `string` or `number` - The inventory's unique id, or a table with the id and owner. - playerId: `1` diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount.md b/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount.md index 68a24664..58faaac0 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount.md +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount.md @@ -3,6 +3,7 @@ Returns the amount a player can hold based on available weight. ```lua exports.ox_inventory:CanCarryAmount(inv, item) ``` + * inv: `string` or `number` * item: `table` or `string` * Can be array to check multiple items. diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem.md b/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem.md index e1a5c88f..53d47e53 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem.md +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem.md @@ -5,6 +5,7 @@ The function checks for inventory weight and available slots. ```lua exports.ox_inventory:CanCarryItem(inv, item, count, metadata) ``` + * inv: `string` or `number` * item `table` or `string` * Can be array of items. @@ -13,6 +14,7 @@ exports.ox_inventory:CanCarryItem(inv, item, count, metadata) * If metadata is passed as string then `metadata.type` will be checked. **Example:** + ```lua -- Checks if the player calling the event can carry 3 water items if exports.ox_inventory:CanCarryItem(source, 'water', 3) then diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight.md b/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight.md index ffaeea48..ad8c9b9a 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight.md +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight.md @@ -3,6 +3,7 @@ Returns if inventory can carry specified weight and free inventory weight. ```lua exports.ox_inventory:CanCarryWeight(inv, weight) ``` + * inv: `string` or `number` * weight: `number` diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem.md b/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem.md index b7e9c4ca..2c05c06a 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem.md +++ b/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem.md @@ -3,6 +3,7 @@ Returns true if the item swap is possible based on inventory weight. ```lua exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount) ``` + * inv: `string` or `number` * firstItem: `string` * firstItemCount: `number` diff --git a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md index a60fa455..ff113165 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md +++ b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory.md @@ -3,5 +3,6 @@ Clears the specified inventory. The `keep` argument is either a string or an arr ```lua exports.ox_inventory:ClearInventory(inv, keep) ``` + * inv: `string` or `number` * keep?: `string` or `string[]` diff --git a/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory.md b/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory.md index f5fafa5f..aaf9dac9 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory.md +++ b/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory.md @@ -6,4 +6,5 @@ the player. ```lua exports.ox_inventory:ConfiscateInventory(source) ``` + * source: `number` diff --git a/docs/ox_inventory/Functions/Server/Inventory/ConvertItems.md b/docs/ox_inventory/Functions/Server/Inventory/ConvertItems.md index fe5ce65f..f9e24d08 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ConvertItems.md +++ b/docs/ox_inventory/Functions/Server/Inventory/ConvertItems.md @@ -3,11 +3,14 @@ Takes traditional item data and updates it to support ox_inventory. ```lua exports.ox_inventory:ConvertItems(playerId, items) ``` + * playerId: `number` * items: `table` Data conversion example: - ``` - Old: [{"cola":1, "bread":3}] - New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}] + +```lua +Old: [{"cola":1, "bread":3}] +New: [{"slot":1,"name":"cola","count":1}, +{"slot":2,"name":"bread","count":3}] ``` diff --git a/docs/ox_inventory/Functions/Server/Inventory/CustomDrop.md b/docs/ox_inventory/Functions/Server/Inventory/CustomDrop.md index f95e3474..9211916d 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CustomDrop.md +++ b/docs/ox_inventory/Functions/Server/Inventory/CustomDrop.md @@ -3,6 +3,7 @@ Drops can be created from other resources, containing a variety of items and uti ```lua exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance) ``` + * prefix: `string` * items: `table` * name: `string` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon.md b/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon.md index a8fdcc87..663ef759 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon.md @@ -4,4 +4,5 @@ Returns the player's currently equipped weapon as a table. -- inv: string or number exports.ox_inventory:GetCurrentWeapon(inv) ``` + * inv: `string` or `number` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetInventory.md b/docs/ox_inventory/Functions/Server/Inventory/GetInventory.md index 88aac9fe..f71bcf39 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetInventory.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetInventory.md @@ -3,23 +3,25 @@ Returns the inventory associated with the ID (and owner if defined). Otherwise r ```lua exports.ox_inventory:GetInventory(inv, owner) ``` + * inv: `number` or `table` * owner?: `string` or `boolean` **Example:** + ```lua local inventory = exports.ox_inventory:GetInventory('example_stash', false) print(json.encode(inventory, {indent = true})) --[[ { - "id": "example_stash, - "label": "Police Stash", - "type": "stash, - "slots": 50, - "weight": 0, - "maxWeight": 100000, - "owner": false, - ... + "id": "example_stash, + "label": "Police Stash", + "type": "stash, + "slots": 50, + "weight": 0, + "maxWeight": 100000, + "owner": false, + ... } ]] ``` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetInventoryItems.md b/docs/ox_inventory/Functions/Server/Inventory/GetInventoryItems.md index a0a96d84..f74b656b 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetInventoryItems.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetInventoryItems.md @@ -3,10 +3,12 @@ Returns all slots with items in a inventory. ```lua exports.ox_inventory:GetInventoryItems(inv, owner) ``` + * inv: `number` or `table` * owner?: `string` or `boolean` **Example:** + ```lua local playerItems = exports.ox_inventory:GetInventoryItems(source) ``` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetItem.md b/docs/ox_inventory/Functions/Server/Inventory/GetItem.md index 23e1aefe..6b0d0e76 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetItem.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetItem.md @@ -3,6 +3,7 @@ Returns the item from the specified inventory. ```lua exports.ox_inventory:GetItem(inv, item, metadata, returnsCount) ``` + * inv: `string` or `number` * item: `table` or `string` * Can be items array. @@ -15,6 +16,7 @@ how many times the item was found. Otherwise returns the data related to the item _and_ it's total count found in the inventory. **Example**: + ```lua local item = ox_inventory:GetItem(source, 'water', nil, false) diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots.md b/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots.md index 3f88d4ea..7c3da1a9 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots.md @@ -3,6 +3,7 @@ Returns the number of slots the specified item is in, the item's total count and ```lua exports.ox_inventory:GetItemSlots(inv, item, metadata) ``` + * inv: `string` or `number` * item: `table` or `string` * metadata?: `table` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetSlot.md b/docs/ox_inventory/Functions/Server/Inventory/GetSlot.md index 2c8bb788..41488298 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetSlot.md +++ b/docs/ox_inventory/Functions/Server/Inventory/GetSlot.md @@ -4,24 +4,26 @@ Returns the specified slot data as a table. exports.ox_inventory:GetSlot(inv, slot) ``` + * inv: `string` or `number` * slot: `number` **Example:** + ```lua local slot = exports.ox_inventory:GetSlot(source, 1) print(json.encode(slot, {indent=true})) --[[ { - "weight": 2000, - "name": "water", - "metadata": [], - "slot": 1, - "label": "Water", - "close": true, - "stack": true, - "count: 4 + "weight": 2000, + "name": "water", + "metadata": [], + "slot": 1, + "label": "Water", + "close": true, + "stack": true, + "count: 4 } ]] ``` diff --git a/docs/ox_inventory/Functions/Server/Inventory/RegisterStash.md b/docs/ox_inventory/Functions/Server/Inventory/RegisterStash.md index 8c4c479d..8ccbddbf 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/RegisterStash.md +++ b/docs/ox_inventory/Functions/Server/Inventory/RegisterStash.md @@ -3,6 +3,7 @@ Creates a new custom stash. ```lua exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords) ``` + * id: `string` or `number` * Stash identifier when loading from the database. * label: `string` @@ -14,9 +15,9 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c * `true`: Each player has a unique stash but can request other player's stashes. * `nil`: Always shared. * groups: `table` - * Table of player groups (jobs) able to access the stash. - * Table of group names where the numeric value is the minimum grade required. - * `{['police'] = 0, ['ambulance'] = 2}` + * Table of player groups (jobs) able to access the stash. + * Table of group names where the numeric value is the minimum grade required. + * `{['police'] = 0, ['ambulance'] = 2}` * coords: `vector3` :::caution diff --git a/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory.md b/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory.md index ed9664ac..455b93d3 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory.md +++ b/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory.md @@ -5,4 +5,5 @@ Use it alongside [ConfiscateInventory](./ConfiscateInventory.md). ```lua exports.ox_inventory:ReturnInventory(source) ``` + * source: `number` diff --git a/docs/ox_inventory/Functions/Server/Inventory/Search.md b/docs/ox_inventory/Functions/Server/Inventory/Search.md index 7050d762..c2245c38 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/Search.md +++ b/docs/ox_inventory/Functions/Server/Inventory/Search.md @@ -1,9 +1,9 @@ Searches an inventory for a specified item. ```lua - exports.ox_inventory:Search(inv, search, item, metadata) ``` + * inv: `string` or `number` * search: `string` * item: `table` or `string` diff --git a/docs/ox_inventory/Functions/Server/Inventory/SetDurability.md b/docs/ox_inventory/Functions/Server/Inventory/SetDurability.md index 8a5c3ec6..ca8ed51b 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SetDurability.md +++ b/docs/ox_inventory/Functions/Server/Inventory/SetDurability.md @@ -5,11 +5,13 @@ Can be used for repairing weapons. ```lua exports.ox_inventory:SetDurability(inv, slot, durability) ``` + * inv: `string` or `number` * slot: `number` * durability: `number` **Example:** + ```lua local ox_inventory = exports.ox_inventory diff --git a/docs/ox_inventory/Functions/Server/Inventory/SetMetadata.md b/docs/ox_inventory/Functions/Server/Inventory/SetMetadata.md index 5e03221c..c81a29e7 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SetMetadata.md +++ b/docs/ox_inventory/Functions/Server/Inventory/SetMetadata.md @@ -3,11 +3,13 @@ Sets metadata on the specified slot. ```lua ox_inventory:SetMetadata(inv, slot, metadata) ``` + * inv: `string` or `number` * slot: `number` * metadata: `table` **Example:** + ```lua local ox_inventory = exports.ox_inventory @@ -18,6 +20,7 @@ for k, v in pairs(water) do water = v break end + water.metadata.type = 'clean' ox_inventory:SetMetadata(source, water.slot, water.metadata) print(('modified %sx water in slot %s with new metadata'):format(water.count, water.slot)) diff --git a/docs/ox_inventory/Functions/Server/Inventory/SwapSlots.md b/docs/ox_inventory/Functions/Server/Inventory/SwapSlots.md index 43e9ff37..202a1eee 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SwapSlots.md +++ b/docs/ox_inventory/Functions/Server/Inventory/SwapSlots.md @@ -3,6 +3,7 @@ Swaps slots in specified inventories. ```lua exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2) ``` + * fromInventory: `any` * toInventory: `any` * slot1: `number` diff --git a/docs/ox_inventory/Functions/Server/Items.md b/docs/ox_inventory/Functions/Server/Items.md index 98c35df0..1c1e4d42 100644 --- a/docs/ox_inventory/Functions/Server/Items.md +++ b/docs/ox_inventory/Functions/Server/Items.md @@ -11,10 +11,10 @@ local itemNames ESX.RegisterServerCallback('crafting:itemNames', function(source, cb) if not itemNames then itemNames = {} - for item, data in pairs(exports.ox_inventory:Items()) do + for item, data in pairs(exports.ox_inventory:Items()) do itemNames[item] = data.label end end cb(itemNames) end) -``` \ No newline at end of file +``` diff --git a/docs/ox_inventory/Functions/Server/setPlayerInventory.md b/docs/ox_inventory/Functions/Server/setPlayerInventory.md index 6917ad21..dcac7677 100644 --- a/docs/ox_inventory/Functions/Server/setPlayerInventory.md +++ b/docs/ox_inventory/Functions/Server/setPlayerInventory.md @@ -3,6 +3,7 @@ Creates and sets the player's inventory. ```lua exports.ox_inventory:setPlayerInventory(player, data) ``` + * player: `table` * source: `number` * identifier: `string` diff --git a/docs/ox_inventory/Getting Started/config.md b/docs/ox_inventory/Getting Started/config.md index 1ce2ad34..285e76b5 100644 --- a/docs/ox_inventory/Getting Started/config.md +++ b/docs/ox_inventory/Getting Started/config.md @@ -13,7 +13,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 +```yaml # Activate specific event handlers and functions (supported: ox, esx, qb, nd) setr inventory:framework "esx" diff --git a/docs/ox_inventory/Getting Started/index.md b/docs/ox_inventory/Getting Started/index.md index 5d6b296e..231a8144 100644 --- a/docs/ox_inventory/Getting Started/index.md +++ b/docs/ox_inventory/Getting Started/index.md @@ -43,7 +43,7 @@ The resources listed under here **aren't** necessary for the inventory to work b ### ox_target -A performant and flexible standalone "third-eye" targeting resource. +A performant and flexible standalone "third-eye" targeting resource. Stashes, shops, and crafting benches will be accessible via zone targets instead of using markers. @@ -60,8 +60,8 @@ The inventory will handle disabling the phone when the player has no item, and s ### Production Build -The user interface included with the source code must be compiled. -You can compile it youself by following the [build guide](./Guides/inventory_ui), otherwise download a production build below. +The user interface included with the source code must be compiled. +You can compile it yourself by following the [build guide](./Guides/inventory_ui), otherwise download a production build below. @@ -76,12 +76,12 @@ Integration between your framework and ox_inventory should be relatively simple You should first reference the [mysql](https://github.com/overextended/ox_inventory/blob/main/modules/mysql/server.lua) module and setup appropriate table and column names. ```lua - elseif shared.framework == 'myframework' then - playerTable = 'characters' -- table storing player / character data - playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id) - vehicleTable = 'vehicles' -- table storing owned vehicle data - vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id) - end +elseif shared.framework == 'myframework' then + playerTable = 'characters' -- table storing player / character data + playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id) + vehicleTable = 'vehicles' -- table storing owned vehicle data + vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id) +end ``` You will need events and functions to handle licenses, owned vehicles, and job systems; these should be handled in the "bridge" module. diff --git a/docs/ox_inventory/Getting Started/issues.md b/docs/ox_inventory/Getting Started/issues.md index b6f3fb3c..b8fc40e7 100644 --- a/docs/ox_inventory/Getting Started/issues.md +++ b/docs/ox_inventory/Getting Started/issues.md @@ -8,16 +8,16 @@ sidebar_position: 1 Because the UI for inventory is written in React it can't run natively under FiveM so it must first be bundled into html/css/js. -We provide an easy way for you to do this by downloading a pre-bundled release, which you can get from [here](https://github.com/overextended/ox_inventory/releases/latest). +We provide an easy way for you to do this by downloading a pre-bundled release, which you can get from [here](https://github.com/overextended/ox_inventory/releases/latest). Make sure you download the `ox_inventory.zip` file as that one contains the bundled files and others are raw source code. -If in case you wanted to edit the inventory UI you would have to build these files yourself. +If in case you wanted to edit the inventory UI you would have to build these files yourself. To do so please read our [_Building inventory UI_](../Guides/inventory_ui.md) guide. ## Stashes / trunks are not saved at server restart -The only supported way of doing a restart is **txAdmin scheduled restart**. +The only supported way of doing a restart is **txAdmin scheduled restart**. txAdmin scheduled restart should be your only way of restarting a server in production. -If you need to do a manual restart, you must use `/saveinv` before restarting the server. +If you need to do a manual restart, you must use `/saveinv` before restarting the server. If you don't do this, all inventory except players inventory will not be saved. diff --git a/docs/ox_inventory/Guides/crafting.md b/docs/ox_inventory/Guides/crafting.md index b837a32a..69ff1a9c 100644 --- a/docs/ox_inventory/Guides/crafting.md +++ b/docs/ox_inventory/Guides/crafting.md @@ -8,37 +8,37 @@ Crafting locations, items and their ingredients are defined in [data/crafting.lu ```lua { - items = { - { - name = 'lockpick', - ingredients = { - garbage = 3, - WEAPON_HAMMER = 0.1 - }, - duration = 5000, - count = 3, - metadata = { durability = 20 } + items = { + { + name = 'lockpick', + ingredients = { + garbage = 3, + WEAPON_HAMMER = 0.1 + }, + duration = 5000, + count = 3, + metadata = { durability = 20 } + }, + { + name = 'garbage', + ingredients = { + cola = 1 + }, + metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' } + }, }, - { - name = 'garbage', - ingredients = { - cola = 1 - }, - metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' } + points = { + vec3(-1147.083008, -2002.662109, 13.180260), + }, + zones = { + { + coords = vec3(-1146.2, -2002.05, 13.2), + size = vec3(3.8, 1.05, 0.15), + distance = 1.5, + rotation = 315.0, + }, }, - }, - points = { - vec3(-1147.083008, -2002.662109, 13.180260), - }, - zones = { - { - coords = vec3(-1146.2, -2002.05, 13.2), - size = vec3(3.8, 1.05, 0.15), - distance = 1.5, - rotation = 315.0, - }, - }, - blip = { id = 566, colour = 31, scale = 0.8 }, + blip = { id = 566, colour = 31, scale = 0.8 }, }, ``` @@ -51,9 +51,9 @@ Crafting locations, items and their ingredients are defined in [data/crafting.lu * value - If 1 or above it's the consume count, if below 1 and above 0 it's the durability consume amount, if set to 0 then the item is required but not consumed. * duration: `number` - * Crafting duration in miliseconds. + * Crafting duration in milliseconds. * count: `number` - * Item amount recieved upon crafting. + * Item amount received upon crafting. * metadata: `table` * Metadata applied to the item being crafted. * points: `vector3[]` diff --git a/docs/ox_inventory/Guides/creatingItems.md b/docs/ox_inventory/Guides/creatingItems.md index aeb5b0bc..2ae1f241 100644 --- a/docs/ox_inventory/Guides/creatingItems.md +++ b/docs/ox_inventory/Guides/creatingItems.md @@ -39,14 +39,14 @@ options for the item. * status?: `table` * Adjust esx_status values after use. * anim?: `table` - * Animation that will be played during the progress bar. - * dict: `string` - * clip: `string` + * Animation that will be played during the progress bar. + * dict: `string` + * clip: `string` * prop?: `table` - * Attached prop that will be displayed during the progress bar. - * model: `string` or `hash` - * pos: `table` (x, y, z) - * rot: `table` (x, y, z) + * Attached prop that will be displayed during the progress bar. + * model: `string` or `hash` + * pos: `table` (x, y, z) + * rot: `table` (x, y, z) * disable?: `table` * Actions to be disabled during the progress bar * move?: `boolean` @@ -57,11 +57,11 @@ options for the item. * cancel?: `boolean` * If set to true the player canc cancel item use. * add?: `function`(total: `number`) - * Function that triggers when recieving an item + * Function that triggers when receiving an item * Returns total item count as `total` * remove?: `function`(total: `number`) - * Function that triggers when removing an item - * Returns total item count as `total` + * Function that triggers when removing an item + * Returns total item count as `total` * buttons?: `table` * label: `string` * action: `function`(slot: `number`) @@ -147,8 +147,8 @@ 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 you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`. +* If you are using ESX, you can continue using `ESX.RegisterUsableItem`. +* If you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`. Using the built-in system is more secure and provides much more functionality. diff --git a/docs/ox_inventory/Guides/index.md b/docs/ox_inventory/Guides/index.md index 8882e681..0e3486a7 100644 --- a/docs/ox_inventory/Guides/index.md +++ b/docs/ox_inventory/Guides/index.md @@ -2,5 +2,5 @@ title: Guides --- -Providing examples and explaining certain inventory API into more detail. +Providing examples and explaining certain inventory API into more detail. If you have trouble understanding how some of the API works check out our [**_example resource_**](https://github.com/overextended/ox_inventory_examples). diff --git a/docs/ox_inventory/Guides/shops.md b/docs/ox_inventory/Guides/shops.md index 5083f4d2..69e2f855 100644 --- a/docs/ox_inventory/Guides/shops.md +++ b/docs/ox_inventory/Guides/shops.md @@ -72,10 +72,12 @@ Targets and model are only available when using a targeting resource like ox_tar ## Register during runtime Shops can be added using `exports.ox_inventory:RegisterShop` on the server, however they cannot utilise any client-only features. + - Blips, markers, and zones will not be created. - Must use "locations" and not "targets" to define each shop using the archetype. **Example:** + ```lua exports.ox_inventory:RegisterShop('TestShop', { name = 'Test shop', diff --git a/docs/ox_inventory/Guides/stashes.md b/docs/ox_inventory/Guides/stashes.md index 443ce738..c59e5904 100644 --- a/docs/ox_inventory/Guides/stashes.md +++ b/docs/ox_inventory/Guides/stashes.md @@ -34,6 +34,7 @@ Firstly, we need to define the stashes properties. ## Example Below the value is hardset, but it could be loaded from the database (especially if there are unknown fields, i.e. owner) + ```lua -- Server local stash = { @@ -55,6 +56,7 @@ exports.ox_inventory:openInventory('stash', {id='42wallabyway', owner=property.o ``` The following sample is based on esx_property's db data. + ```lua -- Server local properties diff --git a/docs/ox_lib/ACL/Server.md b/docs/ox_lib/ACL/Server.md index 4df250b1..65991638 100644 --- a/docs/ox_lib/ACL/Server.md +++ b/docs/ox_lib/ACL/Server.md @@ -1,11 +1,11 @@ -Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions. +Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions. Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information. import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - ### lib.addAce + Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'. @@ -16,6 +16,7 @@ lib.addAce(principal, ace, allow) lib.addAce('group.admin', 'command.say') ``` + @@ -26,25 +27,27 @@ lib.addAce(principal, ace, allow) lib.addAce('group.admin', 'command.say') ``` + -* principal: `string` -* ace: `string` +* principal: `string` +* ace: `string` * allow: `boolean` ### lib.removeAce + Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'. - ```lua lib.removeAce(principal, ace, allow) lib.removeAce('group.admin', 'command.say') ``` + @@ -55,14 +58,16 @@ lib.removeAce(principal, ace, allow) lib.removeAce('group.admin', 'command.say') ``` + -* principal: `string` -* ace: `string` +* principal: `string` +* ace: `string` * allow: `boolean` ### lib.addPrincipal + Assigns a principal to a parent principal. Children inherit permissions from the parent. @@ -73,6 +78,7 @@ lib.addPrincipal(child, parent) lib.addPrincipal('player.1', 'group.moderator') ``` + @@ -83,14 +89,15 @@ lib.addPrincipal(child, parent) lib.addPrincipal('player.1', 'group.moderator') ``` + * child: `string` * parent: `string` - ### lib.removePrincipal + Removes a principal from a parent principal. @@ -101,6 +108,7 @@ lib.removePrincipal(child, parent) lib.removePrincipal('player.1', 'group.moderator') ``` + @@ -111,9 +119,9 @@ lib.removePrincipal(child, parent) lib.removePrincipal('player.1', 'group.moderator') ``` + * child: `string` * parent: `string` - diff --git a/docs/ox_lib/AddCommand/Server.md b/docs/ox_lib/AddCommand/Server.md index 18280d92..45991f82 100644 --- a/docs/ox_lib/AddCommand/Server.md +++ b/docs/ox_lib/AddCommand/Server.md @@ -1,6 +1,7 @@ ```lua lib.addCommand(principal, command, callback, parameters, help) ``` + * principal: `string` or `string[]` or `false` * command: `string` * callback: `function` diff --git a/docs/ox_lib/AddKeybind/Client.md b/docs/ox_lib/AddKeybind/Client.md index ae20ff8c..3324fe58 100644 --- a/docs/ox_lib/AddKeybind/Client.md +++ b/docs/ox_lib/AddKeybind/Client.md @@ -1,6 +1,7 @@ ```lua lib.addKeybind(data) ``` + * data: `table` * name: `string` * description: `string` @@ -27,7 +28,8 @@ local keybind = lib.addKeybind({ ``` Keybinds can be enabled/disabled by using the disable method. + ```lua keybind:disable(true) -- disable keybind:disable(false) -- enable -``` \ No newline at end of file +``` diff --git a/docs/ox_lib/Cache/Client.md b/docs/ox_lib/Cache/Client.md index 4847df33..553c89d9 100644 --- a/docs/ox_lib/Cache/Client.md +++ b/docs/ox_lib/Cache/Client.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -Caches data related to the player and handling some events or statebags. +Caches data related to the player and handling some events or statebags. An interval runs every 100ms to update data that cannot be checked via handlers. ## States diff --git a/docs/ox_lib/Callback/Client.md b/docs/ox_lib/Callback/Client.md index 694990e5..d798132c 100644 --- a/docs/ox_lib/Callback/Client.md +++ b/docs/ox_lib/Callback/Client.md @@ -51,7 +51,7 @@ lib.callback.register(name, cb) ```lua lib.callback.register('ox:getNearbyVehicles', function(radius) - local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true) - return nearbyVehicles + local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true) + return nearbyVehicles end) ``` diff --git a/docs/ox_lib/DisableControls/Client.md b/docs/ox_lib/DisableControls/Client.md index 6d912916..0466d279 100644 --- a/docs/ox_lib/DisableControls/Client.md +++ b/docs/ox_lib/DisableControls/Client.md @@ -1,23 +1,31 @@ ### lib.disableControls + Call on frame to disable all stored keys. ```lua lib.disableControls() ``` + ### lib.disableControls:Add + ```lua lib.disableControls:Add(...) ``` + * vararg: `number` ### lib.disableControls:Remove + ```lua lib.disableControls:Remove(...) ``` + * vararg: `number` ### lib.disableControls:Clear + ```lua lib.disableControls:Clear(...) ``` + * vararg: `number` diff --git a/docs/ox_lib/GetClosestPlayer/Client.md b/docs/ox_lib/GetClosestPlayer/Client.md index 1f117dd6..4ccd7f35 100644 --- a/docs/ox_lib/GetClosestPlayer/Client.md +++ b/docs/ox_lib/GetClosestPlayer/Client.md @@ -5,6 +5,7 @@ Get the id, ped, and coords of the closest player to a set of coordinates. ```lua function lib.getClosestPlayer(coords, maxDistance, includePlayer) end ``` + * coords: `vector3` * The coords to check from. * maxDistance: `number` @@ -13,6 +14,7 @@ function lib.getClosestPlayer(coords, maxDistance, includePlayer) end * Whether or not to include the current player. Return: + * playerId?: `number` * playerPed?: `number` * playerCoords?: `vector3` diff --git a/docs/ox_lib/GetClosestVehicle/Client.md b/docs/ox_lib/GetClosestVehicle/Client.md index 1b39dcae..bd9a999f 100644 --- a/docs/ox_lib/GetClosestVehicle/Client.md +++ b/docs/ox_lib/GetClosestVehicle/Client.md @@ -14,5 +14,6 @@ function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end * Whether or not to include the player's current vehicle. Return: + * vehicle?: `number` * vehicleCoords?: `vector3` diff --git a/docs/ox_lib/GetNearbyPlayers/Client.md b/docs/ox_lib/GetNearbyPlayers/Client.md index f8eadde6..121cde84 100644 --- a/docs/ox_lib/GetNearbyPlayers/Client.md +++ b/docs/ox_lib/GetNearbyPlayers/Client.md @@ -5,6 +5,7 @@ Get the id, ped, and coords of all players within range of a set of coordinates. ```lua function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end ``` + * coords: `vector3` * The coords to check from. * maxDistance: `number` @@ -13,4 +14,5 @@ function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end * Whether or not to include the current player. Return: + * `number[]` diff --git a/docs/ox_lib/GetNearbyVehicles/Client.md b/docs/ox_lib/GetNearbyVehicles/Client.md index ed960198..b7bbf780 100644 --- a/docs/ox_lib/GetNearbyVehicles/Client.md +++ b/docs/ox_lib/GetNearbyVehicles/Client.md @@ -5,6 +5,7 @@ Get the id and coords of all vehicles within range of a set of coordinates. ```lua function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end ``` + * coords: `vector3` * The coords to check from. * maxDistance: `number` @@ -13,4 +14,5 @@ function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end * Whether or not to include the player's current vehicle. Return: + * `number[]` diff --git a/docs/ox_lib/Interface/Client/alert.md b/docs/ox_lib/Interface/Client/alert.md index 4f4c54aa..53497fcd 100644 --- a/docs/ox_lib/Interface/Client/alert.md +++ b/docs/ox_lib/Interface/Client/alert.md @@ -5,7 +5,7 @@ title: Alert Dialog import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -Simple alert dialog that can display a message to the player. +Simple alert dialog that can display a message to the player. Returns whether the player pressed the confirm button or canceled the dialog. ### lib.alertDialog @@ -16,6 +16,7 @@ Returns whether the player pressed the confirm button or canceled the dialog. ```lua lib.alertDialog(data) ``` + @@ -28,6 +29,7 @@ import lib from '@overextended/ox_lib/client' lib.alertDialog(data) ``` + @@ -54,6 +56,7 @@ Force closes the active alert dialog and sets its return data as `nil` ```lua lib.closeAlertDialog() ``` + @@ -62,6 +65,7 @@ import lib from '@overextended/ox_lib/client' lib.closeAlertDialog() ``` + @@ -80,6 +84,7 @@ local alert = lib.alertDialog({ print(alert) ``` + @@ -95,9 +100,8 @@ const alert = await lib.alertDialog({ console.log(alert) ``` + - - ![alert_dialog](https://i.imgur.com/TnUT3S1.png) diff --git a/docs/ox_lib/Interface/Client/clipboard.md b/docs/ox_lib/Interface/Client/clipboard.md index 71a47f9f..83269dab 100644 --- a/docs/ox_lib/Interface/Client/clipboard.md +++ b/docs/ox_lib/Interface/Client/clipboard.md @@ -15,6 +15,7 @@ Sets the player's clipboard to the specified string value. ```lua lib.setClipboard(value) ``` + @@ -23,6 +24,7 @@ import lib from '@overextended/ox_lib/client' lib.setClipboard(value) ``` + diff --git a/docs/ox_lib/Interface/Client/context.md b/docs/ox_lib/Interface/Client/context.md index 81b9908c..2972a25e 100644 --- a/docs/ox_lib/Interface/Client/context.md +++ b/docs/ox_lib/Interface/Client/context.md @@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; ### lib.registerContext + Used for registering a context menu. @@ -14,6 +15,7 @@ Used for registering a context menu. ```lua lib.registerContext(context) ``` + @@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client' lib.registerContext(context) ``` + @@ -54,7 +57,7 @@ lib.registerContext(context) * progress?: `number` * Adds a progress bar filled to this percentage * colorScheme?: `string` - * Sets the color scheme of the progress bar. Current options available are: + * Sets the color scheme of the progress bar. Current options available are: * `whiteAlpha`, `blackAlpha`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `cyan`, `purple`, `pink` * arrow?: `boolean` * Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it. @@ -74,12 +77,13 @@ lib.registerContext(context) You can register as many context menus in one `lib.registerContext` function as you'd like. -The menu can be either in the order you write it in, or sorted alphabetically. +The menu can be either in the order you write it in, or sorted alphabetically. To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys, otherwise not using keys and instead using tables will make the menu be in the order you define it as. ### lib.showContext + Opens a registered context menu by it's id. @@ -88,6 +92,7 @@ Opens a registered context menu by it's id. ```lua lib.showContext(id) ``` + @@ -96,12 +101,14 @@ import lib from '@overextended/ox_lib/client' lib.showContext(id) ``` + * id: `string` ### lib.hideContext + Hides any currently visible context menu. @@ -110,6 +117,7 @@ Hides any currently visible context menu. ```lua lib.hideContext(onExit) ``` + @@ -118,6 +126,7 @@ import lib from '@overextended/ox_lib/client' lib.hideContext(onExit) ``` + @@ -136,6 +145,7 @@ If no context menu is open returns `nil`. ```lua lib.getOpenContextMenu() ``` + @@ -144,10 +154,12 @@ import lib from '@overextended/ox_lib/client' lib.getOpenContextMenu() ``` + ### Usage Example + First we register the menu with our specified options then we call the show function in the command. :::tip @@ -204,9 +216,10 @@ lib.registerContext({ ```lua RegisterCommand('testcontext', function() - lib.showContext('example_menu') + lib.showContext('example_menu') end) ``` + @@ -266,10 +279,10 @@ RegisterCommand('testcontext', () => { lib.showContext('example_menu') }, false) ``` + - To trigger the event from the `Event button` and get it's data we first need to register the event properly: @@ -296,6 +309,7 @@ RegisterNetEvent('some_event', function(data) lib.showContext('another_context_menu') end) ``` + @@ -319,6 +333,7 @@ onNet('some_event', () => { lib.showContext('another_context_menu'); }); ``` + @@ -327,8 +342,7 @@ the event you register, in this case that argument is called `data`. Using this event we also register a new context menu with it's own options. - -By defining a `menu` param to be the id of the first menu we can get the +By defining a `menu` param to be the id of the first menu we can get the neat back arrow button next to the menu title that will take us back. If we have a button that does not define either event, serverEvent or menu @@ -337,7 +351,7 @@ the button will do nothing upon being clicked. Of course just registering the event won't do much so we need to display it with the `lib.showContext` function, passing in the menu's id. -![menu_example](https://i.imgur.com/aJu92dv.png) -![metadata](https://i.imgur.com/kFGSlBF.png) +![menu_example](https://i.imgur.com/aJu92dv.png) +![metadata](https://i.imgur.com/kFGSlBF.png) ![event_menu](https://i.imgur.com/r0Ln4VP.png) ![example](https://i.imgur.com/dUsil3p.png) diff --git a/docs/ox_lib/Interface/Client/input.md b/docs/ox_lib/Interface/Client/input.md index 642e2e58..f47a9a17 100644 --- a/docs/ox_lib/Interface/Client/input.md +++ b/docs/ox_lib/Interface/Client/input.md @@ -16,6 +16,7 @@ by setting input fields. ```lua lib.inputDialog(heading, rows) ``` + @@ -24,6 +25,7 @@ import lib from '@overextended/ox_lib/client' lib.inputDialog(heading, rows) ``` + @@ -70,7 +72,7 @@ number data type, you can use set the `type` to `number`. If a user left an input field empty it will return `nil`. -You can also add checkboxes that will return `true` if checked and `nil` if unchecked. +You can also add checkboxes that will return `true` if checked and `nil` if unchecked. Look at the *Advanced* example for it's usage. :::caution @@ -78,7 +80,6 @@ Look at the *Advanced* example for it's usage. When using the advanced method you can define `icon` and `password` **ONLY** with type `'input'` and `'number'` and you can define `options` **ONLY** with type `'select'`. - Doing so otherwise ***will*** result in errors. ::: @@ -92,6 +93,7 @@ Force closes the active input dialog and sets its return data as `nil` ```lua lib.closeInputDialog() ``` + @@ -100,6 +102,7 @@ import lib from '@overextended/ox_lib/client' lib.closeInputDialog() ``` + @@ -119,6 +122,7 @@ local lockerPasscode = input[2] print(lockerNumber, lockerPasscode) ``` + @@ -127,7 +131,6 @@ print(lockerNumber, lockerPasscode) This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. ::: - ```ts const input = await lib.inputDialog('Police locker', ['Locker number', 'Locker passcode']) @@ -137,6 +140,7 @@ const lockerPasscode = input[1] as number console.log(lockerNumber, lockerPasscode) ``` + @@ -149,19 +153,21 @@ console.log(lockerNumber, lockerPasscode) ```lua local input = lib.inputDialog('Police locker', { - { type = "input", label = "Locker number", placeholder = "123" }, - { type = "checkbox", label = "Some checkbox" }, - { type = "input", label = "Locker PIN", password = true, icon = 'lock' }, - { type = "checkbox", label = "Some other checkbox", checked = true }, - { type = 'select', label = 'Value select', options = { - { value = 'option1', label = 'Option 1' }, - { value = 'option2', label = 'Option 2' }, - { value = 'option3', label = 'Option 3'}, - }}, - { type = "number", label = "Number counter", default = 12 } + { type = "input", label = "Locker number", placeholder = "123" }, + { type = "checkbox", label = "Some checkbox" }, + { type = "input", label = "Locker PIN", password = true, icon = 'lock' }, + { type = "checkbox", label = "Some other checkbox", checked = true }, + { type = 'select', label = 'Value select', options = { + { value = 'option1', label = 'Option 1' }, + { value = 'option2', label = 'Option 2' }, + { value = 'option3', label = 'Option 3'}, + }}, + { type = "number", label = "Number counter", default = 12 } }) + print(json.encode(input, {indent=true})) ``` + @@ -185,7 +191,8 @@ const input = await lib.inputDialog('Police locker', [ ]); console.log(JSON.stringify(input, null, 2)); - ``` +``` + diff --git a/docs/ox_lib/Interface/Client/menu.md b/docs/ox_lib/Interface/Client/menu.md index 9d3997c3..1d9e6c87 100644 --- a/docs/ox_lib/Interface/Client/menu.md +++ b/docs/ox_lib/Interface/Client/menu.md @@ -8,6 +8,7 @@ import TabItem from '@theme/TabItem'; Keyboard navigation menu with specific event functions. ### lib.registerMenu + Registers and caches a menu under the specified id. @@ -16,6 +17,7 @@ Registers and caches a menu under the specified id. ```lua lib.registerMenu(data, cb) ``` + @@ -24,6 +26,7 @@ import lib from '@overextended/ox_lib/client' lib.registerMenu(data, cb) ``` + @@ -37,7 +40,7 @@ lib.registerMenu(data, cb) * icon?: `string` * iconColor?: `string` * values?: `table` (`Array`) - * If provided creates a side scrollabel list. + * If provided creates a side scrollable list. * When using object and setting description, the set description will be displayed in the menu tooltip. * checked?: `boolean` * Setting either true or false will make the button a checkbox, if `values` is also provided the button will be a @@ -61,7 +64,7 @@ lib.registerMenu(data, cb) * onClose: `function`(keyPressed?: `'Escape' | 'Backspace'`) * Function that runs when the menu is exited via ESC/Backspace. * onSelected: `function`(selected: `number`, secondary: `number` | `boolean`, args: {[key: `string`]: `any`}) - * Function being ran when the selected button in the menu changes. + * Function being ran when the selected button in the menu changes. * onSideScroll: `function`(selected: `number`, scrollIndex: `number`, args: {[key: `string`]: `any`}) * Function ran whenever a scroll list item is changed. * onCheck: `function`(selected: `number`, checked: `boolean`, args: {[key: `string`]: `any`}) @@ -69,8 +72,8 @@ lib.registerMenu(data, cb) * Callback function when the menu item is pressed. ### lib.showMenu -Displays the menu with the provided id. +Displays the menu with the provided id. @@ -78,6 +81,7 @@ Displays the menu with the provided id. ```lua lib.showMenu(id) ``` + @@ -86,13 +90,12 @@ import lib from '@overextended/ox_lib/client' lib.showMenu(id) ``` + * id: `string` - - ### lib.hideMenu @@ -101,6 +104,7 @@ lib.showMenu(id) ```lua lib.hideMenu(onExit) ``` + @@ -109,6 +113,7 @@ import lib from '@overextended/ox_lib/client' lib.hideMenu(onExit) ``` + @@ -116,6 +121,7 @@ lib.hideMenu(onExit) * If true runs the menu's `onClose` function. ### lib.getOpenMenu + Returns the id of the currently open menu. @@ -124,6 +130,7 @@ Returns the id of the currently open menu. ```lua lib.getOpenMenu() ``` + @@ -132,10 +139,10 @@ import lib from '@overextended/ox_lib/client' lib.getOpenMenu() ``` + - ### lib.setMenuOptions @@ -144,6 +151,7 @@ lib.getOpenMenu() ```lua lib.setMenuOptions(id, options, index) ``` + @@ -152,6 +160,7 @@ import lib from '@overextended/ox_lib/client' lib.setMenuOptions(id, options, index) ``` + @@ -170,6 +179,7 @@ Replaces the 3rd index option of the specified menu ```lua lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3) ``` + @@ -178,17 +188,18 @@ import lib from '@overextended/ox_lib/client' lib.setMenuOptions('some_menu_id', {label: 'New option', icon: 'plus'}, 3) ``` + ### Usage Example -First we register the menu with our specified options then we call the show function in the command. + +First we register the menu with our specified options then we call the show function in the command. :::tip Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu). ::: - @@ -240,6 +251,7 @@ RegisterCommand('testmenu', function() lib.showMenu('some_menu_id') end) ``` + @@ -293,6 +305,7 @@ RegisterCommand('testmenu', () => { lib.showMenu('some_menu_id') }, false) ``` + diff --git a/docs/ox_lib/Interface/Client/notify.md b/docs/ox_lib/Interface/Client/notify.md index f314db69..168cebb4 100644 --- a/docs/ox_lib/Interface/Client/notify.md +++ b/docs/ox_lib/Interface/Client/notify.md @@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; ## lib.notify + Custom notifications with a lot of styling options. @@ -14,6 +15,7 @@ Custom notifications with a lot of styling options. ```lua lib.notify(data) ``` + @@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client' lib.notify(data) ``` + @@ -44,7 +47,7 @@ lib.notify(data) ### Usage Example -### Standard +#### Standard @@ -56,6 +59,7 @@ lib.notify({ type = 'success' }) ``` + @@ -68,12 +72,13 @@ lib.notify({ type: 'success' }) ``` + ![notification](https://i.imgur.com/cRxJICO.png) -### Custom +#### Custom @@ -92,6 +97,7 @@ lib.notify({ iconColor = '#C53030' }) ``` + @@ -111,13 +117,14 @@ lib.notify({ iconColor: '#C53030' }) ``` + - ![custom_notification](https://i.imgur.com/0EK5APp.png) ## lib.defaultNotify + Default notifications provided by Chakra UI. @@ -126,6 +133,7 @@ Default notifications provided by Chakra UI. ```lua lib.defaultNotify(data) ``` + @@ -134,17 +142,17 @@ import lib from '@overextended/ox_lib/client' lib.defaultNotify(data) ``` + * id?: `number` * Same as id in `lib.notify` * title?: `string` -* description?: `string` +* description?: `string` * duration?: `number` * position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'` -* status?: `'info'` or `'warning'` or `'success'` or `'error'` - +* status?: `'info'` or `'warning'` or `'success'` or `'error'` ### Usage Example @@ -158,6 +166,7 @@ lib.defaultNotify({ status = 'success' }) ``` + @@ -170,6 +179,7 @@ lib.defaultNotify({ status: 'success' }) ``` + diff --git a/docs/ox_lib/Interface/Client/progress.md b/docs/ox_lib/Interface/Client/progress.md index 22d98082..72094b8b 100644 --- a/docs/ox_lib/Interface/Client/progress.md +++ b/docs/ox_lib/Interface/Client/progress.md @@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; ## lib.progressBar + Displays a running progress bar. @@ -14,6 +15,7 @@ Displays a running progress bar. ```lua lib.progressBar(data) ``` + @@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client' lib.progressBar(data) ``` + @@ -88,15 +91,16 @@ if lib.progressBar({ }, anim = { dict = 'mp_player_intdrink', - clip = 'loop_bottle' + clip = 'loop_bottle' }, prop = { model = `prop_ld_flow_bottle`, pos = vec3(0.03, 0.03, 0.02), - rot = vec3(0.0, 0.0, -1.5) + rot = vec3(0.0, 0.0, -1.5) }, }) then print('Do stuff when complete') else print('Do stuff when cancelled') end ``` + @@ -117,22 +121,24 @@ if (await lib.progressBar({ }, anim: { dict: 'mp_player_intdrink', - clip: 'loop_bottle' + clip: 'loop_bottle' }, prop: { model: `prop_ld_flow_bottle`, pos: {x: 0.03, y: 0.03, z: 0.02}, - rot: {x: 0.0, y: 0.0, z: -1.5} + rot: {x: 0.0, y: 0.0, z: -1.5} }, })) console.log('Do stuff when complete'); else console.log('Do stuff when cancelled') ``` + ![progress_bar](https://i.imgur.com/7pAwktr.png) ## lib.progressCircle + Similar to `lib.progressBar` except it displays a circle and you can define a position. @@ -141,6 +147,7 @@ Similar to `lib.progressBar` except it displays a circle and you can define a po ```lua lib.progressCircle(data) ``` + @@ -149,6 +156,7 @@ import lib from '@overextended/ox_lib/client' lib.progressCircle(data) ``` + @@ -217,15 +225,16 @@ if lib.progressCircle({ }, anim = { dict = 'mp_player_intdrink', - clip = 'loop_bottle' + clip = 'loop_bottle' }, prop = { model = `prop_ld_flow_bottle`, pos = vec3(0.03, 0.03, 0.02), - rot = vec3(0.0, 0.0, -1.5) + rot = vec3(0.0, 0.0, -1.5) }, }) then print('Do stuff when complete') else print('Do stuff when cancelled') end ``` + @@ -246,7 +255,7 @@ if (await lib.progressCircle({ }, anim: { dict: 'mp_player_intdrink', - clip: 'loop_bottle' + clip: 'loop_bottle' }, prop: { model: `prop_ld_flow_bottle`, @@ -256,12 +265,14 @@ if (await lib.progressCircle({ })) console.log('Do stuff when complete') else console.log('Do stuff when cancelled') ``` + ![progress_circle](https://i.imgur.com/nETRm5f.png) ## lib.progressActive + Returns true if a progress bar is currently active. @@ -270,6 +281,7 @@ Returns true if a progress bar is currently active. ```lua lib.progressActive() ``` + @@ -278,11 +290,12 @@ import lib from '@overextended/ox_lib/client' lib.progressActive() ``` + - ## lib.cancelProgress + If there is a progress bar active and the progress bar can be cancelled then it cancels it. @@ -292,6 +305,7 @@ progress bar can be cancelled then it cancels it. ```lua lib.cancelProgress() ``` + @@ -300,6 +314,6 @@ import lib from '@overextended/ox_lib/client' lib.cancelProgress() ``` + - diff --git a/docs/ox_lib/Interface/Client/skillcheck.md b/docs/ox_lib/Interface/Client/skillcheck.md index 0c380d7a..d967887a 100644 --- a/docs/ox_lib/Interface/Client/skillcheck.md +++ b/docs/ox_lib/Interface/Client/skillcheck.md @@ -15,6 +15,7 @@ Runs a skill check with the defined difficulty. ```lua lib.skillCheck(difficulty) ``` + @@ -23,10 +24,11 @@ import lib from '@overextended/ox_lib/client' lib.skillCheck(difficulty) ``` + -* difficulty: `easy` or `medium` or `hard` or `object` +* difficulty: `easy` or `medium` or `hard` or `object` * Can set custom difficulty by sending a object instead of string * { areaSize: `number`, speedMultiplier: `number` } * easy: { areaSize: 50, speedMultiplier: 1 } @@ -43,6 +45,7 @@ lib.skillCheck(difficulty) ```lua local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}) ``` + @@ -51,7 +54,8 @@ import lib from '@overextended/ox_lib/client' const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard']) ``` + -![Image](https://i.imgur.com/RWSWZ1I.png) +![skillcheck_example](https://i.imgur.com/RWSWZ1I.png) diff --git a/docs/ox_lib/Interface/Client/textui.md b/docs/ox_lib/Interface/Client/textui.md index 5b66e57c..1eb0d0ac 100644 --- a/docs/ox_lib/Interface/Client/textui.md +++ b/docs/ox_lib/Interface/Client/textui.md @@ -6,9 +6,10 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; ## lib.showTextUI + Show the TextUI window. -**DO NOT** run this every tick, it's intented to be used as a toggle. +**DO NOT** run this every tick, it's intended to be used as a toggle. @@ -16,6 +17,7 @@ Show the TextUI window. ```lua lib.showTextUI(text, options) ``` + @@ -24,11 +26,12 @@ import lib from '@overextended/ox_lib/client' lib.showTextUI(text, options) ``` + * text: `string` -* options?: `table` +* options?: `table` * position?: `'right-center'` or `'left-center'` or `'top-center'` * Default: `'right-center'` * icon?: `string` or `table` (`array`) @@ -45,6 +48,7 @@ lib.showTextUI(text, options) ```lua lib.showTextUI('[E] - Fuel vehicle') ``` + @@ -53,10 +57,11 @@ import lib from '@overextended/ox_lib/client' lib.showTextUI('[E] - Fuel vehicle') ``` + -![](https://i.imgur.com/3ptQyAq.png) +![basic_example](https://i.imgur.com/3ptQyAq.png) ### Custom styling @@ -74,6 +79,7 @@ lib.showTextUI('[E] - Pick apple', { } }) ``` + @@ -90,13 +96,14 @@ lib.showTextUI('[E] - Pick apple', { } }) ``` + -![](https://i.imgur.com/gNDwPBN.png) - +![custom_example](https://i.imgur.com/gNDwPBN.png) ### lib.hideTextUI + Hides the currently visible TextUI window @@ -105,6 +112,7 @@ Hides the currently visible TextUI window ```lua lib.hideTextUI() ``` + @@ -113,7 +121,6 @@ import lib from '@overextended/ox_lib/client' lib.hideTextUI() ``` + - - diff --git a/docs/ox_lib/Locale/Shared.md b/docs/ox_lib/Locale/Shared.md index 3c5b4737..dd24e971 100644 --- a/docs/ox_lib/Locale/Shared.md +++ b/docs/ox_lib/Locale/Shared.md @@ -1,17 +1,20 @@ -Allows servers to set a preferred language and attempt to load locale files in any resources using the module. +Allows servers to set a preferred language and attempt to load locale files in any resources using the module. Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json` To change the preferred language from English, add the convar to your server.cfg -```cfg + +```yaml setr ox:locale en ``` Initialise the locale module in your resource (once). + ```lua lib.locale() ``` Format your strings with the new locale global. + ```lua locale(str, ...) ``` @@ -26,8 +29,8 @@ Additional arguments can be sent to format the locale output. lib.locale() SetInterval(function() - print(locale('grand_theft_auto')) - print(locale('suspect_sex', locale('male'))) + print(locale('grand_theft_auto')) + print(locale('suspect_sex', locale('male'))) end, 5000) ``` @@ -51,6 +54,6 @@ end, 5000) ```lua title="fxmanifest.lua" files { - 'locales/*.json' + 'locales/*.json' } ``` diff --git a/docs/ox_lib/Logger/Server.md b/docs/ox_lib/Logger/Server.md index bbb0fe87..c3034660 100644 --- a/docs/ox_lib/Logger/Server.md +++ b/docs/ox_lib/Logger/Server.md @@ -1,12 +1,14 @@ ## Submit logs to Datadog -Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys). +Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys). Modify your `server.cfg` with the newly generated API key and [intake server](https://docs.datadoghq.com/api/latest/logs/#send-logs). + - datadoghq.com - us3.datadoghq.com - us5.datadoghq.com - datadoghq.eu -``` + +```yaml set datadog:key "yourapikey" set datadog:site "datadoghq.com" ``` @@ -14,14 +16,14 @@ set datadog:site "datadoghq.com" ```lua lib.logger(source, event, message, ...) ``` -* source: `string` or `number` -* event: `string` -* message: `string` -* ...: `string` +- source: `string` or `number` +- event: `string` +- message: `string` +- ...: `string` -Source is passed to ddsource and creates a tag. Could be playerId, identifier, -1, or server. -Event is passed to ddservice and displays in the logs list. +Source is passed to `ddsource` and creates a tag. Could be playerId, identifier, -1, or server. +Event is passed to `ddservice` and displays in the logs list. Additional arguments are converted into tags for additional filtering and search options. ```lua @@ -61,13 +63,13 @@ Once registered with Grafana Cloud, head to [My Account](https://grafana.com/aut To setup a grafana instance you'll require docker, and knowledge on containers or kubernetes. Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that. Once done, setup authentication and use the username and password securing your endpoint. -[*] Please note: By default self-hosted loki instances do not provide any authenication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access. +[*] Please note: By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access. #### Setting up Server Config Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg. -``` +```yaml set ox:logger "loki" set loki:user "" set loki:key "" @@ -76,7 +78,7 @@ set loki:endpoint "" Here is an example -``` +```yaml set ox:logger "loki" set loki:user "1337" set loki:key "alongcomplicatedsecurepassword" @@ -89,4 +91,4 @@ The data can be inserted into Loki the same way as datadog so you can follow the #### Browsing Data -If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite indepth with what you can do, you can even track metrics and economic health all from logs. +If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite in-depth with what you can do, you can even track metrics and economic health all from logs. diff --git a/docs/ox_lib/Points/Client.md b/docs/ox_lib/Points/Client.md index 48db351c..c949e1f9 100644 --- a/docs/ox_lib/Points/Client.md +++ b/docs/ox_lib/Points/Client.md @@ -1,10 +1,11 @@ # Points -Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates. +Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates. ```lua lib.points.new(coords, distance, data) ``` + * coords: `vector3` * distance: `number` * data: `table` @@ -33,6 +34,7 @@ end ``` Points can be deleted by using the remove method. + ```lua point:remove() ``` diff --git a/docs/ox_lib/Raycast/Client.md b/docs/ox_lib/Raycast/Client.md index 106dede5..5ca0dcd1 100644 --- a/docs/ox_lib/Raycast/Client.md +++ b/docs/ox_lib/Raycast/Client.md @@ -5,12 +5,14 @@ Starts a shapetest originating from the camera, extending to ~10m. ```lua function lib.raycast.cam(flags, p8) end ``` + * flags?: `number` * Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586) * p8?: `number` * A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used. Return: + * hit: `boolean` * entityHit: `number` * endCoords: `vector3` diff --git a/docs/ox_lib/Streaming/Client.md b/docs/ox_lib/Streaming/Client.md index 77bebbc4..20be729d 100644 --- a/docs/ox_lib/Streaming/Client.md +++ b/docs/ox_lib/Streaming/Client.md @@ -1,4 +1,4 @@ -Check if assets exist, such as models, and loads them into memory. +Check if assets exist, such as models, and loads them into memory. Throws errors for invalid assets and returns true if the asset is loaded. import Tabs from '@theme/Tabs'; @@ -12,6 +12,7 @@ import TabItem from '@theme/TabItem'; ```lua lib.requestAnimDict(dict, timeout) ``` + @@ -20,6 +21,7 @@ import lib from '@overextended/ox_lib/client' lib.requestAnimDict(dict, timeout) ``` + @@ -27,7 +29,6 @@ lib.requestAnimDict(dict, timeout) * timeout: `number` * Default: `100` - ### lib.requestAnimSet @@ -36,6 +37,7 @@ lib.requestAnimDict(dict, timeout) ```lua lib.requestAnimSet(set, timeout) ``` + @@ -44,6 +46,7 @@ import lib from '@overextended/ox_lib/client' lib.requestAnimSet(set, timeout) ``` + @@ -59,6 +62,7 @@ lib.requestAnimSet(set, timeout) ```lua lib.requestModel(model, timeout) ``` + @@ -67,6 +71,7 @@ import lib from '@overextended/ox_lib/client' lib.requestModel(model, timeout) ``` + @@ -74,7 +79,6 @@ lib.requestModel(model, timeout) * timeout: `number` * Default: `100` - ### lib.requestStreamedTextureDict @@ -83,6 +87,7 @@ lib.requestModel(model, timeout) ```lua lib.requestStreamedTextureDict(dict, timeout) ``` + @@ -91,6 +96,7 @@ import lib from '@overextended/ox_lib/client' lib.requestStreamedTextureDict(dict, timeout) ``` + @@ -98,7 +104,6 @@ lib.requestStreamedTextureDict(dict, timeout) * timeout: `number` * Default: `100` - ### lib.requestNamedPtfxAsset @@ -106,8 +111,8 @@ lib.requestStreamedTextureDict(dict, timeout) ```lua lib.requestNamedPtfxAsset(fxName, timeout) - ``` + @@ -116,10 +121,10 @@ import lib from '@overextended/ox_lib/client' lib.requestNamedPtfxAsset(fxName, timeout) ``` + * fxName: `string` * timeout: `number` * Default: `100` - diff --git a/docs/ox_lib/VehicleProperties/Client.md b/docs/ox_lib/VehicleProperties/Client.md index 7071cacc..429fd107 100644 --- a/docs/ox_lib/VehicleProperties/Client.md +++ b/docs/ox_lib/VehicleProperties/Client.md @@ -1,4 +1,4 @@ -Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props. +Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props. https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5 import Tabs from '@theme/Tabs'; @@ -6,10 +6,10 @@ import TabItem from '@theme/TabItem'; ### lib.getVehicleProperties - ```ts lib.getVehicleProperties(vehicle) ``` + * vehicle: `entity` @@ -18,6 +18,7 @@ lib.getVehicleProperties(vehicle) ```lua lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId())) ``` + @@ -26,16 +27,18 @@ import lib from '@overextended/ox_lib/client' lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId())) ``` + - ### lib.setVehicleProperties + Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_. ```lua lib.setVehicleProperties(vehicle, props) ``` + * vehicle: `entity` * props: `table` (`object`) @@ -47,6 +50,7 @@ RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data) lib.setVehicleProperties(NetToVeh(netid), data) end) ``` + @@ -57,13 +61,14 @@ onNet('ox_lib:setVehicleProperties', (netid, data) => { lib.setVehicleProperties(NetToVeh(netid), data) }) ``` + - - #### Recommended usage + The server should tell the owner of the entity to set properties, using the following trigger. + ```lua TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data) ``` diff --git a/docs/ox_lib/Version/Server.md b/docs/ox_lib/Version/Server.md index 731e2d86..033cf90c 100644 --- a/docs/ox_lib/Version/Server.md +++ b/docs/ox_lib/Version/Server.md @@ -1,5 +1,6 @@ ### lib.versionCheck -Compares the resource version to the latest published release on GitHub. + +Compares the resource version to the latest published release on GitHub. import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; @@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem'; ```lua lib.versionCheck(repository) ``` + * repository: `string` @@ -15,6 +17,7 @@ lib.versionCheck(repository) ```lua lib.versionCheck('overextended/ox_lib') ``` + @@ -23,6 +26,7 @@ import lib from '@overextended/ox_lib/server' lib.versionCheck('overextended/ox_lib') ``` + diff --git a/docs/ox_lib/Version/Shared.md b/docs/ox_lib/Version/Shared.md index 07328b5b..ce4c1d97 100644 --- a/docs/ox_lib/Version/Shared.md +++ b/docs/ox_lib/Version/Shared.md @@ -1,4 +1,5 @@ ### lib.checkDependency + Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors. import Tabs from '@theme/Tabs'; @@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem'; ```lua lib.checkDependency(resource, version) ``` + * resource: `string` * version: `string` @@ -16,6 +18,7 @@ lib.checkDependency(resource, version) ```lua if not lib.checkDependency('ox_lib', '1.5.0') then error() end ``` + @@ -25,7 +28,6 @@ import lib from '@overextended/ox_lib/shared' if (!lib.checkDependency('ox_lib', '1.5.0')) error() ``` + - - diff --git a/docs/ox_lib/Zones/Client.md b/docs/ox_lib/Zones/Client.md index 355b1652..c090434d 100644 --- a/docs/ox_lib/Zones/Client.md +++ b/docs/ox_lib/Zones/Client.md @@ -5,6 +5,7 @@ Faster alternative to PolyZone utilising [glm.polygon](https://github.com/gottfr ```lua lib.zones.poly(data) ``` + * data: `table` * points: `vector3[]` * All z values must match @@ -20,6 +21,7 @@ lib.zones.poly(data) ```lua lib.zones.box(data) ``` + * data: `table` * coords: `vector3` * size?: `vector3` @@ -36,6 +38,7 @@ lib.zones.box(data) ```lua lib.zones.sphere(data) ``` + * data: `table` * coords: `vector3` * radius?: `number` @@ -75,11 +78,11 @@ local poly = lib.zones.poly({ vec(420.0, -1030.2, 29), vec(409.8, -1028.4, 29), }, - thickness = 2, - debug = true, - inside = inside, - onEnter = onEnter, - onExit = onExit + thickness = 2, + debug = true, + inside = inside, + onEnter = onEnter, + onExit = onExit }) local sphere = lib.zones.sphere({ @@ -92,17 +95,18 @@ local sphere = lib.zones.sphere({ }) local box = lib.zones.box({ - coords = vec3(442.5363, -1017.666, 28.65637), - size = vec3(1, 1, 1), - rotation = 45, - debug = true, - inside = insideZone, - onEnter = onEnter, - onExit = onExit + coords = vec3(442.5363, -1017.666, 28.65637), + size = vec3(1, 1, 1), + rotation = 45, + debug = true, + inside = insideZone, + onEnter = onEnter, + onExit = onExit }) ``` Zones can be deleted by using the remove method. + ```lua poly:remove() sphere:remove() @@ -110,11 +114,11 @@ box:remove() ``` ## Zone creation script + Similarly to PolyZone, there is a zone creation script included. To use it use the `/zone` with `poly`, `box` or `sphere` as args. Available controls will be displayed on the right side. -Once saved you will find the created zone details in created_zones.lua withn ox_lib - +Once saved you will find the created zone details in created_zones.lua within ox_lib diff --git a/docs/ox_lib/index.md b/docs/ox_lib/index.md index af070a00..f6005759 100644 --- a/docs/ox_lib/index.md +++ b/docs/ox_lib/index.md @@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem'; ox_lib is a collection of Lua and UI functions to utilise in other resources. -The UI is built in React so the code needs to be compiled into standard JS. +The UI is built in React so the code needs to be compiled into standard JS. If you don't know how to do this then please download the [release](https://github.com/overextended/ox_lib/releases/latest) (ox_lib.zip) which is *already* compiled into a working resource. @@ -28,6 +28,7 @@ Or if the library is the only shared script you use you can do: ```lua shared_script '@ox_lib/init.lua' ``` + @@ -39,7 +40,7 @@ All supported functions are located inside the `resource` folder in the lib. You can get the npm package [here](https://npmjs.com/package/@overextended/ox_lib). -**Usage:** +**Usage:** You can either import the whole library object which contains all the functions for that scope (client/server/shared) or you can deconstruct it and import the functions you find needed at the time. @@ -50,25 +51,27 @@ import lib from '@overextended/ox_lib/server' ```ts import { versionCheck } from '@overextended/ox_lib/server' ``` + **ACE Permissions:** -``` + +```yaml add_ace resource.ox_lib command.add_ace allow add_ace resource.ox_lib command.remove_ace allow add_ace resource.ox_lib command.add_principal allow add_ace resource.ox_lib command.remove_principal allow ``` -That's it! +That's it! You can now use the library functions inside of your resource, check the rest of the documentation to see how to utilise them. -# Using icons for interface functions +## Using icons for interface functions The icon library used is Font Awesome 6.0, if for the icon you define only a string -the default icon type will be `solid`. +the default icon type will be `solid`. If you want to use a different icon type, i.e apple as a brand, you need to define icon as a table (`array`) with the first value being the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name. @@ -79,23 +82,25 @@ the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon n ```lua icon = {'fab', 'apple'} ``` + ```ts icon: ['fab', 'apple'] ``` + -# Building the UI +## Building the UI If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then compile it. :::danger -**DO NOT** debundle and unminify the release CSS and JS files to edit them. +**DO NOT** de-bundle and un-minify the release CSS and JS files to edit them. ::: **Requirements:** diff --git a/docs/ox_target/Getting Started/index.md b/docs/ox_target/Getting Started/index.md index 2e844982..5ceab916 100644 --- a/docs/ox_target/Getting Started/index.md +++ b/docs/ox_target/Getting Started/index.md @@ -8,7 +8,7 @@ slug: ./../ We always recommend using Git so you can track changes and update easily. -``` +```bash git clone https://github.com/overextended/ox_target.git ``` diff --git a/docs/ox_target/Usage/Globals.md b/docs/ox_target/Usage/Globals.md index 5cbf63aa..26e0a25b 100644 --- a/docs/ox_target/Usage/Globals.md +++ b/docs/ox_target/Usage/Globals.md @@ -2,7 +2,7 @@ Registers options that will apply to all entities of that type (object, ped, pla ```lua local options = { - { + { name = 'ox:option1', event = 'ox_target:debug', icon = 'fa-solid fa-road', diff --git a/docs/ox_target/Usage/Target.md b/docs/ox_target/Usage/Target.md index ab56b7d9..8fad683b 100644 --- a/docs/ox_target/Usage/Target.md +++ b/docs/ox_target/Usage/Target.md @@ -1,6 +1,6 @@ ```lua local options = { - { + { name = 'ox:option1', event = 'ox_target:debug', icon = 'fa-solid fa-road', @@ -42,7 +42,7 @@ exports.ox_target:removeModel(models, optionNames) ## addEntity -Add new options when targeting a networked entity matching the given netid or list of netids. +Add new options when targeting a networked entity matching the given netid or list of netIds. Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id. ```lua @@ -51,14 +51,13 @@ exports.ox_target:addEntity(netIds, options) ## removeEntity -Remove options from a networked entity matching the given netid or list of netids. +Remove options from a networked entity matching the given netid or list of netIds. Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id. ```lua exports.ox_target:removeEntity(netIds, optionNames) ``` - ## addLocalEntity Add new options when targeting a local entity or list of entities. diff --git a/docs/ox_target/Usage/Zones.md b/docs/ox_target/Usage/Zones.md index 45526d17..087f0075 100644 --- a/docs/ox_target/Usage/Zones.md +++ b/docs/ox_target/Usage/Zones.md @@ -10,11 +10,11 @@ exports.ox_target:addSphereZone(parameters) ```lua { - coords = vector3, - radius = number, - debug? = boolean, - drawSprite? = boolean, - options = options, + coords = vector3, + radius = number, + debug? = boolean, + drawSprite? = boolean, + options = options, } ``` @@ -49,12 +49,12 @@ exports.ox_target:addBoxZone(parameters) ```lua { - coords = vector3, - size = vector3, - rotation = number, - debug? = boolean, - drawSprite? = boolean, - options = options, + coords = vector3, + size = vector3, + rotation = number, + debug? = boolean, + drawSprite? = boolean, + options = options, } ``` diff --git a/docs/ox_target/Usage/index.md b/docs/ox_target/Usage/index.md index 1f143114..bbc2d6d5 100644 --- a/docs/ox_target/Usage/index.md +++ b/docs/ox_target/Usage/index.md @@ -4,27 +4,27 @@ When calling exports to add options, the input is an array of tables with the fo ```lua { - -- an identifier used when removing options - name? = string, - -- an icon from font-awesome - icon? = string, - -- display text - label = string, - -- range to display (default: 2, max: 7) - distance? = number, - -- a group, array of groups, or groups and grades needed to display - groups? = string | string[] | { [string]: number } - -- an item, array of items, or items and counts needed to display - items? = string | string[] | { [string]: number } - -- a bone, bones table to select specific parts - bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' } - -- custom check to hide or display the option - canInteract? = function(entity, distance, coords, name, bone), - -- triggered on option selection (one only) - onSelect? = function(data), - export? = string, - event? = string, - serverEvent? = string, - command? = string + -- an identifier used when removing options + name? = string, + -- an icon from font-awesome + icon? = string, + -- display text + label = string, + -- range to display (default: 2, max: 7) + distance? = number, + -- a group, array of groups, or groups and grades needed to display + groups? = string | string[] | { [string]: number } + -- an item, array of items, or items and counts needed to display + items? = string | string[] | { [string]: number } + -- a bone, bones table to select specific parts + bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' } + -- custom check to hide or display the option + canInteract? = function(entity, distance, coords, name, bone), + -- triggered on option selection (one only) + onSelect? = function(data), + export? = string, + event? = string, + serverEvent? = string, + command? = string } ``` diff --git a/docs/oxmysql/Getting Started/benchmark.md b/docs/oxmysql/Getting Started/benchmark.md index ead34a08..f45d22b9 100644 --- a/docs/oxmysql/Getting Started/benchmark.md +++ b/docs/oxmysql/Getting Started/benchmark.md @@ -1,16 +1,19 @@ # Benchmark Internal benchmark -``` + +```md Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries) ``` Round-trip-time for exports -``` + +```md Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries) ``` -#### Lua (5.4) +## Lua (5.4) + ```lua local val = 10000 RegisterCommand('luasync', function() @@ -38,7 +41,8 @@ RegisterCommand('luasync', function() end) ``` -#### JavaScript +## JavaScript + ```js const val = 10000 RegisterCommand('jssync', async() => { @@ -60,4 +64,4 @@ RegisterCommand('jssync', async() => { console.log(result) console.log('Low: '+ queryMsLow +'ms | Avg: '+averageQueryTime+'ms | Total: '+queryMsSum+'ms ('+queryTimesLocal.length+' queries)') }) -``` \ No newline at end of file +``` diff --git a/docs/oxmysql/Getting Started/index.md b/docs/oxmysql/Getting Started/index.md index 1dbf7957..d5ba6d21 100644 --- a/docs/oxmysql/Getting Started/index.md +++ b/docs/oxmysql/Getting Started/index.md @@ -31,23 +31,21 @@ Reference the following for an idea of how to set your connection options. You must include one of the following lines, adjusted for your connection and database settings. :::caution - -When using convars do not replicate sensitive information to the client. +When using convars do not replicate sensitive information to the client. **set** will only be set on the server, while **setr** is replicated. - ::: -``` +```yaml set mysql_connection_string "mysql://root:12345@localhost:3306/es_extended?charset=utf8mb4" set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=es_extended;charset=utf8mb4" ``` -Certain special characters are reserved or blocked and may cause issues when used in your password. +Certain special characters are reserved or blocked and may cause issues when used in your password. For more optional settings (such as multiple statements) you can reference [pool.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Pool.d.ts#L10) and [connection.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L8). You can also add the following convars if you require extra information when testing queries. -```json +```yaml set mysql_slow_query_warning 150 set mysql_debug true ``` @@ -56,7 +54,7 @@ set mysql_debug true When using the `mysql_debug` convar, rather than setting the value as true, you can send an array and enable debug prints for a set list of resources instead. -```json +```yaml set mysql_debug [ "ox_core", "ox_inventory" @@ -65,7 +63,7 @@ set mysql_debug [ This list can be adjusted during runtime with commands, temporarily adding or removing resources until the resource is restarted. -``` +```yaml oxmysql_debug remove ox_core oxmysql_debug add ox_core ``` @@ -74,7 +72,7 @@ oxmysql_debug add ox_core Before using the UI first you have to make sure you have the `mysql_ui` convar set to true: -```json +```yaml set mysql_ui true ``` @@ -83,14 +81,14 @@ Also make sure that you have `command` ace permission access, then you should be ## Compatibility -You shouldn't run multiple mysql resources to ensure the best experience. +You shouldn't run multiple mysql resources to ensure the best experience. The resources listed below can be deleted to allow oxmysql to handle the events, without any changes. ### mysql-async -Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`. +Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`. Raw exports, mostly used in resources written in JavaScript or C#, are _not supported_. ### ghmattimysql -As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`. +As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`. diff --git a/docs/oxmysql/Getting Started/issues.md b/docs/oxmysql/Getting Started/issues.md index e0e0b30d..bc3c0492 100644 --- a/docs/oxmysql/Getting Started/issues.md +++ b/docs/oxmysql/Getting Started/issues.md @@ -1,21 +1,24 @@ # Common Issues ### Unable to establish a connection + This is usually the result of incorrect database settings or your password containing reserved characters (`; , / ? : @ & = + $ #`). :::tip Solution -Ensure you have entered the correct database settings in the mysql_connection_string convar. +Ensure you have entered the correct database settings in the mysql_connection_string convar. You can try using the semicolon-separated format if your password contains reserved characters. ::: ### No such export ... in resource oxmysql + Typically the result of failing to follow instructions. :::tip Solution Download the latest release _build_ (not source) of oxmysql, and ensure it is starting before any resources that require it. ::: ### Numbers treated as string + This is an incompatibility between mysqljs (used by mysql-async) and mysql2 (used by oxmysql) (See [Known incompatibilities with node-mysql](https://github.com/sidorares/node-mysql2/tree/master/documentation#known-incompatibilities-with-node-mysql)) To resolve this issue simply add `&decimalNumbers=true` to the connection string, ie. `mysql://root@localhost/essentialmode?charset=utf8mb4_general_ci&decimalNumbers=true` to revert to the behavior of mysqljs. -Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way. \ No newline at end of file +Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way. diff --git a/docs/oxmysql/Getting Started/placeholders.md b/docs/oxmysql/Getting Started/placeholders.md index 4fdb8c88..23b4bfd0 100644 --- a/docs/oxmysql/Getting Started/placeholders.md +++ b/docs/oxmysql/Getting Started/placeholders.md @@ -2,7 +2,7 @@ This allows queries to be properly prepared and escaped; the following lines are equivalent. -``` +```lua "SELECT group FROM users WHERE identifier = ?", {identifier} "SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier} "SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier} diff --git a/docs/oxmysql/Usage/index.md b/docs/oxmysql/Usage/index.md index c0ce8c37..236e398e 100644 --- a/docs/oxmysql/Usage/index.md +++ b/docs/oxmysql/Usage/index.md @@ -24,7 +24,7 @@ If you are using VSCode with [sumneko Lua](https://marketplace.visualstudio.com/ Use your favourite package manager to install our [node package](https://www.npmjs.com/package/@overextended/oxmysql). -```yaml +```bash # With pnpm pnpm add @overextended/oxmysql @@ -43,7 +43,7 @@ import { oxmysql as MySQL } from '@overextended/oxmysql'; ## Placeholders -Safely format queries by using placeholders in the query, and sending arguments in an array or object. +Safely format queries by using placeholders in the query, and sending arguments in an array or object. Named placeholders are not recommended, and unsupported when using MySQL.prepare. ```lua @@ -59,5 +59,5 @@ When uncertain if a row should be inserted into the database, or an existing row MySQL.prepare('INSERT INTO ox_inventory (owner, name, data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)', { owner, dbId, inventory }) ``` -This is preferred over checking the existence of a row, then inserting or updating depending on the result. +This is preferred over checking the existence of a row, then inserting or updating depending on the result. Furthermore, unlike using 'REPLACE INTO', the row is not deleted and re-inserted. diff --git a/docs/oxmysql/Usage/insert.md b/docs/oxmysql/Usage/insert.md index 68565a63..62c1b47e 100644 --- a/docs/oxmysql/Usage/insert.md +++ b/docs/oxmysql/Usage/insert.md @@ -5,6 +5,7 @@ Inserts a new entry into the database and returns the insert id for the row, if ## Lua ### Callback + ```lua -- alias: exports.oxmysql:insert -- alias: MySQL.Async.insert @@ -15,6 +16,7 @@ end) ``` ### Promise + ```lua -- alias: exports.oxmysql:insert_async -- alias: MySQL.Sync.insert @@ -26,6 +28,7 @@ print(id) ## JavaScript ### Callback + ```js // alias: exports.oxmysql.insert @@ -35,6 +38,7 @@ MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ``` ### Promise + ```js // alias: exports.oxmysql.insert_async diff --git a/docs/oxmysql/Usage/prepare.md b/docs/oxmysql/Usage/prepare.md index 8bf69aee..2bf51aab 100644 --- a/docs/oxmysql/Usage/prepare.md +++ b/docs/oxmysql/Usage/prepare.md @@ -1,17 +1,18 @@ # Prepare -The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL. -Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query. +The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL. +Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query. - Date will not return the datestring commonly used in FiveM - TINYINT 1 and BIT will not return a boolean -- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error +- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error When using SELECT, the return value will match `query, single, or scalar` depending on the number of columns and rows selected. ## Lua ### Callback + ```lua -- alias: exports.oxmysql:prepare -- alias: MySQL.Async.prepare @@ -24,6 +25,7 @@ end) ``` ### Promise + ```lua -- alias: exports.oxmysql:prepare_async -- alias: MySQL.Sync.prepare @@ -37,6 +39,7 @@ end ## JavaScript ### Callback + ```js // alias: exports.oxmysql.prepare @@ -48,6 +51,7 @@ MySQL.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (r ``` ### Promise + ```js // alias: exports.oxmysql.prepare_async diff --git a/docs/oxmysql/Usage/query.md b/docs/oxmysql/Usage/query.md index 119bff1a..82ffe2cd 100644 --- a/docs/oxmysql/Usage/query.md +++ b/docs/oxmysql/Usage/query.md @@ -1,10 +1,12 @@ # Query -Generic function that can be utilised for any query. + +Generic function that can be utilised for any query. When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc. ## Lua ### Callback + ```lua -- alias: exports.oxmysql:query -- alias: MySQL.Async.query @@ -18,7 +20,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, func end end) ``` + ### Promise + ```lua -- alias: exports.oxmysql:query_async -- alias: MySQL.Sync.query @@ -35,6 +39,7 @@ end ## JavaScript ### Callback + ```js // alias: exports.oxmysql.query @@ -46,7 +51,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (res } }) ``` + ### Promise + ```js // alias: exports.oxmysql.query_async diff --git a/docs/oxmysql/Usage/scalar.md b/docs/oxmysql/Usage/scalar.md index 7541238c..20582e01 100644 --- a/docs/oxmysql/Usage/scalar.md +++ b/docs/oxmysql/Usage/scalar.md @@ -1,9 +1,11 @@ # Scalar + Returns the first column for a single row. ## Lua ### Callback + ```lua -- alias: exports.oxmysql:scalar -- alias: MySQL.Async.fetchScalar @@ -14,6 +16,7 @@ end) ``` ### Promise + ```lua -- alias: exports.oxmysql:scalar_async -- alias: MySQL.Sync.fetchScalar @@ -25,6 +28,7 @@ print(firstname) ## JavaScript ### Callback + ```js // alias: exports.oxmysql.scalar @@ -34,6 +38,7 @@ MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifi ``` ### Promise + ```js // alias: exports.oxmysql.scalar_async diff --git a/docs/oxmysql/Usage/single.md b/docs/oxmysql/Usage/single.md index 8b6ad0c2..da18b0f5 100644 --- a/docs/oxmysql/Usage/single.md +++ b/docs/oxmysql/Usage/single.md @@ -1,9 +1,11 @@ # Single + Returns the columns for a single row. ## Lua ### Callback + ```lua -- alias: exports.oxmysql:single -- alias: MySQL.Async.fetchSingle @@ -16,6 +18,7 @@ end) ``` ### Promise + ```lua -- alias: exports.oxmysql:single_async -- alias: MySQL.Sync.fetchSingle @@ -29,6 +32,7 @@ end ## JavaScript ### Callback + ```js // alias: exports.oxmysql.single @@ -40,6 +44,7 @@ MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row ``` ### Promise + ```js // alias: exports.oxmysql.single_async diff --git a/docs/oxmysql/Usage/transaction.md b/docs/oxmysql/Usage/transaction.md index ef60bed0..14d3fe8f 100644 --- a/docs/oxmysql/Usage/transaction.md +++ b/docs/oxmysql/Usage/transaction.md @@ -67,7 +67,7 @@ console.log(success); ## Shared Format -When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use. +When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use. This is useful if your queries use the same SQL variables. ### Lua diff --git a/docs/oxmysql/Usage/update.md b/docs/oxmysql/Usage/update.md index 3087a511..303a0a7d 100644 --- a/docs/oxmysql/Usage/update.md +++ b/docs/oxmysql/Usage/update.md @@ -1,9 +1,11 @@ # Update + Returns the number of affected rows by the query. ## Lua ### Callback + ```lua -- alias: exports.oxmysql:update -- alias: MySQL.Async.execute @@ -16,6 +18,7 @@ end) ``` ### Promise + ```lua -- alias: exports.oxmysql:update_async -- alias: MySQL.Sync.execute @@ -29,6 +32,7 @@ end ## JavaScript ### Callback + ```js // alias: exports.oxmysql.update @@ -40,6 +44,7 @@ MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, p ``` ### Promise + ```js // alias: exports.oxmysql.update_async