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
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, iftrue
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
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
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, iftrue
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
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
exports.exp_target_menu:AddModelMenuItem({
model = GetHashKey("a_c_horsemule_01"),
event = "exp_target_menu:LeadHorse",
desc = "Lead",
stay = false,
name = "Horse",
arguments = {
owner = PlayerId()
}
}
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, iftrue
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.
RemoveModelMenuItem
Remove the specified item from the model.
Example
exports.exp_target_menu:RemoveModelMenuItem({
model = GetHashKey("a_c_horsemule_01"),
event = "exp_target_menu:LeadHorse"
})
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.
exports.exp_target_menu:PauseMenu({
pause = true
})
Options
pause
: boolean, iftrue
the menu will be paused, else it won't.
OpenMainMenu
Opens the menu with the specified options.
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.
exports.exp_target_menu:SetEntityName({
entity = horse,
name = "My Horse"
})
Options
entity
: integer, game entity handle.name
: string, menu title.
SetModelName
Sets the menu title for the specified model.
exports.exp_target_menu:SetModelName({
model = GetHashKey("a_c_horse_americanpaint_splashedwhite"),
name = "Horse"
})
Options
model
: integer, model hash.name
: string, menu title.
SetModelOffset
Moves the indicator location from the model origin.
exports.exp_target_menu:SetModelOffset({
model = GetHashKey("p_chairwicker03x"),
offset = vector(0.0, 0.0, 0.5)
})
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
.
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.
Last updated