From efbe5fe0878f0a5001d47e99fa8f6c7a13e01352 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 20 Aug 2022 01:26:52 +1000 Subject: [PATCH] low effort ox_target docs --- docs/ox_target/Getting Started/config.md | 20 ++++++ docs/ox_target/Getting Started/index.md | 28 ++++++++ docs/ox_target/Usage/Globals.md | 40 +++++++++++ docs/ox_target/Usage/Target.md | 74 ++++++++++++++++++++ docs/ox_target/Usage/Zones.md | 89 ++++++++++++++++++++++++ docs/ox_target/Usage/index.md | 28 ++++++++ sidebars.js | 27 +++++++ 7 files changed, 306 insertions(+) create mode 100644 docs/ox_target/Getting Started/config.md create mode 100644 docs/ox_target/Getting Started/index.md create mode 100644 docs/ox_target/Usage/Globals.md create mode 100644 docs/ox_target/Usage/Target.md create mode 100644 docs/ox_target/Usage/Zones.md create mode 100644 docs/ox_target/Usage/index.md diff --git a/docs/ox_target/Getting Started/config.md b/docs/ox_target/Getting Started/config.md new file mode 100644 index 00000000..589f2930 --- /dev/null +++ b/docs/ox_target/Getting Started/config.md @@ -0,0 +1,20 @@ +# Config + +All settings are modified using convars, which need to be executed before the resource starts. + +```yaml +# Toggle targeting when pressing the hotkey, instead of holding it down. +setr ox_target:toggleHotkey 0 + +# Change the key to enable targeting (https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard) +setr ox_target:defaultHotkey LMENU + +# Draw a sprite (circle) at the centroid of a zone. +setr ox_target:drawSprite 1 + +# Enable built-in targeting options, e.g. toggling vehicle doors. +setr ox_target:defaults 1 + +# Enable debugging / testing options, entity outlines, and a raycast indicator. +setr ox_target:debug 0 +``` diff --git a/docs/ox_target/Getting Started/index.md b/docs/ox_target/Getting Started/index.md new file mode 100644 index 00000000..2e844982 --- /dev/null +++ b/docs/ox_target/Getting Started/index.md @@ -0,0 +1,28 @@ +--- +title: Getting started +sidebar_position: 1 +slug: ./../ +--- + +## Installation + +We always recommend using Git so you can track changes and update easily. + +``` +git clone https://github.com/overextended/ox_target.git +``` + +Otherwise, download the [latest release](https://github.com/overextended/ox_target/releases). + +### Dependencies + +- [ox_lib](https://github.com/overextended/ox_lib/) + - Several modules are loaded from ox_lib, most notably the zones module. + +### Supported Frameworks + +These aren't necessary to run ox_target, but they will add additional features. + +- [ox_core](https://github.com/overextended/ox_core) +- [esx](https://github.com/esx-framework/esx-legacy) +- [qb-core](https://github.com/qbcore-framework/qb-core) diff --git a/docs/ox_target/Usage/Globals.md b/docs/ox_target/Usage/Globals.md new file mode 100644 index 00000000..d6e35a79 --- /dev/null +++ b/docs/ox_target/Usage/Globals.md @@ -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) +``` diff --git a/docs/ox_target/Usage/Target.md b/docs/ox_target/Usage/Target.md new file mode 100644 index 00000000..2df4a59c --- /dev/null +++ b/docs/ox_target/Usage/Target.md @@ -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) +``` diff --git a/docs/ox_target/Usage/Zones.md b/docs/ox_target/Usage/Zones.md new file mode 100644 index 00000000..d38cad6a --- /dev/null +++ b/docs/ox_target/Usage/Zones.md @@ -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. diff --git a/docs/ox_target/Usage/index.md b/docs/ox_target/Usage/index.md new file mode 100644 index 00000000..ff425a05 --- /dev/null +++ b/docs/ox_target/Usage/index.md @@ -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 +} +``` diff --git a/sidebars.js b/sidebars.js index 8d377ab3..c8cafe39 100644 --- a/sidebars.js +++ b/sidebars.js @@ -38,12 +38,39 @@ const sidebars = { label: 'Library', href: '/docs/ox_lib', }, + { + type: 'link', + label: 'Target', + href: '/docs/ox_target', + }, { type: 'link', label: 'Inventory', href: '/docs/ox_inventory', }, ], + ox_target: [ + { + type: 'link', + label: '← Documentation', + href: '/docs', + }, + { + type: 'category', + label: 'Target', + link: { + type: 'generated-index', + title: 'Ox Target', + description: 'A performant and flexible "third-eye" stand-alone targeting resource, with additional support for ox, esx, and qb.', + }, + items: [ + { + type: 'autogenerated', + dirName: 'ox_target', + }, + ], + }, + ], ox_core: [ { type: 'link',