Target Options
- label:
string - name?:
string -
- An identifier used when removing an option.
- icon?:
string -
- Name of a Font Awesome icon.
- iconColor?:
string - distance?:
number -
- The max distance to display the option.
- bones?:
stringorstring[] -
- A bone name or array of bone names (see GetEntityBoneIndexByName).
- offset?:
vector3 -
- Offset the targetable area of an entity, relative to the model dimensions.
- offsetAbsolute?:
vector3 -
- Offset the targetable area of an entity, relative to the entity’s world coords.
- offsetSize?:
number -
- The radius of the targetable area for an entity offset.
- groups?:
stringorstring[]ortable<string, number> -
- A group, array of groups, or pairs of groups-grades required to show the option.
-
- Groups are framework dependent, and may refer to jobs, gangs, etc.
- items?:
stringorstring[]ortable<string, number> -
- An item, array of items, or pairs of items-count required to show the option.
-
- Items are framework dependent.
- anyItem?:
boolean -
- Only require a single item from the items table to exist.
- canInteract?:
function(entity, distance, coords, name, bone) -
- Options will always display if this is undefined.
- menuName?:
string -
- The option is only displayed when a menu has been set with openMenu.
- openMenu?: string
-
- Sets the current menu name, displaying only options for the menuName.
- onSelect?:
function(data) - export?:
string - event?:
string - serverEvent?:
string - command?:
string
Overview
ox_target (previously known as qtarget) is a performant and flexible targeting resource for RedM. It allows players to interact with entities, zones, and models using a “third-eye” targeting system.ox_target is already included and used extensively in RSG Framework resources!
Installation
ox_target is already included in RSG Framework. To use it in your custom resources:fxmanifest.lua
Entity Targeting
addEntity
Add targeting options to a specific entity.entity(number) - The entity handleoptions(table) - Array of target options
removeEntity
Remove targeting options from a specific entity.entity(number) - The entity handleoptionNames(string|table|nil) - Specific option names to remove, or nil to remove all
Model Targeting
addModel
Add targeting options to all entities with specific models.models(string|number|table) - Model hash(es) or name(s)options(table) - Array of target options
removeModel
Remove targeting options from models.models(string|number|table) - Model hash(es) or name(s)optionNames(string|table|nil) - Option names to remove, or nil for all
Zone Targeting
addBoxZone
Add a box-shaped targeting zone.name(string) - Unique zone identifiercoords(vector3) - Center coordinatessize(vector3) - Box dimensions (length, width, height)rotation(number) - Rotation in degreesoptions(table) - Array of target optionstargetoptions(table) - Additional zone settings
addSphereZone
Add a sphere-shaped targeting zone.name(string) - Unique zone identifiercoords(vector3) - Center coordinatesradius(number) - Sphere radiusoptions(table) - Array of target optionstargetoptions(table) - Additional zone settings
removeZone
Remove a targeting zone.name(string) - Zone identifier
Advanced Options
Job Restrictions
Restrict interactions to specific jobs:Item Requirements
Require specific items to see the interaction:Distance Control
Control interaction distance:Bone Targeting
Target specific entity bones:Can Interact Function
Dynamic interaction visibility:Event Types
Different ways to handle interactions:Complete Examples
Example 1: NPC Shopkeeper
Example 2: Job-Restricted Zones
Example 3: Crafting Station
Example 4: Dynamic Hitching Posts
Best Practices
Use appropriate distances: Keep interaction distances realistic (1.5-3.0 for most interactions)
Performance Tips
- Don’t add too many zones: Each zone checks distance every frame
- Use models over entities: Model targeting is more efficient than entity targeting for common objects
- Efficient canInteract: Keep canInteract functions lightweight
- Clean up when done: Remove zones/entities when they’re no longer needed
Troubleshooting
Target options not showing
Target options not showing
- Check distance - are you close enough?
- Verify canInteract function isn’t returning false
- Check job/gang/item requirements
- Ensure ox_target is started before your resource
Option showing for wrong job
Option showing for wrong job
- Verify the groups parameter is set correctly
- Check player’s actual job name (not label)
- Ensure grade requirements are correct
Zone not working
Zone not working
- Check zone coordinates are correct
- Verify size/radius is appropriate
- Make sure zone name is unique
- Check for Lua errors in F8 console
For more advanced usage, check the official ox_target documentation: https://overextended.dev/ox_target