addPublicVariableEventHandler: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) mNo edit summary |
Killzone Kid (talk | contribs) mNo edit summary |
||
Line 11: | Line 11: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| This event handler will detect if a [[missionNamespace]] variable | | This event handler will detect if a [[missionNamespace]] variable (it is attached to) has been broadcast over network with [[publicVariable]], [[publicVariableClient]] or [[publicVariableServer]] commands and will execute EH code upon detection. Arguments passed to the code in ''_this'' array are: | ||
<br /> | <br /> | ||
<br />_this select 0: [[String]] - broadcast variable name (same variable name EH is attached to) | <br />_this select 0: [[String]] - broadcast variable name (same variable name EH is attached to) | ||
Line 40: | Line 40: | ||
};</code> |= Example 1 | };</code> |= Example 1 | ||
|x2= Client:<code>"'^:)123BURP,+=lol" [[addPublicVariableEventHandler]] {[[hint]] "NUTS are " + _this [[select]] 1};</code> | |x2= Client:<code>"'^:)123BURP,+=lol" [[addPublicVariableEventHandler]] {[[hint]] ("NUTS are " + _this [[select]] 1)};</code> | ||
Server:<code>[[missionNamespace]] [[setVariable]] ["'^:)123BURP,+=lol", "craZZZZy"]; | Server:<code>[[missionNamespace]] [[setVariable]] ["'^:)123BURP,+=lol", "craZZZZy"]; | ||
[[publicVariable]] "'^:)123BURP,+=lol";</code> |= Example 2 | [[publicVariable]] "'^:)123BURP,+=lol";</code> |= Example 2 |
Revision as of 22:33, 22 September 2013
Description
- Description:
- This event handler will detect if a missionNamespace variable (it is attached to) has been broadcast over network with publicVariable, publicVariableClient or publicVariableServer commands and will execute EH code upon detection. Arguments passed to the code in _this array are:
_this select 0: String - broadcast variable name (same variable name EH is attached to)
_this select 1: Anything - broadcast variable value
Please note:
* EH works only in Multiplayer environment.
* EH will not fire on the machine that executed broadcast command, only on the machines that receive the broadcast.
* The value of broadcast variable can be exactly the same, it is the actual broadcast that triggers EH not the change in variable. - Groups:
- Uncategorised
Syntax
- Syntax:
- varName addPublicVariableEventHandler code
- Parameters:
- varName: String - missionNamespace variable name
- code: Code
- Return Value:
- Nothing
Examples
- Example 1:
"publicThis" addPublicVariableEventHandler { hint format [ "%1 has been updated to: %2", _this select 0, _this select 1 ] };
- Example 2:
- Client:
"'^:)123BURP,+=lol" addPublicVariableEventHandler {hint ("NUTS are " + _this select 1)};
Server:missionNamespace setVariable ["'^:)123BURP,+=lol", "craZZZZy"]; publicVariable "'^:)123BURP,+=lol";
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
- TeRp
-
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.