Skip to content

ax.relay

Source: gamemode/framework/libraries/sh_relay.lua

Entity and global variable relay system for synchronized data storage.

Documented functions: 4

Functions


ENTITY:GetRelay(name, fallback)

Get a relay variable from an entity. Retrieves a stored value associated with this entity.

Realm: shared

Parameters

Name Type Description
name string The variable name to retrieve
fallback any Optional fallback value if variable is not set

Returns

  • any: The stored value or fallback if not found

Usage

local health = entity:GetRelay("health_percentage", 1.0)
local status = player:GetRelay("status", "healthy")

ENTITY:SetRelay(name, value, bNoNetworking, recipients)

Set a relay variable on an entity with optional networking. Stores a value associated with this entity and optionally syncs it to clients.

Realm: shared

Parameters

Name Type Description
name string The variable name to set
value any The value to store (will be networked if on server)
bNoNetworking boolean Optional flag to disable networking (server only)
recipients table Optional specific recipients for networking (server only)

Usage

entity:SetRelay("health_percentage", 0.75)
player:SetRelay("status", "injured", false, {otherPlayer})

GetRelay(name, fallback)

Get a global relay variable. Retrieves a stored global value that can be accessed from anywhere.

Realm: shared

Parameters

Name Type Description
name string The variable name to retrieve
fallback any Optional fallback value if variable is not set

Returns

  • any: The stored value or fallback if not found

Usage

local roundState = GetRelay("round_state", "waiting")
local message = GetRelay("server_message", "")

SetRelay(name, value, bNoNetworking, recipients)

Set a global relay variable with optional networking. Stores a global value that can be accessed from anywhere and optionally syncs to clients.

Realm: shared

Parameters

Name Type Description
name string The variable name to set
value any The value to store (will be networked if on server)
bNoNetworking boolean Optional flag to disable networking (server only)
recipients table Optional specific recipients for networking (server only)

Usage

SetRelay("round_state", "preparation")
SetRelay("server_message", "Welcome!", false, specificPlayers)