local: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)<\/code>" to "<code>$1$2$3 $4 $5 $6</code>")
m (Text replacement - "// since Arma 3" to "// since {{arma3}}")
 
(13 intermediate revisions by the same user not shown)
Line 26: Line 26:
|arg= global
|arg= global


|descr= Check if given unit is local on the computer in multiplayer games - see {{HashLink|Multiplayer Scripting#Locality}}.<br>
|descr= Check if given unit is local on the computer in multiplayer games - see {{Link|Multiplayer Scripting#Locality}}.<br>
This can be used to determine on which computer some code must be run. In single player all objects are local.
This can be used to determine on which computer some code must be run. In single player all objects are local.


Line 40: Line 40:


|s2= [[local]] variable = value <span style="margin-left: 7em">'''{{Color|red|From {{arma2}} v1.00 until {{arma3}} v1.54}}''' - see '''[[private]]''' for later versions</span>
|s2= [[local]] variable = value <span style="margin-left: 7em">'''{{Color|red|From {{arma2}} v1.00 until {{arma3}} v1.54}}''' - see '''[[private]]''' for later versions</span>
|s2since= arma2 1.00


|r2= [[Nothing]]
|r2= [[Nothing]]


|x1= <code>if ([[not]] [[local]] _unit) [[then]]
|x1= <sqf>
if (not local _unit) then
{
{
[[hint]] [[format]] ["%1 is remote", [[name]] _unit];
hint format ["%1 is remote", name _unit];
};</code>
};
</sqf>


|x2= <code>_isLocalGroup = local group _unit;</code>
|x2= <sqf>_isLocalGroup = local group _unit;</sqf>


|x3= Sets variable's [[Variables#Scopes|scope]]:
|x3= Sets variable's [[Variables#Scopes|scope]]:
<code>// from {{arma2 v1.00 until {{arma3}} v1.54}}
<sqf>
[[local]] _myVariable = 42;
// from Arma 2 v1.00 until Arma 3v1.54
local _myVariable = 42;


// since {{arma3 v1.54}}
// since {{arma3}} v1.54
private _myVariable = 42;</code>
private _myVariable = 42;
</sqf>


|seealso= [[Arma 3: Event Handlers#Local|"Local" Event Handler]], [[owner]], [[setOwner]]
|seealso= [[Arma 3: Event Handlers#Local|"Local" Event Handler]] [[owner]] [[setOwner]]
}}
}}

Latest revision as of 18:02, 18 November 2023

Hover & click on the images for description

Description

Description:
Check if given unit is local on the computer in multiplayer games - see Multiplayer Scripting - Locality.
This can be used to determine on which computer some code must be run. In single player all objects are local.
Multiplayer:
A few things to note amongst others:
  • A game logic / module is always local to the server
  • Terrain objects are local to every machine
Groups:
Multiplayer

Syntax

Syntax:
local object
Parameters:
object: Object or Group (since Arma 3 logo black.png1.32)
Return Value:
Boolean

Alternative Syntax

Syntax:
local variable = value From Arma 2 v1.00 until Arma 3 v1.54 - see private for later versions
Return Value:
Nothing

Examples

Example 1:
if (not local _unit) then { hint format ["%1 is remote", name _unit]; };
Example 2:
_isLocalGroup = local group _unit;
Example 3:
Sets variable's scope:
// from Arma 2 v1.00 until Arma 3v1.54 local _myVariable = 42; // since Arma 3 v1.54 private _myVariable = 42;

Additional Information

See also:
"Local" Event Handler owner setOwner

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