Skip to content

Options

This page documents hooks in the options category.


InitializedOptions()View Source

Purpose

Runs after saved option values are loaded, or after defaults are initialized and saved when no option file exists.

Category

Options

Realm

Shared

Example Usage

  hook.Add("InitializedOptions", "liaExampleInitializedOptions", function()
      print("[MyModule] handled InitializedOptions")
  end)

OptionAdded(key, option)View Source

Purpose

Runs after an option is registered with `lia.option.add`.

Category

Options

Realm

Shared

Parameters

string key The unique option identifier.

table option The stored option data table created for the key.

Example Usage

  hook.Add("OptionAdded", "liaExampleOptionAdded", function(key, option)
      print("[MyModule] handled OptionAdded")
  end)

OptionChanged(key, oldValue, newValue)View Source

Purpose

Runs after `lia.option.set` changes a registered option value.

Category

Options

Realm

Shared

Parameters

string key The unique option identifier.

any oldValue The value before the change.

any newValue The value after the change.

Example Usage

  hook.Add("OptionChanged", "liaExampleOptionChanged", function(key, oldValue, newValue)
      print("[MyModule] handled OptionChanged")
  end)

OptionReceived(client, key, value)View Source

Purpose

Runs on the server when a changed option is marked for networking.

Category

Options

Realm

Server

Parameters

Player client optional The player associated with the networked option change, or nil when triggered directly by `lia.option.set`.

string key The unique option identifier.

any value The networked option value.

Example Usage

  hook.Add("OptionReceived", "liaExampleOptionReceived", function(client, key, value)
      if not IsValid(client) then return end
      print(string.format("[MyModule] handled OptionReceived for %s", client:Name()))
  end)