Usage

nn_interaction Documentation

A comprehensive interaction system for FiveM resources that provides targeting and text display functionality for entities, models, coordinates, and global objects.

Table of Contents

  • Installation

  • Configuration

  • Data Structure

  • API Reference

    • Local Entity Interactions

    • Model Interactions

    • Global Interactions

    • Coordinate Interactions

    • Utility Functions

  • Examples

  • Advanced Usage

Installation

  1. Place the nn_interaction resource in your resources folder

  2. Add ensure nn_interaction to your server.cfg

  3. Configure the settings in config.lua if needed

Configuration

The script uses config.lua for default settings:

Data Structure

All interaction functions use a similar data structure:

API Reference

Local Entity Interactions

These functions work with specific entity IDs.

addInteractionLocalEntity(name, entity, data, resource)

Adds an interaction to a specific local entity.

Parameters:

  • name (string): Unique interaction name

  • entity (number|table): Entity ID or table of entity IDs

  • data (table): Interaction data structure

  • resource (string, optional): Resource name (auto-detected if not provided)

addTextLocalEntity(name, entity, data, resource)

Adds text display to a specific local entity.

removeLocalEntity(entity, name, option, resource)

Removes interactions from local entities.

Parameters:

  • entity (number|table): Entity ID(s) to remove from

  • name (string, optional): Specific interaction name to remove

  • option (string, optional): Specific option to remove

  • resource (string, optional): Resource name

hideLocalEntity(entity, name)

Temporarily hides interactions on local entities.

showLocalEntity(entity, name)

Shows previously hidden interactions on local entities.

Model Interactions

These functions work with entity model hashes and apply to all entities of that model.

addInteractionModel(name, model, data, resource)

Adds interactions to all entities of a specific model.

Parameters:

  • name (string): Unique interaction name

  • model (number|table): Model hash or table of model hashes

  • data (table): Interaction data structure

  • resource (string, optional): Resource name

addTextModel(name, model, data, resource)

Adds text display to all entities of a specific model.

removeModel(model, name, option, resource)

Removes interactions from model-based interactions.

hideModel(model, name)

Temporarily hides interactions on model-based interactions.

showModel(model, name)

Shows previously hidden model-based interactions.

Global Interactions

These functions work with entity types (ped, vehicle, player, object).

addInteractionGlobal(name, entityType, data, resource)

Adds interactions to all entities of a specific type.

Parameters:

  • name (string): Unique interaction name

  • entityType (string|table): Entity type ("ped", "vehicle", "player", "object")

  • data (table): Interaction data structure

  • resource (string, optional): Resource name

addTextGlobal(name, entityType, data, resource)

Adds text display to all entities of a specific type.

removeGlobal(entityType, name, option, resource)

Removes global interactions.

hideGlobal(entityType, name)

Temporarily hides global interactions.

showGlobal(entityType, name)

Shows previously hidden global interactions.

Coordinate Interactions

These functions create interactions at specific world coordinates.

addInteractionCoords(name, coords, data, resource)

Adds interaction at specific coordinates.

Parameters:

  • name (string): Unique interaction name

  • coords (vector3|table): Coordinates or table of coordinates

  • data (table): Interaction data structure

  • resource (string, optional): Resource name

addTextCoords(name, coords, data, resource)

Adds text display at specific coordinates.

removeCoords(coords, name, option, resource)

Removes coordinate-based interactions.

hideCoords(coords, name)

Temporarily hides coordinate interactions.

showCoords(coords, name)

Shows previously hidden coordinate interactions.

Utility Functions

removeResource(resource)

Removes all interactions created by a specific resource.

Examples

Basic Entity Interaction

Model-Based Interactions

Global Interactions

Coordinate-Based Interactions

Text-Only Display

Advanced Vehicle Bone Targeting

Multiple Options with Conditions

Advanced Usage

Dynamic Interaction Management

Resource Cleanup

Performance Considerations

  • Use checkVisibility = true for entities that might be behind walls

  • Set appropriate distance values to avoid unnecessary processing

  • Use hideSquare = true for text-only displays

  • Clean up unused interactions to maintain performance

  • Use model-based interactions instead of multiple entity-specific ones when possible

Error Handling

The script includes built-in error handling and will log warnings for:

  • Invalid entity IDs

  • Incorrect parameter types

  • Non-existent interactions during removal

  • Missing required parameters

Enable debug mode in config.lua to see detailed logging:

Last updated