JCKSDocs
JCKS LibReferência

Interactions

How the JCKS target system works for players, how admins set it up and how to add interactions from code.

jcks_lib has its own way to interact with places, NPCs, players and vehicles. Every JCKS resource uses it when the bridge setup picks JCKS as the target system. ox_target, qb-target, tgiann-target and plain text prompts stay available. With target set to auto, the bridge picks jcks first when jcks_lib runs.

How players use it

Mode What the player sees
hold (default) Nothing until the player holds the show key (Left Alt). Then the closest interaction opens its options and other interactions in range show a small key.
always Everything in range shows its key all the time, the one closest to the screen center shows its options
look Only the interaction the player looks at shows its options, no key needed
  • The mouse wheel moves the selection.
  • The use key (E) runs the selected option.
  • An option can have its own key, for example G. Pressing it runs that option at once.
  • In mouse input mode, holding the show key frees the cursor and options are clicked.

Players rebind both keys in GTA Settings, Key Bindings, FiveM: JCKS - show interactions and JCKS - use interaction.

Server setup

/jcks, Interactions sets the mode, the input, the default reach (0.5 to 10 m) and whether other interactions show a key hint. Changes reach every player after saving. These settings only apply when the target system in Environment is JCKS interactions. Scan rate, longest reach and blocked shortcut keys are in Configuration.

API (client)

lua
local id = exports.jcks_lib:AddInteraction({
    id = 'mrpd_reception',
    coords = vec3(441.2, -981.9, 30.7),
    label = 'Mission Row reception',
    distance = 2.0,
    options = {
        { name = 'clock', label = 'Clock in', icon = 'clock', onSelect = function(data) Duty.toggle() end },
        { name = 'armory', label = 'Open armory', icon = 'shield', canInteract = function(entity, distance) return Job.isPolice() end, event = 'myres:armory' },
        { name = 'records', label = 'Search records', icon = 'search', key = 'G', serverEvent = 'myres:records' },
    },
})

exports.jcks_lib:RemoveInteraction(id)
exports.jcks_lib:HasInteraction(id)

Where an interaction sits

Pick one:

Field Target
coords A fixed place
entity A local entity handle
netId A networked entity, followed when it migrates to another owner
model or models Every entity with that model, names or hashes
global vehicle, ped (NPCs only), player or object

Optional fields:

Field What it does
offset vector3 from the entity
bone Bone name, for example door_dside_f
label Title above the options
distance Reach in meters, default from the server setup
id Your own id. Adding the same id again replaces it.
radius, or size with rotation Only with coords. The interaction covers a sphere or a box and the distance is measured to its edge, so a counter 4 m wide works from any spot along it. Radius up to 50 m, box sides up to 100 m, box height up to 50 m.
debug true draws the point and its reach, green while it is focused. Not for model and global targets.

Option fields

Field Meaning
label Text, required
icon Icon name, see Icons
key Own key: E, F, G, H, Q, R, X, Z, C, B, Y, T, K, U or L
distance Reach of this option only
canInteract(entity, distance, coords, name, ctx) Return true to show the option. Checked with every scan (Config.Interact.refresh, 250 ms by default), never every frame.
onSelect(data) Runs on select. Only one of onSelect, event, serverEvent and command runs, in this order.
event Local client event, gets data
serverEvent Server event, gets { id, name, netId, args }. Validate everything on the server.
command Runs a command
args Passed through to data.args

data contains id, name, entity, netId, coords, distance and args.

Interactions belong to the resource that added them and are removed when it stops. Ids from different resources do not overwrite each other.

Through jcks_bridge

JCKS resources do not call AddInteraction directly. They use the bridge target exports (AddTargetZone, AddTargetEntity, AddTargetModel, AddTargetGlobalVehicle, AddTargetGlobalPlayer), and the bridge sends them to the chosen system. With JCKS interactions the bridge also checks groups (job name, list of jobs or { job = minGrade }) and items before an option shows. See Bridge exports.

Performance

  • Nothing is checked while no interaction exists.
  • Places are checked every Config.Interact.refresh ms (250 by default) through a 64 m grid, the 3 by 3 cells around the player are scanned.
  • Model and global targets scan the entity pools only while prompts can show (in hold mode only while the key is held), and only within a few meters.
  • Per frame work only runs while prompts are visible: screen positions, the wheel and option keys. The UI gets at most 30 updates per second and only when something changed.