Skip to content

Player Interactions

Player interaction and personal action helpers for registering, syncing, categorizing, and opening interaction menu options.


Overview

The player interaction library centralizes menu-driven player interactions under `lia.playerinteract`. It stores registered interactions and personal actions, groups options by category, synchronizes safe option metadata to clients, opens the clientside options menu, and provides built-in money transfer and voice mode actions.

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

lia.playerinteract.openMenu(options, isInteraction, titleText, closeKey, netMsg, preFiltered)View Source

Purpose

Opens the clientside player interaction or personal action options menu.

Realm

Client

Parameters

table options Options to display in the menu.

boolean isInteraction True for target interactions, false for personal actions.

string titleText optional Optional menu title text.

number closeKey optional Optional key code used to close the menu.

string netMsg optional Optional network message used when an option is selected.

boolean preFiltered optional Whether the supplied options were already filtered before opening the menu.

Returns

Panel|nil The created options menu panel, or nil if the local player is invalid.

Example Usage

  lia.playerinteract.openMenu(options, true, L("interactionMenu"), KEY_TAB, "liaRunInteraction", true)

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.