Examples
All examples are available in interactionMenu/lua/examples
.
DEVMODE
After setting DEVMODE = true
in interactionMenu/lua/client/util.lua
, all of those examples will be available in-game.
Just make sure it's not enabled in production.
onPosition
lua
local centerPosition = vector4(-1977.17, 3170.62, 32.81, 60.87)
exports['interactionMenu']:Create {
position = centerPosition,
indicator = {
prompt = 'Press Enter',
glow = true
},
extra = {
onTrigger = function()
print('on trigger')
end
}
}
onEntites
lua
local id = exports['interactionMenu']:Create {
entity = entity, -- entity handle
offset = vec3(0, 0, 0),
maxDistance = 2.0,
options = {
{
label = 'Using Event (client)',
icon = 'fa fa-server',
event = {
type = 'client',
name = 'testEvent:client',
payload = { 1, 2, 3 }
}
},
{
label = 'Using Event (server)',
icon = 'fa fa-server',
event = {
type = 'server',
name = 'testEvent:server',
payload = { 1, 2, 3 }
}
},
{
label = 'Using Action',
icon = 'fa fa-cogs',
action = {
type = 'sync',
func = function()
print('nothing')
end
}
}
}
}
onBones
Here we just added the last option (Switch Plate).
lua
exports['interactionMenu']:Create {
bone = 'platelight', -- bone name
vehicle = veh, -- vehicle handle
offset = vec3(0, 0, 0),
maxDistance = 2.0,
indicator = {
prompt = 'E',
keyPress = {
-- https://docs.fivem.net/docs/game-references/controls/#controls
padIndex = 0,
control = 38
}
},
options = {
{
label = "Switch Plate",
icon = "fas fa-toggle-on",
action = {
type = 'sync',
func = function(data)
Wait(1000)
SetVehicleNumberPlateText(data.entity, 'swkeep' .. math.random(0, 9))
Wait(500)
end
}
}
}
}
onPlayer
In case we want to add an interaction on a player
TIP
You should set player
with the server-id to be able to use this feature
lua
exports['interactionMenu']:create {
player = 2,
offset = vec3(0, 0, 0),
maxDistance = 1.0,
options = {
{
label = 'Just On Player Id: 2',
icon = 'fa fa-person',
action = {
type = 'sync',
func = function(data)
Util.print_table(data)
end
}
}
}
}