publicVariable

From Bohemia Interactive Community
Jump to navigation Jump to search
Introduced with Operation Flashpoint version 1.341.34Arguments of this scripting command have to be local to the client the command is executed onEffects of this scripting command are broadcasted over the network and happen on every computer in the network
Hover & click on the images for descriptions

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.
Using publicVariable too frequently and/or with a lot of data can cause other aspects of the game to experience bandwidth problems.


The following Data Types are supported:

Type Number Boolean Object Group String Text Array Code Nothing (nil)
Since Introduced with Operation Flashpoint version 1.341.34 Introduced with Operation Flashpoint version 1.341.34 Introduced with Operation Flashpoint version 1.341.34 Introduced with Armed Assault version 1.001.00 Introduced with Armed Assault version 1.001.00 Introduced with Armed Assault version 1.091.09 Introduced with Armed Assault version 1.091.09 Introduced with Arma 3 version 1.261.26
It is not possible (and illogical) to transfer a local entity reference, such as scripts, displays or local objects.
Also, note that Team Member is not supported.

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
Groups:
MultiplayerVariables

Notes

i
Only post proven facts here. Report bugs on the Feedback Tracker and discuss on the Arma Discord or on the Forums.

Notes

Bottom Section