AddTarget
Last updated on
Puts rows on the target eye, owned by your resource.
local res = exports.opx_infinity:AddTarget(kind, rows, where)Sync.
Parameters
-
kind:
string—any,players,self,vehicles,npcs,props,doors,world,sky,models,entities,spheres -
rows:
table— one row, or a list registered whole or not at all- id:
string— your row id - label:
string - onSelect:
string— the name of your export called with the pick context - canInteract?:
string— your export answeringtrueto list the row - checked?:
string— your export answeringtrue/falseto draw a box - danger?:
boolean— drawn as dangerous, and asks for a second click unlessconfirm = false - confirm?:
boolean—trueasks for a second click on any row;falselets adangerrow run in one click - description?, group?, icon?, distance?, ... — the rest of a target row
- id:
-
where?:
table— required formodels(model records),entities(entity ids) andspheres({ x, y, z, radius }list) -
Rows are owned under your resource name. The eye reads your resource's generation and drops your rows when it stops or reloads.
-
Every callback is an export name of yours (
onSelect = 'OnPick'callsexports.<you>:OnPick(context)); a{ resource, export }naming any other resource, or anything else, isexport.badArgument. The eye asks callbacks in slices over export calls, never inside one resume. -
A resource named like a module of OPX (
target,inventory, ...) is refused:export.ownerTaken. -
The eye limits how many rows one owner holds.
-
A confirm row: the first click relabels it
Confirm: <label>in place;onSelectis called only on a second click on the same row within 4 s. Your export is never called for the first click. Since PR #90 everydangerrow confirms by default: setconfirm = falseto keep one click (for example whenonSelectopens a form that confirms on its own).
Returns
{ token }for one row,{ tokens }for a list
Errors
export.ownerTaken,export.badArgument, target codes such asinvalid_optionoroption_limit
exports('OnBuy', function(context)
TriggerServerEvent('my_shop:open', context.option.id)
end)
local res = exports.opx_infinity:AddTarget('npcs', {
id = 'buy', label = 'Browse the stall', icon = 'cart', onSelect = 'OnBuy',
})
-- Two clicks: "Rob the stall", then "Confirm: Rob the stall".
exports.opx_infinity:AddTarget('npcs', {
id = 'rob', label = 'Rob the stall', icon = 'warning', danger = true, onSelect = 'OnRob',
})