🧩 Creating an Interaction Point

Creates a new interaction point in the world.

Exports

local id = exports['weInteract']:addInteractionPoint(data)

This function returns a unique id that can later be used with removeInteractionPoint to delete the point if needed.

All interactions created by a resource are saved, and upon its shutdown, the points are dynamically removed.

🧾 Data Structure

Here’s the structure of the data table you must provide:

  • ped (optional): The NPC model to spawn (e.g., 's_m_y_cop_01').

  • scenario (optional): The scenario animation the NPC will perform (e.g., 'WORLD_HUMAN_COP_IDLES').

  • heading (optional): The direction the NPC should face (e.g., 180.0).

  • coords (required): A vec3 location of the interaction point (e.g., vec3(0.0, 0.0, 0.0)).

  • dist (required): The maximum distance at which the player can interact (e.g., 2.0).

  • key (required): The keyboard key the player must press to trigger the interaction (e.g., 'E').

  • message (required): The UI message shown when the player is near the interaction point (e.g., 'GARAGE').

  • icon (optional): The icon displayed in the UI (e.g., 'warehouse').

  • onPress (required): A Lua function executed when the key is pressed (e.g., function() print('GARAGE pressed') end).

Last updated