publicVariable: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Add HashMap) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
| ofp | |game1= ofp | ||
|1.34 | |version1= 1.34 | ||
|gr1 = Multiplayer | |gr1= Multiplayer | ||
|gr2 = Variables | |gr2= Variables | ||
|arg= local | |arg= local | ||
Line 13: | Line 13: | ||
|eff= global | |eff= global | ||
| Reliably broadcasts [[missionNamespace]] variable and its '''current''' value to all computers (server/client).<br> | |descr= Reliably broadcasts [[missionNamespace]] variable and its '''current''' value to all computers (server/client).<br> | ||
Variables broadcast with [[publicVariable]] during a mission will be available to [[Multiplayer Scripting#Join In Progress|JIP]] clients with the value they held at the time.<br> | Variables broadcast with [[publicVariable]] during a mission will be available to [[Multiplayer Scripting#Join In Progress|JIP]] clients with the value they held at the time.<br> | ||
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. | 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. | ||
Line 33: | Line 33: | ||
{{!}}- | {{!}}- | ||
! Since | ! Since | ||
{{!}} | {{!}} {{GVI|ofp|1.34}} | ||
{{!}} {{GVI|ofp|1.34}} | {{!}} {{GVI|ofp|1.34}} | ||
{{!}} {{GVI|ofp|1.34}} | {{!}} {{GVI|ofp|1.34}} | ||
Line 48: | Line 48: | ||
Also, note that [[Team Member]] is not supported.}} | Also, note that [[Team Member]] is not supported.}} | ||
| [[publicVariable]] varName | |s1= [[publicVariable]] varName | ||
|p1= varName: [[String]] - the [[Variables#Global Scope|global variable]]'s [[Identifier]] | |p1= varName: [[String]] - the [[Variables#Global Scope|global variable]]'s [[Identifier]] | ||
| [[Nothing]] | |r1= [[Nothing]] | ||
|x1= <code>TAG_MyPublicVariable = 0; | |x1= <code>TAG_MyPublicVariable = 0; | ||
Line 73: | Line 73: | ||
[[publicVariable]] {{Color|red|"}}TAG_BossName{{Color|red|"}}; {{cc|correct - do not forget the {{Color|red|quotes}}}}</code> | [[publicVariable]] {{Color|red|"}}TAG_BossName{{Color|red|"}}; {{cc|correct - do not forget the {{Color|red|quotes}}}}</code> | ||
| [[Multiplayer Scripting]], [[Initialization Order]], [[addPublicVariableEventHandler]], [[publicVariableClient]], [[publicVariableServer]], [[Variables#Global Scope|Global Variable]], [[Event Scripts]], [[Multiplayer Scripting#Join In Progress|Join In Progress]] | |seealso= [[Multiplayer Scripting]], [[Initialization Order]], [[addPublicVariableEventHandler]], [[publicVariableClient]], [[publicVariableServer]], [[Variables#Global Scope|Global Variable]], [[Event Scripts]], [[Multiplayer Scripting#Join In Progress|Join In Progress]] | ||
}} | }} | ||
[[Category:Scripting Commands OFP 1.46 | [[Category:Scripting Commands OFP 1.46]] | ||
[[Category:Scripting Commands OFP 1.96 | [[Category:Scripting Commands OFP 1.96]] | ||
[[Category:Scripting Commands OFP 1.99 | [[Category:Scripting Commands OFP 1.99]] | ||
{{GameCategory|arma1|Scripting Commands}} | {{GameCategory|arma1|Scripting Commands}} | ||
{{GameCategory|arma2|Scripting Commands}} | {{GameCategory|arma2|Scripting Commands}} | ||
{{GameCategory|arma3|Scripting Commands}} | {{GameCategory|arma3|Scripting Commands}} | ||
{{GameCategory|tkoh|Scripting Commands}} | {{GameCategory|tkoh|Scripting Commands}} |
Revision as of 19:01, 23 February 2021
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) HashMap Since 1.34 1.34 1.34 1.34 1.00 1.00 1.09 1.09 1.26 2.02 - Groups:
- MultiplayerVariables
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
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.34
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Multiplayer
- Command Group: Variables
- Scripting Commands: Global Effect
- Scripting Commands OFP 1.46
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.99
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 3: Scripting Commands
- Take On Helicopters: Scripting Commands