low effort ox_target docs

This commit is contained in:
Linden committed 2022-08-20 01:26:52 +10:00
1 parent 40faff4ab8
commit efbe5fe087
7 files changed
+306

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
```lua
local options = {
{
name = 'ox:option1',
event = 'ox_target:debug',
icon = 'fa-solid fa-road',
label = 'Option 1',
canInteract = function(entity, coords, distance)
return math.random(0, 100) < 51
end
},
{
name = 'ox:option1',
event = 'ox_target:debug',
icon = 'fa-solid fa-road',
label = 'Option 2',
canInteract = function(entity, coords, distance)
return math.random(0, 100) < 51
end
}
}
local optionNames = { 'ox:option1', 'ox:option2' }
```
## Create Globals
exports.ox_target:addGlobalObject(options)
exports.ox_target:addGlobalPed(options)
exports.ox_target:addGlobalPlayer(options)
exports.ox_target:addGlobalVehicle(options)
## Remove Globals
```lua
exports.ox_target:removeGlobalObject(optionNames)
exports.ox_target:removeGlobalPed(optionNames)
exports.ox_target:removeGlobalPlayer(optionNames)
exports.ox_target:removeGlobalVehicle(optionNames)
```
+74
View File
@@ -0,0 +1,74 @@
```lua
local options = {
{
name = 'ox:option1',
event = 'ox_target:debug',
icon = 'fa-solid fa-road',
label = 'Option 1',
canInteract = function(entity, coords, distance)
return math.random(0, 100) < 51
end
},
{
name = 'ox:option2',
event = 'ox_target:debug',
icon = 'fa-solid fa-road',
label = 'Option 2',
canInteract = function(entity, coords, distance)
return math.random(0, 100) < 51
end
}
}
local models = { `prop_atm_01`, `prop_atm_02` }
local optionsNames = { 'ox:option1', 'ox:option2' }
```
## addModel
Add new options when targeting a specific model or list of models.
```lua
exports.ox_target:addModel(models, options)
```
## removeModel
Remove options from a specific model or list of models.
```lua
exports.ox_target:removeModel(models, optionNames)
```
## addEntity
Add new options when targeting a networked entity or list of entities.
```lua
exports.ox_target:addEntity(entities, options)
```
## removeEntity
Remove options from a networked entity or list of entities.
```lua
exports.ox_target:removeEntity(entities, optionNames)
```
## addLocalEntity
Add new options when targeting a local entity or list of entities.
```lua
exports.ox_target:addLocalEntity(entities, options)
```
## removeLocalEntity
Remove options from a local entity or list of entities.
```lua
exports.ox_target:removeLocalEntity(entities, optionNames)
```
+89
View File
@@ -0,0 +1,89 @@
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).
## addSphereZone
```lua
exports.ox_target:addSphereZone(parameters)
```
### Parameters
```lua
{
coords = vector3,
radius = number,
debug? = boolean,
drawSprite? = boolean,
options = options,
}
```
### Example
```lua
exports.ox_target:addSphereZone({
coords = vec3(440.5363, -1015.666, 28.85637),
radius = 1,
debug = drawZones,
options = {
{
name = 'sphere',
event = 'ox_target:debug',
icon = 'fa-solid fa-circle',
label = '(Debug) Sphere',
canInteract = function(entity, coords, distance)
return true
end
}
}
})
```
## addBoxZone
```lua
exports.ox_target:addBoxZone(parameters)
```
### Parameters
```lua
{
coords = vector3,
size = vector3,
rotation = number,
debug? = boolean,
drawSprite? = boolean,
options = options,
}
```
### Example
```lua
exports.ox_target:addBoxZone({
coords = vec3(442.5363, -1017.666, 28.85637),
size = vec3(2, 2, 2),
rotation = 45,
debug = drawZones,
options = {
{
name = 'box',
event = 'ox_target:debug',
icon = 'fa-solid fa-cube',
label = '(Debug) Box',
canInteract = function(entity, coords, distance)
return true
end
}
}
})
```
## removeZone
```lua
exports.ox_target:removeZone(id)
```
The `id` passed to removeZone is the return value from addBoxZone / addSphereZone.
+28
View File
@@ -0,0 +1,28 @@
# Usage
When calling exports to add options, the input is an array of tables with the following properties.
```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 }
-- custom check to hide or display the option
canInteract? = function(entity, distance, coords, name),
-- triggered on option selection (one only)
onSelect? = function(data),
export? = string,
event? = string,
serverEvent? = string,
command? = string
}
```