publicVariable: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "[[Category:Scripting_Commands_Take_On_Helicopters" to "[[Category:Scripting Commands Take On Helicopters") |
Lou Montana (talk | contribs) (Fix description and clean comments) |
||
Line 11: | Line 11: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | 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 [[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. | |||
Variables broadcast with [[publicVariable]] during a mission | {{Important | Using [[publicVariable]] too frequently and/or with a lot of data can cause other aspects of the game to experience bandwidth problems.}} | ||
Such | |||
<br> | <br> | ||
The following [[Data Types]] are supported: | |||
It is | {{{!}} class{{=}}"wikitable" style{{=}}"text-align: center" | ||
[[Team Member]] is | ! Type | ||
{{!}} [[Number]] | |||
{{!}} [[Boolean]] | |||
{{!}} [[Object]] | |||
{{!}} [[Group]] | |||
{{!}} [[String]] | |||
{{!}} [[Text]] | |||
{{!}} [[Array]] | |||
{{!}} [[Code]] | |||
{{!}} [[Nothing]] ([[nil]]) | |||
{{!}}- | |||
! Since | |||
{{!}} | |||
{{!}} {{GVI|ofp|1.34}} | |||
{{!}} {{GVI|ofp|1.34}} | |||
{{!}} {{GVI|ofp|1.34}} | |||
{{!}} {{GVI|arma|1.00}} | |||
{{!}} {{GVI|arma|1.00}} | |||
{{!}} {{GVI|arma|1.09}} | |||
{{!}} {{GVI|arma|1.09}} | |||
{{!}} {{GVI|arma3|1.26}} | |||
{{!}}} | |||
{{Important| It is not possible (and illogical) to transfer a local entity reference, such as [[Script|scripts]], [[Display|displays]] or [[createVehicleLocal|local objects]].<br> | |||
Also, note that [[Team Member]] is not supported.}} |Description= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [[publicVariable]] varName |Syntax= | | [[publicVariable]] varName |Syntax= | ||
|p1= varName: [[String]] |Parameter 1= | |p1= varName: [[String]] - the [[Variables#Global Scope|global variable]]'s [[Identifier]] |Parameter 1= | ||
| [[Nothing]] |Return value= | | [[Nothing]] |Return value= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x2= <code> | |x1= <code>TAG_MyPublicVariable = 0; | ||
[[ | TAG_MyPublicVariable = 1; | ||
[[publicVariable]] "TAG_MyPublicVariable"; {{cc|other clients will receive the "TAG_MyPublicVariable" variable with a '''1''' value}} | |||
TAG_MyPublicVariable = 2; {{cc|needs to be broadcast again - synchronisation is not automatic}}</code> |Example 1= | |||
|x2= JIP example: | |||
<code>[[if]] ([[isNil]] "TAG_CurrentTarget") [[then]] {{cc|has the variable already been set and broadcast?}} | |||
{ | |||
TAG_CurrentTarget = [[objNull]]; {{cc|if not, set it on the local machine}} | |||
}; | |||
[[player]] [[doTarget]] TAG_CurrentTarget;</code> |Example 2= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [[Multiplayer Scripting]], [[Initialization Order]], [[addPublicVariableEventHandler]], [[publicVariableClient]], [[publicVariableServer]] |See also= | | [[Multiplayer Scripting]], [[Initialization Order]], [[addPublicVariableEventHandler]], [[publicVariableClient]], [[publicVariableServer]], [[Variables#Global Scope|Global Variable]], [[Event Scripts]], [[Join In Progress]] |See also= | ||
}} | }} | ||
Line 55: | Line 73: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
<dd class="notedate">Posted on 12 April, 2008 | <dd class="notedate">Posted on 12 April, 2008 | ||
Line 64: | Line 78: | ||
<dd class="note">Be sure to place your variable name in quotation marks. | <dd class="note">Be sure to place your variable name in quotation marks. | ||
This may sound awfully simple, but many times I have forgotten to do this, and it has resulted in no end of headaches for me. | This may sound awfully simple, but many times I have forgotten to do this, and it has resulted in no end of headaches for me. | ||
<!-- Note Section END --> | <!-- Note Section END --> | ||
Line 100: | Line 83: | ||
<h3 style="display:none">Bottom Section</h3> | <h3 style="display:none">Bottom Section</h3> | ||
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]] | ||
Line 106: | Line 88: | ||
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | |||
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]] | ||
[[Category: | [[Category:Command Group: Multiplayer|{{uc:{{PAGENAME}}}}]] | ||
Revision as of 18:52, 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;
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
- Posted on 12 April, 2008
- Icemotoboy
- Be sure to place your variable name in quotation marks. This may sound awfully simple, but many times I have forgotten to do this, and it has resulted in no end of headaches for me.
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