Hooks called by Active Network

Summary

Hooks

Called on the client when the server has changed a networked global variable, after the new value has been stored, so ActiveNetwork.get_nv already returns it.
Called on the client when the server has changed a networked variable of an entity, after the new value has been stored, so Entity:get_nv already returns it.

Hooks

GlobalNetVarChanged(key, old_value, value)

client packages/active_network/lib/cl_active_network.lua:109

Called on the client when the server has changed a networked global variable, after the new value has been stored, so ActiveNetwork.get_nv already returns it. Does not run if a value that is not a table arrives unchanged; a table runs the hook every time it arrives.

Parameters

  • key String Variable name
  • old_value Any Previous value, nil if the variable was not set
  • new_value Any New value, nil if the variable has been unset

Call sites

NetVarChanged(Entity(ent_idx), key, old_value, new_value, ent_idx)

client packages/active_network/lib/cl_active_network.lua:57

Called on the client when the server has changed a networked variable of an entity, after the new value has been stored, so Entity:get_nv already returns it. Runs when a variable is set, when it is unset and, once for every variable the entity had, when the server clears the variables of an entity (which it does as the entity is removed). Does not run if a value that is not a table arrives unchanged; a table runs the hook every time it arrives. Variables are stored by entity index and may arrive before the entity does, or after it is gone, so the entity is not always valid.

function PLUGIN:NetVarChanged(entity, key, old_value, new_value)
  if entity == PLAYER and key == 'faction' then
    self:rebuild_menu()
  end
end

Parameters

  • entity Entity The entity the variable belongs to; a NULL entity if the client does not have an entity with that index
  • key String Variable name
  • old_value Any Previous value, nil if the variable was not set
  • new_value Any New value, nil if the variable has been unset
  • ent_idx Number Index of the entity, which is known even if the entity is not

Called from

  • run_changed_hook

Call sites

Defined in