local: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Extended note to prevent confusion in the change as current note seems like whole local command got moved into private)
m (Text replacement - "// since Arma 3" to "// since {{arma3}}")
 
(57 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| ofp |= Game name
|game1= ofp
|version1= 1.00


|1.00|= Game version
|game2= ofpe
|version2= 1.00


|arg= global |= Arguments in MP
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| Check if given unit is local on the computer in Multiplayer games (see [[Locality in Multiplayer]] for general concepts).
|game4= arma2
|version4= 1.00


<br>This can be used when some activation fields or scripts need to be performed only on one computer. In Single player all objects are local.  
|game5= arma2oa
|version5= 1.50


<br><br>'''Note1:''' Map created objects (those placed in [[Terrain_Editing|Visitor]]) are local everywhere.
|game6= tkoh
<br>'''Note2:''' Since Arma 3 v1.53.132932 keyword [[local]] has been renamed to [[private]] for consistency and to avoid any confusion. However, this just makes the third example obsolete. It's core functionality still remains. |= Description
|version6= 1.00
____________________________________________________________________________________________


| '''local''' object |= Syntax
|game7= arma3
|version7= 0.50


|p1= object: [[Object]] or [[Group]] (since Arma 3 v1.31.127204) |= Parameter 1
|gr1= Multiplayer


| [[Boolean]] |= Return value
|arg= global
____________________________________________________________________________________________
 
|x1= SQS:<code>?![[local]] _unitName : [[hint]] "remote"</code> |= Example 1


|x2= SQF:<code>[[if]] (![[local]] _unitName) [[then]] {
|descr= Check if given unit is local on the computer in multiplayer games - see {{Link|Multiplayer Scripting#Locality}}.<br>
    [[hint]] "remote";
This can be used to determine on which computer some code must be run. In single player all objects are local.
};</code> |= Example 2


|x3= <code>_isLocalGroup = [[local]] [[group]] _unit;</code> |= Example 3
|mp= A few things to note [[Multiplayer Scripting#General information about locality|amongst others]]:
____________________________________________________________________________________________
* A game logic / module is always local to the server
* Terrain objects are local to every machine


|pr= In MP remote objects are not initialised in functions called by initline or init eventhandlers.|=
|s1= [[local]] object


| [[Arma_3:_Event_Handlers#Local|Local Event Handler]], [[owner]], [[setOwner]] |= See also
|p1= object: [[Object]] or [[Group]] (since {{GVI|arma3|1.32|size= 0.75}})


}}
|r1= [[Boolean]]
 
|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>


<h3 style="display:none">Notes</h3>
|s2since= arma2 1.00
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on August 4, 2006 - 10:56
|r2= [[Nothing]]
<dt class="note">'''[[User:Hardrock|hardrock]]'''<dd class="note">''Notes from before the conversion:''


In multiplayer, a game logic will always be local to the host computer. This works on both dedicated and player-hosted servers.
|x1= <sqf>
if (not local _unit) then
{
hint format ["%1 is remote", name _unit];
};
</sqf>


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


<!-- Note Section END -->
|x3= Sets variable's [[Variables#Scopes|scope]]:
</dl>
<sqf>
// from Arma 2 v1.00 until Arma 3v1.54
local _myVariable = 42;


<h3 style="display:none">Bottom Section</h3>
// since {{arma3}} v1.54
private _myVariable = 42;
</sqf>


[[Category:Scripting Commands|LOCAL]]
|seealso= [[Arma 3: Event Handlers#Local|"Local" Event Handler]] [[owner]] [[setOwner]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
}}
[[Category:Scripting Commands OFP 1.96|LOCAL]]
[[Category:Scripting Commands OFP 1.46|LOCAL]]
[[Category:Scripting Commands ArmA|LOCAL]]
[[Category:Command_Group:_Multiplayer|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Object_Information|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19: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