Please note that varName indicates which variable you want to monitor with this eventhandler.
As a result, the example eventhandler on this page will only fire when the variable publicThis has been changed,
but not if any other variable was changed by any other client via the publicVariable command.
MulleDK13
Note on using addPublicVariableEventHandler during initialization: If you need a function to call addPublicVariableEventHandler during initialization, you must use postInit. addPublicVariableEventHandler does not work during preInit.
Killzone_Kid
MulleDK13's note above needs some clarification. You don't "must" use postInit and you absolutely can use preInit function to initialise addPublicVariableEventHandler if you start scheduled script from it.
While it is true that the event handler will only fire on the machine receiving the broadcast value, please note that this machine can actually be the same machine broadcasting it in the cases of publicVariableClient and publicVariableServer.
// This example assumes the client knows their own client ID// It does also work on the server (when the server ID is used) irrespective of the command name"OnClient"addPublicVariableEventHandler { hint"This event handler still fired!"; };
clientID publicVariableClient"OnClient";