publicVariable: Difference between revisions
Jump to navigation
Jump to search
(Extended) |
Dr Eyeball (talk | contribs) No edit summary |
||
Line 48: | Line 48: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
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. | <dd class="notedate">Posted 2007</dd> | ||
<dd class="note">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. | |||
</dd> | |||
<dd class="notedate">Posted on 2 Feb, 2008</dd> | |||
<dt class="note">[[User:Dr_Eyeball|Dr_Eyeball]]</dt><dd class="note"> | |||
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.<br> | |||
<br> | |||
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. | |||
<br> | |||
</dd> | |||
<!-- Note Section END --> | <!-- Note Section END --> | ||
</dl> | </dl> |
Revision as of 11:39, 2 February 2008
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 reliably to all clients. Using publicVariable a lot can cause other parts of the game to experience bandwidth problems.
- Groups:
- Uncategorised
Syntax
Examples
- Example 1:
publicVariable "CTFscoreOne"
Additional Information
- See also:
- addPublicVariableEventHandler
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.
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.96
- Scripting Commands OFP 1.46
- Scripting Commands ArmA
- Command Group: Multiplayer