Summary

Methods

Flushes all of this entity's networked variables, along with their recipients, and tells clients to do the same.
Returns the value of this entity's networked variable.
Returns the players this entity's networked variable is sent to.
Sends the current value of this entity's networked variable to a player (or players).
Sets this entity's networked variable and sends it to clients.
Changes who this entity's networked variable is sent to without changing its value.

Methods

Entity:clear_net_vars(recv)

server packages/active_network/lib/sv_active_network.lua:379

Flushes all of this entity's networked variables, along with their recipients, and tells clients to do the same. Nothing is sent for an entity that has never had a variable set.

Parameters

  • recv Player/List<Player> optional, defaults to nil who to notify; everyone if nil

Entity:get_nv(key, default)

shared packages/active_network/lib/sv_active_network.lua:316

Returns the value of this entity's networked variable.

Parameters

  • key String variable name
  • default Any optional, defaults to nil value to return if the variable is not set

Returns

  • Any variable value, or default

Defined in

Entity:get_nv_recipients(key)

server packages/active_network/lib/sv_active_network.lua:334

Returns the players this entity's networked variable is sent to.

Parameters

  • key String variable name

Returns

  • List<Player> recipients who are still on the server, or nil if the variable is public

Entity:send_net_var(key, recv)

server packages/active_network/lib/sv_active_network.lua:303

Sends the current value of this entity's networked variable to a player (or players). A private variable is never sent to a player who is not one of its recipients.

Parameters

  • key String variable name
  • recv Player/List<Player> optional, defaults to nil who to send the value to; if nil, everyone who may receive the variable

Entity:set_nv(key, value, send)

server packages/active_network/lib/sv_active_network.lua:408

Sets this entity's networked variable and sends it to clients. Does nothing if neither a non-table value nor the recipients have changed. Functions and tables that contain functions cannot be networked.

-- Public: sent to everyone, including the players who join later.
entity:set_nv('fl_locked', true)

-- Private: sent to the listed players only, and so are the later updates.
entity:set_nv('fl_combination', '1234', { owner, co_owner })
entity:set_nv('fl_combination', '4321')

Parameters

  • key String variable name
  • value Any new value, anything but a function or a table that contains one
  • send Player/List<Player> optional, defaults to nil makes the variable private: these players become its only recipients, and everyone else is told to forget it. If nil, the value goes to the current recipients of the variable, which is everyone unless it is private. A variable that is given recipients stays private until Entity:set_nv_recipients makes it public again

Entity:set_nv_recipients(key, send)

server packages/active_network/lib/sv_active_network.lua:357

Changes who this entity's networked variable is sent to without changing its value. Players who stop being recipients are told to forget the value, and the current value is sent to the new recipients. The recipients can be set before the variable itself, which makes sure that its first value does not reach anybody else.

-- Only admins receive the variable from now on.
entity:set_nv_recipients('fl_owner_steam_id', admins)

-- Make it public again.
entity:set_nv_recipients('fl_owner_steam_id', nil)

Parameters

  • key String variable name
  • send Player/List<Player> optional, defaults to nil the only players to send the variable to; nil makes it public

Defined in