use same params and types format for all of lib

This commit is contained in:
Luke committed 2022-09-17 13:25:20 +02:00
1 parent e3293c2109
commit 6c2ab8f8ec
14 files changed
+114 -67

No files matched your search

+7 -5
View File
@@ -1,11 +1,13 @@
```lua
-- principal: string or string[] or false
-- command: string
-- callback: function
-- parameters: table (optional)
-- help: string (optional)
lib.addCommand(principal, command, callback, parameters, help)
```
* principal: `string` or `string[]` or `false`
* command: `string`
* callback: `function`
* parameters?: `table` (`array`)
* help?: `string`
```lua
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
args.item = Items(args.item)
if args.item and args.count > 0 then
+11 -5
View File
@@ -3,11 +3,14 @@ Triggers a registered server callback and registers an event handler for the res
### lib.callback
The response is handled in a separate coroutine.
```lua
-- name: string
-- delay: number or false
-- cb: function
lib.callback(name, delay, cb, ...)
```
* name: `string`
* delay: `number` or `false`
* cb: `function`
* ...: `any`
```lua
lib.callback('ox_inventory:getItemCount', false, function(count)
print(count)
end, 'water', {type = 'fresh'})
@@ -16,10 +19,13 @@ end, 'water', {type = 'fresh'})
### lib.callback.await
The current coroutine is yielded until a response is received.
```lua
-- name: string
-- delay: number or false
lib.callback.await(name, delay, ...)
```
* name: `string`
* delay: `number` or `false`
* ...: `any`
```lua
local count = lib.callback.await('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
print(count)
```
+4 -2
View File
@@ -1,9 +1,11 @@
### lib.callback.register
```lua
-- name: string
-- cb: function
lib.callback.register(name, cb)
```
* name: `string`
* cb: `function`
```lua
lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
local inventory = target and Inventory(target) or Inventory(source)
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
+5 -5
View File
@@ -1,23 +1,23 @@
### lib.disableControls
Call on frame to disable all stored keys.
```lua
-- Call on frame to disable all stored keys.
lib.disableControls()
```
### lib.disableControls:Add
```lua
-- vararg: number
lib.disableControls:Add(...)
```
* vararg: `number`
### lib.disableControls:Remove
```lua
-- vararg: number
lib.disableControls:Remove(...)
```
* vararg: `number`
### lib.disableControls:Clear
```lua
-- vararg: number
lib.disableControls:Clear(...)
```
* vararg: `number`
+11 -6
View File
@@ -3,11 +3,16 @@
Get the id, ped, and coords of the closest player to a set of coordinates.
```lua
---@param coords vector3 The coords to check from.
---@param maxDistance number The max distance to check.
---@param includePlayer boolean Whether or not to include the current player.
---@return number? playerId
---@return number? playerPed
---@return vector3? playerCoords
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
```
* coords: `vector3`
* The coords to check from.
* maxDistance: `number`
* The max distance to check.
* includePlayer: `boolean`
* Whether or not to include the current player.
Return:
* playerId?: `number`
* playerPed?: `nubmer`
* playerCoords?: `vector3`
+11 -5
View File
@@ -3,10 +3,16 @@
Get the id and coords of the closest vehicle to a set of coordinates.
```lua
---@param coords vector3 The coords to check from.
---@param maxDistance number The max distance to check.
---@param includePlayerVehicle boolean Whether or not to include the player's current vehicle.
---@return number? vehicle
---@return vector3? vehicleCoords
function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end
```
* coords: `vector3`
* The coords to check from.
* maxDistance: `number`
* The max distance to check.
* includePlayerVehicle: `boolean`
* Whether or not to include the player's current vehicle.
Return:
* vehicle?: `number`
* vehicleCoords?: `vector3`
+9 -4
View File
@@ -3,9 +3,14 @@
Get the id, ped, and coords of all players within range of a set of coordinates.
```lua
---@param coords vector3 The coords to check from.
---@param maxDistance number The max distance to check.
---@param includePlayer boolean Whether or not to include the current player.
---@return number[]
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
```
* coords: `vector3`
* The coords to check from.
* maxDistance: `number`
* The max distance to check.
* includePlayer: `boolean`
* Whether or not to include the current player.
Return:
* `number[]`
+9 -4
View File
@@ -3,9 +3,14 @@
Get the id and coords of all vehicles within range of a set of coordinates.
```lua
---@param coords vector3 The coords to check from.
---@param maxDistance number The max distance to check.
---@param includePlayerVehicle boolean Whether or not to include the player's current vehicle.
---@return number[]
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
```
* coords: `vector3`
* The coords to check from.
* maxDistance: `number`
* The max distance to check.
* includePlayerVehicle: `boolean`
* Whether or not to include the player's current vehicle.
Return:
* `number[]`
+3 -2
View File
@@ -4,11 +4,12 @@ Locale files should use the [ISO Language Code](http://www.lingoes.net/en/transl
Players can use `setlocale [langcode]`, and admins can use `serverlocale [langcode]` to change the loaded file.
```lua
-- str: string
-- ...: string | number
locale(str, ...)
```
* str: `string`
* ...: `string` or `number`
Additional arguments can be sent to format the locale output.
```lua
+5 -4
View File
@@ -12,12 +12,13 @@ set datadog:site "datadoghq.com"
```
```lua
-- source: string | number
-- event: string
-- message: string
-- ...: string
lib.logger(source, event, message, ...)
```
* 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.
+5 -3
View File
@@ -3,11 +3,13 @@
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
```lua
-- coords: vector3
-- distance: number
-- data: table
lib.points.new(coords, distance, data)
```
* coords: `vector3`
* distance: `number`
* data: `table`
```lua
local point = lib.points.new(playerCoords, 5, {
dunak = 'nerd',
})
+11 -7
View File
@@ -3,12 +3,16 @@
Starts a shapetest originating from the camera, extending to ~10m.
```lua
---@param flags number? Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
---@param p8 number? A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
---@return boolean hit
---@return number entityHit
---@return vector3 endCoords
---@return vector3 surfaceNormal
---@return number materialHash
function lib.raycast.cam(flags, p8) end
```
* flags?: `number`
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
* p8?: `numbe`
* 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`
* surfaceNormal: `vector3`
* materialHash: `number`
-2
View File
@@ -51,8 +51,6 @@ lib.requestAnimSet(set, timeout)
* timeout: `number`
* Default: `100`
### lib.requestModel
<Tabs>
+23 -13
View File
@@ -1,25 +1,35 @@
An alternative to PolyZone utilising [glm.polygon](https://github.com/gottfriedleibniz/lua/blob/luaglm/EXTENDED.md#polygon).
```lua
-- data: table
-- points: vector3[] all z values must match
-- thickness: number (optional), default 4
-- debug: bool (optional)
lib.zones.poly(data)
```
* data: `table`
* points: `vector3[]`
* All z values must match
* thickness?: `number`
* Default: `4`
* debug?: `boolean`
-- data: table
-- coords: vector3
-- size: vector3 (optional), default is vec3(4, 4, 4)
-- rotation: number (optional), angle in degrees
-- debug: bool (optional)
```lua
lib.zones.box(data)
```
* data: `table`
* coords: `vector3`
* size?: `vector3`
* Default: `vec3(4, 4, 4)`
* rotation?: `number`
* Angle in degrees
* debug?: `boolean`
-- data: table
-- coords: vector3
-- radius: number (optional), default is 2
-- debug: bool (optional)
```lua
lib.zones.sphere(data)
```
* data: `table`
* coords: `vector3`
* radius?: `number`
* Default: `2`
* debug?: `boolean`
```lua
function onEnter(self)