offset: vector3 A vector of offsets for the entity interaction (only applicable when not using target)
message: string Message displayed for users when using non-target solution
targetMessage: string Message displayed for users when using a target solution
input: number The control index ()
callback: function reference The function which will get executed after user interacts
canInteract?: function reference The function which will get executed to check whether the user can interact with the entity
meta?: table A table with any data you want to store on the interaction. This will be accessible in your callback and canInteract functions
interactDist?: number The max distance at which players can interact (default 2.0)
icon?: string A font-awesome icon used for the target systems. "fas fa-hand" e.g.
Example
-- In this example we will add a mock interaction for a player to go ragdoll upon interaction
function OnInteract(interaction)
-- You can retrieve the meta data using interaction.GetMeta()
local meta = interaction.GetMeta()
-- We defined the ragdoll duration in the meta table when creating the interaction entity
-- We can now access it
local ragdollDuration = meta.ragdollDuration
SetPedToRagdoll(PlayerPedId(), ragdollDuration, ragdollDuration, 0, 0, 0)
-- We can also retrieve the entity from the interaction
-- In this case we will retrieve it and delete it straight away
DeleteEntity(interaction.GetEntity())
end
function CanInteract(interaction)
-- In this case we will only allow the player to interact if they're not already ragdolling
return not IsPedRagdoll(PlayerPedId())
end
exports.kq_link:AddInteractionEntity(
entity,
vector3(0, 0, 0.5),
'[E] Touch the exposed wire',
'Touch the exposed wire',
38, -- 38 is the index for E
OnInteract,
CanInteract,
{
ragdollDuration = 10000
},
1.5,
'fas fa-hand'
)
coords: vector3 The coordinates of the center of the zone
rotation: vector3 The rotation of the zone (used for target)
scale: vector3 The scale of the zone (used for target)
message: string Message displayed for users when using non-target solution
targetMessage: string Message displayed for users when using a target solution
callback: function reference The function which will get executed after user interacts
canInteract?: function reference The function which will get executed to check whether the user can interact with the entity
meta?: table A table with any data you want to store on the interaction. This will be accessible in your callback and canInteract functions
interactDist?: number The max distance at which players can interact (default 2.0)
icon?: string A font-awesome icon used for the target systems. "fas fa-hand" e.g.
Example
-- In this example we will add a mock interaction for a player to go ragdoll upon interaction
function OnInteract(interaction)
-- You can retrieve the meta data using interaction.GetMeta()
local meta = interaction.GetMeta()
-- We defined the ragdoll duration in the meta table when creating the interaction zone
-- We can now access it
local ragdollDuration = meta.ragdollDuration
SetPedToRagdoll(PlayerPedId(), ragdollDuration, ragdollDuration, 0, 0, 0)
end
function CanInteract(interaction)
-- In this case we will only allow the player to interact if they're not already ragdolling
return not IsPedRagdoll(PlayerPedId())
end
exports.kq_link:AddInteractionZone(
vector3(254.3, 124.0, 42.0),
vector3(0, 0, 0),
vector3(1, 1, 1),
'[E] Touch the exposed wire',
'Touch the exposed wire',
38, -- 38 is the index for E
OnInteract,
CanInteract,
{
ragdollDuration = 10000
},
1.5,
'fas fa-hand'
)
Interaction functions
The interaction contains many useful functions which can be used to retrieve or set variables
interaction.GetMeta()
-- Returns the metadata table of the interaction
interaction.GetCoords()
-- Returns the coordinates of the interaction (will return the entity coords if its an entity interaction)
interaction.GetEntity()
-- Returns the interaction entity (only available on Entity interactions)
interaction.Delete()
-- Deletes the interaction
interaction.GetInvoker()
-- Returns the resource which invoked (created) the interactable
The data needs to be sent as a table containing the following values:
coords: vector3 The coordinates of the dispatch alert
jobs: table A table containing string names of the jobs which are going to receive the alert
message: string The message/title of the alert
description: string The long description of the alert
code: string a 10-code of the alert. (Default 10-35)
blip: table A table containing the following keys:
color: integer The id of a blip color
scale: float The scale of the blip
text: string The name of the blip visible in the legend
flash: boolean whether the blip should be flashing on the map
Example
exports.kq_link:SendDispatchMessage({
coords = GetEntityCoords(PlayerPedId()),
jobs = {'bcso', 'lspd'},
message = 'Suspicious van with blue smoke',
description = 'There\'s a van with blue smoke coming out of it. It looks really shady!',
code = '10-35',
blip = {
sprite = 636,
color = 1,
scale = 1.5,
text = 'Suspicious van',
flash = true,
},
})
Notifications
Sending a notification
exports.kq_link:Notify(message, type)
message: string The notification message
type?: string enum ['success', 'warning', 'error'] - This defines the color of the notification
input: number The control index ()
sprite: integer The id of a blip sprite (See more )