Skip to content

For developers

For script developers. Every ox_target export works as before, and one is added to read the cursor.

Every export, option and event of the official ox_target works the same way: addBoxZone, addGlobalVehicle, addLocalEntity and the others, and option fields like onSelect, event, serverEvent, canInteract, groups, items or openMenu. Follow the official documentation.

  • icon takes a Font Awesome class, as before, like fa-solid fa-car.
  • iconColor fills the tile behind the icon.
  • White, grey, black and transparent colors give a frosted tile instead, so a white icon stays readable on light themes too.
  • Without iconColor, the tile takes the accent color of the theme.
client.lua
exports.ox_target:addGlobalVehicle({
{
name = 'my_script:repair',
icon = 'fa-solid fa-wrench',
iconColor = '#ff9f0a',
label = 'Repair',
onSelect = function(data)
-- data.entity is the vehicle
end,
},
})

exports.ox_target:getCursor() is a client export added by ox_target Redesigned.

While a player targets in cursor mode, it returns { x, y, menu }: the pointer position from 0 to 1, and whether the options are open. It returns nil the rest of the time.

In cursor mode the targeting page holds the mouse, so IsNuiFocused() is true for the whole hold. A script with its own context menu can read the pointer here and keep using the right mouse button.

client.lua
local cursor = exports.ox_target:getCursor()
if cursor and not cursor.menu then
-- The player aims with the mouse, at cursor.x and cursor.y (0 to 1).
end

To style your own interface like ox_target and ox_lib Redesigned, read the theme of ox_lib Redesigned 1.1.0 or newer: exports.ox_lib:getThemeTokens() returns its CSS variables, and the ox_lib:themeChanged client event fires when they change.