publicVariable: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Fix description and clean comments) |
Lou Montana (talk | contribs) m (Add example and remove comment) |
||
Line 65: | Line 65: | ||
[[player]] [[doTarget]] TAG_CurrentTarget;</code> |Example 2= | [[player]] [[doTarget]] TAG_CurrentTarget;</code> |Example 2= | ||
|x3= <code>TAG_BossName = "EvilBigBoss"; | |||
[[publicVariable]] TAG_BossName; {{cc|wrong - will try to publicVariable "EvilBigBoss" variable, that does not exist}} | |||
[[publicVariable]] {{Color|red|"}}TAG_BossName{{Color|red|"}}; {{cc|correct - do not forget the {{Color|red|quotes}}}}</code> |Example 3= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 73: | Line 78: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
<!-- Note Section END --> | <!-- Note Section END --> |
Revision as of 18:57, 16 May 2020
Description
- Description:
- Reliably broadcasts missionNamespace variable and its current value to all computers (server/client).
Variables broadcast with publicVariable during a mission will be available to JIP clients with the value they held at the time.
Such variables are persistent and sent to the JIP client before the first batch of client-side Event Scripts (such as init.sqf) is run.
The following Data Types are supported:Type Number Boolean Object Group String Text Array Code Nothing (nil) Since 1.34 1.34 1.34 -wrong parameter ("Arma") defined!-1.00 -wrong parameter ("Arma") defined!-1.00 -wrong parameter ("Arma") defined!-1.09 -wrong parameter ("Arma") defined!-1.09 1.26 - Groups:
- Uncategorised
Syntax
- Syntax:
- publicVariable varName
- Parameters:
- varName: String - the global variable's Identifier
- Return Value:
- Nothing
Examples
- Example 1:
TAG_MyPublicVariable = 0; TAG_MyPublicVariable = 1; publicVariable "TAG_MyPublicVariable"; // other clients will receive the "TAG_MyPublicVariable" variable with a 1 value TAG_MyPublicVariable = 2; // needs to be broadcast again - synchronisation is not automatic
- Example 2:
- JIP example:
if (isNil "TAG_CurrentTarget") then // has the variable already been set and broadcast? { TAG_CurrentTarget = objNull; // if not, set it on the local machine }; player doTarget TAG_CurrentTarget;
- Example 3:
TAG_BossName = "EvilBigBoss"; publicVariable TAG_BossName; // wrong - will try to publicVariable "EvilBigBoss" variable, that does not exist publicVariable "TAG_BossName"; // correct - do not forget the quotes
Additional Information
- See also:
- Multiplayer ScriptingInitialization OrderaddPublicVariableEventHandlerpublicVariableClientpublicVariableServerGlobal VariableEvent ScriptsJoin In Progress
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
Bottom Section
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.34
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Uncategorised
- Scripting Commands: Global Effect
- Scripting Commands OFP 1.46
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.99
- Scripting Commands ArmA
- Scripting Commands Arma 2
- Scripting Commands Arma 3
- Scripting Commands Take On Helicopters
- Command Group: Multiplayer