From 8ca3c1bdfc1fa09751dafdb943c95d6a2360aec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Raty=C5=84ski?= Date: Thu, 20 Apr 2023 16:07:57 +0200 Subject: [PATCH] Update for docs (#116) * Update for docs * More changes and fix --- docs/ox_fuel/Functions/Client.md | 17 +++++++ docs/ox_fuel/Functions/Server.md | 20 ++++++++ docs/ox_lib/Cache/Client.md | 2 + docs/ox_lib/Cron/Server.md | 16 +++++++ docs/ox_lib/GetClosestPlayer/Client.md | 2 +- docs/ox_lib/GetClosestVehicle/Client.md | 2 +- docs/ox_lib/GetNearbyPlayers/Client.md | 2 +- docs/ox_lib/GetNearbyVehicles/Client.md | 2 +- docs/ox_lib/Interface/Client/alert.md | 13 +++++ docs/ox_lib/Interface/Client/notify.md | 13 +++++ docs/ox_lib/Interface/Client/radial.md | 1 + docs/ox_lib/Raycast/Client.md | 5 +- docs/ox_lib/Streaming/Client.md | 55 ++++++++++++++++++++++ docs/ox_lib/Table/Shared.md | 34 +++++++++++++ docs/ox_lib/Zones/{Client.md => Shared.md} | 0 docs/ox_target/Usage/Zones.md | 2 +- docs/oxmysql/Usage/insert.md | 2 + docs/oxmysql/Usage/query.md | 2 + docs/oxmysql/Usage/scalar.md | 2 + docs/oxmysql/Usage/transaction.md | 3 ++ docs/oxmysql/Usage/update.md | 2 + 21 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 docs/ox_fuel/Functions/Client.md create mode 100644 docs/ox_fuel/Functions/Server.md create mode 100644 docs/ox_lib/Cron/Server.md create mode 100644 docs/ox_lib/Table/Shared.md rename docs/ox_lib/Zones/{Client.md => Shared.md} (100%) diff --git a/docs/ox_fuel/Functions/Client.md b/docs/ox_fuel/Functions/Client.md new file mode 100644 index 00000000..6acdd4db --- /dev/null +++ b/docs/ox_fuel/Functions/Client.md @@ -0,0 +1,17 @@ +### setMoneyCheck + +Replaces the standard inventory search for "money". + +```lua +exports.ox_fuel:setMoneyCheck(function() + local accounts = ESX.GetPlayerData().accounts + + for i = 1, #accounts do + if accounts[i].name == 'bank' then + return accounts[i].money + end + end + + return 0 +end) +``` diff --git a/docs/ox_fuel/Functions/Server.md b/docs/ox_fuel/Functions/Server.md new file mode 100644 index 00000000..b09d2d0a --- /dev/null +++ b/docs/ox_fuel/Functions/Server.md @@ -0,0 +1,20 @@ +### setPaymentMethod + +Replaces the standard payment method using "money" as an item. + +```lua +exports.ox_fuel:setPaymentMethod(function(playerId, amount) + local xPlayer = ESX.GetPlayerFromId(playerId) + local bankAmount = xPlayer.getAccount('bank').money + + if bankAmount >= amount then + xPlayer.removeAccountMoney('bank', amount) + return true + end + + TriggerClientEvent('ox_lib:notify', source, { + type = 'error', + description = locale('not_enough_money', amount - bankAmount) + }) +end) +``` diff --git a/docs/ox_lib/Cache/Client.md b/docs/ox_lib/Cache/Client.md index c03be323..bffb592f 100644 --- a/docs/ox_lib/Cache/Client.md +++ b/docs/ox_lib/Cache/Client.md @@ -24,6 +24,8 @@ An interval runs every 100ms to update data that cannot be checked via handlers. - current player coords - only populated if using `zones` or `points` - cannot be listened for with `onCache` +- mount: `number` or `false` (RedM only) + - mount entity id ## lib.onCache diff --git a/docs/ox_lib/Cron/Server.md b/docs/ox_lib/Cron/Server.md new file mode 100644 index 00000000..afde8cbf --- /dev/null +++ b/docs/ox_lib/Cron/Server.md @@ -0,0 +1,16 @@ +### lib.cron.new + +Creates a new [cronjob](https://en.wikipedia.org/wiki/Cron), scheduling a task to run at fixed times or intervals. +Supports numbers, any value `*`, lists `1,2,3`, ranges `1-3`, and steps `*/4`. +Day of the week is a range of `1-7` starting from Sunday and allows short-names (i.e. sun, mon, tue). + +```lua +lib.cron.new(expression, job, options) +``` + +* expression: + * string A cron expression such as `* * * * *` representing minute, hour, day, month, and day of the week +* job: + * fun(task: `OxTask`, date: `osdate`) +* options?: + * debug?: `boolean` diff --git a/docs/ox_lib/GetClosestPlayer/Client.md b/docs/ox_lib/GetClosestPlayer/Client.md index 4ccd7f35..9fe7bcd2 100644 --- a/docs/ox_lib/GetClosestPlayer/Client.md +++ b/docs/ox_lib/GetClosestPlayer/Client.md @@ -3,7 +3,7 @@ Get the id, ped, and coords of the closest player to a set of coordinates. ```lua -function lib.getClosestPlayer(coords, maxDistance, includePlayer) end +lib.getClosestPlayer(coords, maxDistance, includePlayer) ``` * coords: `vector3` diff --git a/docs/ox_lib/GetClosestVehicle/Client.md b/docs/ox_lib/GetClosestVehicle/Client.md index bd9a999f..3ad980d5 100644 --- a/docs/ox_lib/GetClosestVehicle/Client.md +++ b/docs/ox_lib/GetClosestVehicle/Client.md @@ -3,7 +3,7 @@ Get the id and coords of the closest vehicle to a set of coordinates. ```lua -function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end +lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) ``` * coords: `vector3` diff --git a/docs/ox_lib/GetNearbyPlayers/Client.md b/docs/ox_lib/GetNearbyPlayers/Client.md index 121cde84..25674f31 100644 --- a/docs/ox_lib/GetNearbyPlayers/Client.md +++ b/docs/ox_lib/GetNearbyPlayers/Client.md @@ -3,7 +3,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 +lib.getNearbyPlayers(coords, maxDistance, includePlayer) ``` * coords: `vector3` diff --git a/docs/ox_lib/GetNearbyVehicles/Client.md b/docs/ox_lib/GetNearbyVehicles/Client.md index b7bbf780..7da79f13 100644 --- a/docs/ox_lib/GetNearbyVehicles/Client.md +++ b/docs/ox_lib/GetNearbyVehicles/Client.md @@ -3,7 +3,7 @@ Get the id and coords of all vehicles within range of a set of coordinates. ```lua -function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end +lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) ``` * coords: `vector3` diff --git a/docs/ox_lib/Interface/Client/alert.md b/docs/ox_lib/Interface/Client/alert.md index be6c1fe9..ac77f410 100644 --- a/docs/ox_lib/Interface/Client/alert.md +++ b/docs/ox_lib/Interface/Client/alert.md @@ -13,10 +13,23 @@ Returns whether the player pressed the confirm button or canceled the dialog. + + + ```lua lib.alertDialog(data) ``` + + + +```lua +TriggerClientEvent('ox_lib:alertDialog', source, data) +``` + + + + diff --git a/docs/ox_lib/Interface/Client/notify.md b/docs/ox_lib/Interface/Client/notify.md index b6ea5be8..fdfb8e87 100644 --- a/docs/ox_lib/Interface/Client/notify.md +++ b/docs/ox_lib/Interface/Client/notify.md @@ -12,10 +12,23 @@ Custom notifications with a lot of styling options. + + + ```lua lib.notify(data) ``` + + + +```lua +TriggerClientEvent('ox_lib:notify', source, data) +``` + + + + diff --git a/docs/ox_lib/Interface/Client/radial.md b/docs/ox_lib/Interface/Client/radial.md index 563acffb..e2c35183 100644 --- a/docs/ox_lib/Interface/Client/radial.md +++ b/docs/ox_lib/Interface/Client/radial.md @@ -38,6 +38,7 @@ lib.addRadialItem(items) * Id of a menu to open. * onSelect: `function(currentMenu: string | nil, itemIndex: number)` | `string` * Function that's ran when a user clicks the item. +* keepOpen?: `boolean` ### lib.removeRadialItem diff --git a/docs/ox_lib/Raycast/Client.md b/docs/ox_lib/Raycast/Client.md index 5ca0dcd1..ad1e0366 100644 --- a/docs/ox_lib/Raycast/Client.md +++ b/docs/ox_lib/Raycast/Client.md @@ -3,13 +3,14 @@ Starts a shapetest originating from the camera, extending to ~10m. ```lua -function lib.raycast.cam(flags, p8) end +lib.raycast.cam(flags, ignore, distance) ``` * flags?: `number` * Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586) -* p8?: `number` +* ignore?: `number` * A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used. +* distance?: `number` Return: diff --git a/docs/ox_lib/Streaming/Client.md b/docs/ox_lib/Streaming/Client.md index cfc0cef8..23106a1b 100644 --- a/docs/ox_lib/Streaming/Client.md +++ b/docs/ox_lib/Streaming/Client.md @@ -153,3 +153,58 @@ lib.requestScaleformMovie(scaleformMovie, timeout) * dict: `string` * timeout: `number` * Default: `100` + +### lib.requestWeaponAsset + + + + +```lua +lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags) +``` + + + + +```ts +import lib from '@overextended/ox_lib/client' + +lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags) +``` + + + + +* weaponType: `string | number` +* timeout: `number?` + * Number of ticks to wait for the asset to load. Default is `500` +* weaponResourceFlags: `WeaponResourceFlags?` + * Default is `31` +* extraWeaponComponentFlags: `ExtraWeaponComponentFlags?` + * Default is `0` + +Return: +* `string | number?` weaponType + +### WeaponResourceFlags + +``` +1 WRF_REQUEST_BASE_ANIMS +2 WRF_REQUEST_COVER_ANIMS +4 WRF_REQUEST_MELEE_ANIMS +8 WRF_REQUEST_MOTION_ANIMS +16 WRF_REQUEST_STEALTH_ANIMS +32 WRF_REQUEST_ALL_MOVEMENT_VARIATION_ANIMS +31 WRF_REQUEST_ALL_ANIMS +``` + +### ExtraWeaponComponentFlags + +``` +0 WEAPON_COMPONENT_NONE +1 WEAPON_COMPONENT_FLASH +2 WEAPON_COMPONENT_SCOPE +4 WEAPON_COMPONENT_SUPP +8 WEAPON_COMPONENT_SCLIP2 +16 WEAPON_COMPONENT_GRIP +``` diff --git a/docs/ox_lib/Table/Shared.md b/docs/ox_lib/Table/Shared.md new file mode 100644 index 00000000..3e1b409f --- /dev/null +++ b/docs/ox_lib/Table/Shared.md @@ -0,0 +1,34 @@ +## lib.table.contains + +```lua +lib.table.contains(table, value) +``` + +* table: `table` +* value: `any` + +## lib.table.matches + +```lua +lib.table.matches(tableOne, tableTwo) +``` + +* tableOne: `table`. +* tableTwo: `table` + +## lib.table.deepclone + +```lua +lib.table.deepclone(table) +``` + +* table: `table` + +## lib.table.merge + +```lua +lib.table.merge(tableOne, tableTwo) +``` + +* tableOne: `table` +* tableTwo: `table` diff --git a/docs/ox_lib/Zones/Client.md b/docs/ox_lib/Zones/Shared.md similarity index 100% rename from docs/ox_lib/Zones/Client.md rename to docs/ox_lib/Zones/Shared.md diff --git a/docs/ox_target/Usage/Zones.md b/docs/ox_target/Usage/Zones.md index 601c1c2a..46d8344b 100644 --- a/docs/ox_target/Usage/Zones.md +++ b/docs/ox_target/Usage/Zones.md @@ -1,4 +1,4 @@ -The input for zones differs slightly from all other options, instead taking the [zone](../../ox_lib/Zones/Client.md) properties and two additional properties (drawSprite, and options). +The input for zones differs slightly from all other options, instead taking the [zone](../../ox_lib/Zones/Shared.md) properties and two additional properties (drawSprite, and options). ## addSphereZone diff --git a/docs/oxmysql/Usage/insert.md b/docs/oxmysql/Usage/insert.md index 62c1b47e..421c8ea5 100644 --- a/docs/oxmysql/Usage/insert.md +++ b/docs/oxmysql/Usage/insert.md @@ -9,6 +9,7 @@ Inserts a new entry into the database and returns the insert id for the row, if ```lua -- alias: exports.oxmysql:insert -- alias: MySQL.Async.insert +-- alias: exports.ghmattimysql:execute MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName}, function(id) print(id) @@ -20,6 +21,7 @@ end) ```lua -- alias: exports.oxmysql:insert_async -- alias: MySQL.Sync.insert +-- alias: exports.ghmattimysql:executeSync local id = MySQL.insert.await('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName}) print(id) diff --git a/docs/oxmysql/Usage/query.md b/docs/oxmysql/Usage/query.md index 9123da24..4e28dd5a 100644 --- a/docs/oxmysql/Usage/query.md +++ b/docs/oxmysql/Usage/query.md @@ -10,6 +10,7 @@ When selecting data it will return all matching rows and columns, otherwise it w ```lua -- alias: exports.oxmysql:query -- alias: MySQL.Async.query +-- alias: exports.ghmattimysql:execute MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result) if result then @@ -26,6 +27,7 @@ end) ```lua -- alias: exports.oxmysql:query_async -- alias: MySQL.Sync.query +-- alias: exports.ghmattimysql:executeSync local result = MySQL.query.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}) if result then diff --git a/docs/oxmysql/Usage/scalar.md b/docs/oxmysql/Usage/scalar.md index 20582e01..ccc58d7d 100644 --- a/docs/oxmysql/Usage/scalar.md +++ b/docs/oxmysql/Usage/scalar.md @@ -9,6 +9,7 @@ Returns the first column for a single row. ```lua -- alias: exports.oxmysql:scalar -- alias: MySQL.Async.fetchScalar +-- alias: exports.ghmattimysql:scalar MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}, function(firstname) print(firstname) @@ -20,6 +21,7 @@ end) ```lua -- alias: exports.oxmysql:scalar_async -- alias: MySQL.Sync.fetchScalar +-- alias: exports.ghmattimysql:scalarSync local firstname = MySQL.scalar.await('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}) print(firstname) diff --git a/docs/oxmysql/Usage/transaction.md b/docs/oxmysql/Usage/transaction.md index ef60bed0..283083c8 100644 --- a/docs/oxmysql/Usage/transaction.md +++ b/docs/oxmysql/Usage/transaction.md @@ -22,6 +22,7 @@ local queries = { ```lua -- alias: exports.oxmysql:transaction -- alias: MySQL.Async.transaction +-- alias: exports.ghmattimysql:transaction MySQL.transaction(queries, function(success) print(success) @@ -33,6 +34,8 @@ end) ```lua -- alias: exports.oxmysql:transaction_async -- alias: MySQL.Sync.transaction +-- alias: exports.ghmattimysql:transactionSync + local success = MySQL.transaction.await(queries) print(success) ``` diff --git a/docs/oxmysql/Usage/update.md b/docs/oxmysql/Usage/update.md index 303a0a7d..48b1f728 100644 --- a/docs/oxmysql/Usage/update.md +++ b/docs/oxmysql/Usage/update.md @@ -9,6 +9,7 @@ Returns the number of affected rows by the query. ```lua -- alias: exports.oxmysql:update -- alias: MySQL.Async.execute +-- alias: exports.ghmattimysql:execute MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier}, function(affectedRows) if affectedRows then @@ -22,6 +23,7 @@ end) ```lua -- alias: exports.oxmysql:update_async -- alias: MySQL.Sync.execute +-- alias: exports.ghmattimysql:executeSync local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier}) if affectedRows then