Player Interactions¶
Player interaction and personal action helpers for registering, syncing, categorizing, and opening interaction menu options.
Overview
lia.playerinteract.isWithinRange(client, entity, customRange)View Source
Purpose
Checks whether an entity is within interaction range of a client.
Realm
Shared
Parameters
Player client The player being used as the range origin.
Entity entity The entity being checked against the client.
number customRange optional Optional distance override. Defaults to 100 units.
Returns
boolean True if both entities are valid and the target is within range, otherwise false.
Example Usage
if lia.playerinteract.isWithinRange(client, target, 150) then
client:notifyInfo("Target is close enough.")
end
lia.playerinteract.getInteractions(client)View Source
Purpose
Gets interaction options available for the entity currently traced by a client.
Realm
Client
Parameters
Player client optional The player whose traced entity should be checked. Defaults to LocalPlayer on the client.
Returns
table A table of available interaction definitions keyed by interaction name.
Example Usage
local interactions = lia.playerinteract.getInteractions(LocalPlayer())
for name, interaction in pairs(interactions) do
print(name, interaction.category)
end
lia.playerinteract.getActions(client)View Source
Purpose
Gets personal action options available to a client.
Realm
Client
Parameters
Player client optional The player whose personal actions should be checked. Defaults to LocalPlayer on the client.
Returns
table A table of available action definitions keyed by action name.
Example Usage
local actions = lia.playerinteract.getActions(LocalPlayer())
for name, action in pairs(actions) do
print(name, action.category)
end
lia.playerinteract.getCategorizedOptions(options)View Source
Purpose
Builds a display-ready option list grouped by category.
Realm
Shared
Parameters
table options The option entries to categorize. Each entry may include an `opt.category` value.
Returns
table A sequential table containing category header entries followed by the options in each category.
Example Usage
local categorized = lia.playerinteract.getCategorizedOptions(options)
for _, entry in ipairs(categorized) do
if entry.isCategory then print(entry.name, entry.count) end
end
lia.playerinteract.addInteraction(name, data)View Source
Purpose
Registers a target-based interaction option.
Realm
Server
Parameters
string name Unique interaction identifier.
table data Interaction definition. Supports fields such as `category`, `target`, `range`, `shouldShow`, `onRun`, `serverOnly`, `timeToComplete`, `actionText`, `targetActionText`, and `categoryColor`.
Example Usage
lia.playerinteract.addInteraction("inspectTarget", {
target = "player",
category = "@categoryGeneral",
shouldShow = function(client, target) return target:IsPlayer() end,
onRun = function(client, target) client:notifyInfo(target:Name()) end
})
lia.playerinteract.addAction(name, data)View Source
Purpose
Registers a personal action option.
Realm
Server
Parameters
string name Unique action identifier.
table data Action definition. Supports fields such as `category`, `range`, `shouldShow`, `onRun`, `serverOnly`, `timeToComplete`, `actionText`, `targetActionText`, and `categoryColor`.
Example Usage
lia.playerinteract.addAction("toggleHelmet", {
category = "@categoryGeneral",
shouldShow = function(client) return client:getChar() ~= nil end,
onRun = function(client) client:notifyInfo("Helmet toggled.") end
})
lia.playerinteract.sync(client)View Source
Purpose
Synchronizes registered player interaction metadata and categories to clients.
Realm
Server
Parameters
Player client optional Optional player to synchronize. When omitted, all connected players are synchronized in small batches.
Example Usage
lia.playerinteract.sync(client)
lia.playerinteract.sync()
lia.playerinteract.hasChanges()View Source
Purpose
Checks whether registered interactions or categories have changed since the last full synchronization.
Realm
Server
Returns
boolean True if the stored interaction count or category count differs from the last synchronized counts.
Example Usage
if lia.playerinteract.hasChanges() then
lia.playerinteract.sync()
end
Hooks
Library-specific hooks documented for this library.
OnVoiceTypeChanged(client)View Source
Purpose
Runs after a client changes their voice mode through a player interaction action.
Realm
Server
Parameters
Player client The player whose voice mode changed.