Client

These exports can be only called on the client side of your scripts.

Interactions

Entity interaction

exports.kq_link.AddInteractionEntity(
    entity,
    offset,
    message,
    targetMessage,
    input,
    callback,
    canInteract,
    meta,
    interactDist,
    icon
): Interaction<object> 
  • entity: number the numeric entity id

  • 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 (learn more)

  • 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
exports.kq_link:AddInteractionEntity(
            entity,
            vector3(0, 0, 0.5),
            L('[E] Touch the exposed wire'),
            L('Touch the exposed wire'),
            38, -- 38 is the index for E
            OnInteract,
            CanInteract,
            {
                ragdollDuration = 10000
            },
            1.5,
            'fas fa-hand'
        )
        
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

Zone Interaction

exports.kq_link.AddInteractionZone(
    coords,
    rotation,
    scale,
    message,
    targetMessage,
    input,
    callback,
    canInteract,
    meta,
    interactDist,
    icon
): Interaction<object>
  • 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

  • input: number The control index (learn more)

  • 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
exports.kq_link:AddInteractionZone(
            vector3(254.3, 124.0, 42.0),
            vector3(0, 0, 0),
            vector3(1, 1, 1),
            L('[E] Touch the exposed wire'),
            L('Touch the exposed wire'),
            38, -- 38 is the index for E
            OnInteract,
            CanInteract,
            {
                ragdollDuration = 10000
            },
            1.5,
            'fas fa-hand'
        )
        
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

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

Last updated