Entity class
Part of Active Network
Summary
Methods
Methods
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
nilwho to notify; everyone if nil
Returns the value of this entity's networked variable.
Parameters
- key String variable name
- default Any optional, defaults to
nilvalue to return if the variable is not set
Returns
- Any variable value, or default
Defined in
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
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
nilwho to send the value to; if nil, everyone who may receive the variable
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
nilmakes 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 untilEntity:set_nv_recipientsmakes it public again
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
nilthe only players to send the variable to; nil makes it public