OPX//77
CreatorsClient exports

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 answering true to list the row
    • checked?: string — your export answering true / false to draw a box
    • danger?: boolean — drawn as dangerous, and asks for a second click unless confirm = false
    • confirm?: boolean — true asks for a second click on any row; false lets a danger row run in one click
    • description?, group?, icon?, distance?, ... — the rest of a target row
  • where?: table — required for models (model records), entities (entity ids) and spheres ({ 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' calls exports.<you>:OnPick(context)); a { resource, export } naming any other resource, or anything else, is export.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; onSelect is 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 every danger row confirms by default: set confirm = false to keep one click (for example when onSelect opens a form that confirms on its own).

Returns

  • { token } for one row, { tokens } for a list

Errors

  • export.ownerTaken, export.badArgument, target codes such as invalid_option or option_limit
Example
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',
})

On this page

No Headings