local: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "[[Category:Scripting_Commands_Take_On_Helicopters" to "[[Category:Scripting Commands Take On Helicopters")
(Add Arma 2 → Arma 3 v1.54 "private" syntax)
Line 9: Line 9:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Check if given unit is local on the computer in Multiplayer games (see [[Locality in Multiplayer]] for general concepts).
| Check if given unit is local on the computer in Multiplayer games - see [[Multiplayer Scripting#Locality|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. |DESCRIPTION=


<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.
|mp= A few things to note [[Multiplayer Scripting#General information about locality|amongst others]]:
 
* A game logic / module is always local to the server
<br><br>'''Note1:''' Map created objects (those placed in [[Terrain_Editing|Visitor]]) are local everywhere.
* Terrain objects are local to every machine |Multiplayer=
<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=
____________________________________________________________________________________________
____________________________________________________________________________________________


| '''local''' object |SYNTAX=
| [[local]] object |SYNTAX=


|p1= object: [[Object]] or [[Group]] (since Arma 3 v1.31.127204) |PARAMETER1=
|p1= object: [[Object]] or [[Group]] (since Arma 3 v1.31.127204) |PARAMETER1=
Line 23: Line 23:
| [[Boolean]] |RETURNVALUE=
| [[Boolean]] |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________
 
|x1= SQS:<code>?![[local]] _unitName : [[hint]] "remote"</code> |EXAMPLE1=


|x2= SQF:<code>[[if]] (![[local]] _unitName) [[then]] {
|s2= [[local]] variable = value <span style="margin-left: 7em">{{Color|red|From {{arma2}} until {{arma3}} v1.54}} - see '''[[private]]''' for later versions</span> |SYNTAX2=
    [[hint]] "remote";
};</code> |EXAMPLE2=


|x3= <code>_isLocalGroup = [[local]] [[group]] _unit;</code> |EXAMPLE3=
|r2= [[Nothing]] |RETURNVALUE2=
____________________________________________________________________________________________
____________________________________________________________________________________________


|pr= In MP remote objects are not initialised in functions called by initline or init eventhandlers.|=
|x1= <code>[[if]] ([[not]] [[local]] _unit) [[then]] {
[[hint]] [[format]] ["%1 is remote", [[name]] _unit];
};</code> |EXAMPLE1=
 
|x2= <code>_isLocalGroup = [[local]] [[group]] _unit;</code> |EXAMPLE2=
 
|x3= Sets variable's [[Variables#Scopes|scope]]:<code>{{cc|From {{arma2}} until {{arma3}} v1.54}}
[[local]] _myVariable = 42;


| [[Arma_3:_Event_Handlers#Local|Local Event Handler]], [[owner]], [[setOwner]] |SEEALSO=
{{cc|Since {{arma3}} v1.54}}
[[private]] _myVariable = 42;</code> |EXAMPLE3=
____________________________________________________________________________________________


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


Line 42: Line 48:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on August 4, 2006 - 10:56
<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.


<!-- Note Section END -->
<!-- Note Section END -->
Line 54: Line 54:
<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>


[[Category:Scripting Commands|LOCAL]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|LOCAL]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
[[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 Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Multiplayer|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Object Information|{{uc:{{PAGENAME}}}}]]

Revision as of 23:29, 13 May 2020

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:
Uncategorised

Syntax

Syntax:
local object
Parameters:
object: Object or Group (since Arma 3 v1.31.127204)
Return Value:
Boolean

Alternative Syntax

Syntax:
local variable = value From Arma 2 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 until Arma 3 v1.54 local _myVariable = 42; // Since Arma 3 v1.54 private _myVariable = 42;

Additional Information

See also:
"Local" Event HandlerownersetOwner

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

Bottom Section