publicVariable: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 41: Line 41:
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[6thSense.eu:EG|MP editing guide]], [[addPublicVariableEventHandler]], [[publicVariableClient]] [[publicVariableServer]] |= See also
| [[6thSense.eu:EG|MP editing guide]], [[addPublicVariableEventHandler]], [[publicVariableClient]], [[publicVariableServer]] |= See also
| mp= The message is sent consequently and reliably to all clients. Using publicVariable too frequently in a given period of time can cause other parts of the game to experience bandwidth problems.|=
| mp= The message is sent consequently and reliably to all clients. Using publicVariable too frequently in a given period of time can cause other parts of the game to experience bandwidth problems.|=
}}
}}

Revision as of 01:51, 29 August 2012

Hover & click on the images for description

Description

Description:
Broadcast variable value to all computers. Only type Number is supported in version 1.33 and before. Following Types are supported since version 1.34: Following Types are supported since version ArmA v1.00: Since version ArmA v1.09: Any value can be transferred, including The only limitation is you cannot transfer references to entities which are local, like scripts, displays, or local objects.
Multiplayer:
The message is sent consequently and reliably to all clients. Using publicVariable too frequently in a given period of time can cause other parts of the game to experience bandwidth problems.
Groups:
Uncategorised

Syntax

Syntax:
publicVariable varName
Parameters:
varName: String
Return Value:
Nothing

Examples

Example 1:
publicVariable "CTFscoreOne"

Additional Information

See also:
MP editing guideaddPublicVariableEventHandlerpublicVariableClientpublicVariableServer

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 2007
This command broadcasts a variable to all clients, but as soon as you change the variable again, you have to use publicVariable again, as it does not automatically synchronise it.
Posted on 2 Feb, 2008
Dr_Eyeball
When initialising a public variable to handle JIP, you will usually first want to check if the public variable has already been (broadcast, received and) set locally. Otherwise you may inadvertantly overwrite the broadcast value with your default value.

To perform this check, use code similar to the following to first check that the variable is nil: if (isNil "PV_abc") then { // set the nil variable with a default value for server and both JIP & 'join at mission start' PV_abc = [7, 8, 9]; }; // else public variable has already been set due to a public variable broadcast.
Posted on 14 July, 2011
kju
To make Dr_Eyeball's note even more clear: For JIP players pV'ed variables are received and set BEFORE the init.sqf. So to avoid the received variables getting overwritten by variable initialization normally done in the init.sqf, you HAVE TO to use the 'if (isNil "PV_abc")' pattern. It says literally: "Only initialize value it has not yet been set. And in a JIP this may already been the cause due to publicVariable use".
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.
Posted on 13 April, 2008
=FSI=Corsair
Var type "side" cannot be sent on 1.08, it will work in 1.11, 1.09 not tested

Bottom Section