> For the complete documentation index, see [llms.txt](https://gtadocs.gta-explore.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gtadocs.gta-explore.com/target-menu/client-functions.md).

# Client Functions

The following exported functions can be called from any scripts. They should always be called in scripts starting after exp\_target\_menu.

## AddTypeMenuItem

Adds an item to the specified menu type.

### Example

```lua
exports.exp_target_menu:AddTypeMenuItem({
    type = "all",
    event = "emotes:OpenEmotesMenu",
    desc = "Open Emotes",
    stay = false,
    arguments = {
        favorites = favorite_emotes
    }
})
```

### Options

* `type`: **string**, menu to add the item to. Possible value: `all` `ped` `vehicle` `object` `player` `in_vehicle` (`all` is actually the personal menu)
* `event`: **string**, name of the event to call when clicked.
* `desc`: **string**, text showing on the button.
* ?`stay`: **boolean**, if `true` the menu stays open when clicked, else it automatically closes.
* ?`arguments`: **table**, arguments passed to the event on trigger.

## RemoveTypeMenuItem

Remove the specified item from the menu type.

### Example

```lua
exports.exp_target_menu:RemoveTypeMenuItem({
    type = "all",
    event = "emotes:OpenEmotesMenu"
})
```

### Options

* `type`: **string**, menu to remove the item from. Possible value: `all` `ped` `vehicle` `object` `player` `in_vehicle`
* `event`: **string**,  name of the event to call when clicked.

## AddEntityMenuItem

Adds an item to the specified entity.

### Example

```lua
local npc = CreatePed(...)
exports.exp_target_menu:AddEntityMenuItem({
    entity = npc,
    event = "garages:OpenGarage",
    desc = "Open Garage",
    stay = false,
    name = "Garage",
    arguments = {
        garage = garage_id
    }
})
```

### Options

* `entity`: **integer**, game entity handle to add the item to.
* `event`: **string**, name of the event to call when clicked.
* `desc`: **string**, text showing on the button.
* ?`stay`: **boolean**, if `true` the menu stays open when clicked, else it automatically closes.
* ?`name`: **string**, name of the menu.
* ?`arguments`: **table**, arguments passed to the event on trigger.

## RemoveEntityMenuItem

Remove the specified item from the entity.

### Example

```lua
exports.exp_target_menu:RemoveEntityMenuItem({
    entity = npc,
    event = "garages:OpenGarage"
})
```

### Options

* `entity`: **integer**, game entity handle to remove the item from.
* `event`: **string**, name of the event to call when clicked.

## AddModelMenuItem

Adds an item to the specified model.

### Example

```lua
exports.exp_target_menu:AddModelMenuItem({
    model = GetHashKey("prop_bin_01a"),
    event = "trashcan:SearchBin",
    desc = "Search",
    stay = false,
    name = "Trashcan",
    arguments = {
        loots = LOOT_TABLE["prop_bin_01a"]
    },
    offset = vector3(0.0, 0.0, 0.8)
})
```

### Options

* `model`: **integer**, model hash to add the item to.
* `event`: **string**, name of the event to call when clicked.
* `desc`: **string**, text showing on the button.
* ?`stay`: **boolean**, if `true` the menu stays open when clicked, else it automatically closes.
* ?`name`: **string**, name of the menu.
* ?`arguments`: **table**, arguments passed to the event on trigger.
* ?`offset`: **vector3**, indicator's offset for this model. (This offset will overwrite the last one)

## RemoveModelMenuItem

Remove the specified item from the model.

### Example

```lua
exports.exp_target_menu:RemoveModelMenuItem({
    model = GetHashKey("washington"),
    event = "garages:ToggleLock"
})
```

### Options

* `model`: **integer**, model hash to remove the item from.
* `event`: **string**, name of the event to call when clicked.

## PauseMenu

Pauses the menu. When paused, the menu can't be opened and the cursor won't appear.

```lua
exports.exp_target_menu:PauseMenu({
    pause = true
})
```

### Options

* `pause`: **boolean**, if `true` the menu will be paused, else it won't.

## OpenMainMenu

Opens the menu with the specified options.

```lua
exports.exp_target_menu:OpenMainMenu({
    name = "Vehicle Options",
    options = {
       ["garages:OpenTrunk"] = {
          desc = "Open Trunk",
          stay = false
       },
       ["garages:OpenHood"] = {
          desc = "Open Hood",
          stay = false
       }
    }
})
```

### Options

* `name`: **string**, name to display.
* `options`: **table**, dictionary with event name as key, and desc and stay as value. (See example)

## SetEntityName

Sets the menu title for the specified entity.

```lua
exports.exp_target_menu:SetEntityName({
    entity = vehicle,
    name = "My Car"
})
```

### Options

* `entity`: **integer**, game entity handle.
* `name`: **string**, menu title.

## SetModelName

Sets the menu title for the specified model.

```lua
exports.exp_target_menu:SetModelName({
    model = GetHashKey("flatbed"),
    name = "Towtruck"
})
```

### Options

* `model`: **integer**, model hash.
* `name`: **string**, menu title.

## SetModelOffset

Moves the indicator location from the model origin.

```lua
exports.exp_target_menu:SetModelOffset({
    model = GetHashKey("prop_phonebox_04"),
    offset = vector(0.3, 0.3, 1.4)
})
```

### Options

* `model`: **integer**, model hash.
* `offset`: **vector3**, offset vector to move the indicator from the origin.

## Response

When triggered, an event comes with the parameters `entity` and `arguments`.

```lua
AddEventHandler("my_resource:my_event", function(entity, arguments)
    -- Do what you want with it
end)
```

### Parameters

* `entity`: **integer**, entity handle from whatever entity the interaction was triggered.
* `arguments`: **table**, arguments passed when the interaction was registered.
