createMarker: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (fixed example 3)
m (Fix)
(79 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
|version2= 1.00


|gr1 = Markers |GROUP1=
|game3= arma2oa
|version3= 1.50


|eff= global |Effects in MP=
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| Creates a new map marker at the given position. The marker name has to be unique, if a marker with the given name exists, the command will be ignored. Use [[deleteMarker]] to delete global marker.
|game5= arma3
{{Important|The marker will be visible once at least [[markerType]] has been defined:
|version5= 0.50
<div><code>_markerName {{=}} [[createMarker]] ["markername", [[player]]];
_markerName [[setMarkerType]] "hd_dot";</code></div>}}
{{Informative|If position is given in 3D format, the <tt>z</tt> coordinate is stored with the marker and will be used when marker is passed to commands like [[createVehicle]], [[createUnit]], [[createAgent]], [[createMine]], [[setVehiclePosition]] for example. When marker is manually placed in the editor, <tt>z</tt> is 0, which means it is placed on the ground. However when user manually places marker on the map in game, it is placed on the water, so <tt>z</tt> of the marker will be: <tt>[[-]][[getTerrainHeightASL]] [[markerPos]] &lt;USERMARKER&gt;</tt>}}
{{Informative|'''Multiplayer optimisation:''' Global marker commands always broadcast the ''entire'' marker state over the network. As such, the number of network messages exchanged when creating or editing a marker can be reduced by performing all but the last operation using local marker commands, then using a global marker command for the last change (and subsequent global broadcast of all changes applied to the marker).}}
|Description=
____________________________________________________________________________________________


| [[createMarker]] [name, position, channelID, creator] |Syntax=
|gr1= Markers


|p1= [name, position, channel, creator]: [[Array]] |Parameter 1=
|eff= global


|p2= name: [[String]] - Name of the marker. If "_USER_DEFINED" is added as prefix, the marker can be deleted by the player |Parameter 2=
|descr= Creates a new map marker at the given position. The marker will be created for every connected player as well as all JIP players. The marker name has to be unique; the command will be ignored if a marker with the given name already exists.


|p3= position: [[Array]] or [[Object]] - format position: [[Position2D]], [[PositionAGL]] or [[Object]] (object's [[PositionWorld]] is used)|Parameter 3=
{{Feature|important|
The marker will be visible only once at least [[markerType]] has been defined:
<sqf>
_marker = createMarker ["markername", player]; // Not visible yet.
_marker setMarkerType "hd_dot"; // Visible.</sqf>
}}
 
{{Feature|informative|If the marker position is given in 3D format, the {{hl|z}}-coordinate is stored with the marker and will be used when the marker is passed to commands such as [[createVehicle]], [[createUnit]], [[createAgent]], [[createMine]] or [[setVehiclePosition]].<br>When a marker is manually placed in the editor, {{hl|z}} is always 0, which means the marker is placed on the ground. But when the player places a marker on the map in game, it is placed at sea level, so the {{hl|z}}-coordinate of that marker is <sqf inline>-getTerrainHeightASL markerPos "userMarker";</sqf>.}}
 
|mp= {{Feature|informative|'''Multiplayer optimisation:''' Global marker commands always broadcast the ''entire'' marker state over the network. As such, the number of network messages exchanged when creating or editing a marker can be reduced by performing all but the last operation using local marker commands, then using a global marker command for the last change (and subsequent global broadcast of all changes applied to the marker).}}
 
|pr= [[setMarkerDrawPriority]] sorts [[allMapMarkers]] from least to most priority. As of {{GVI|arma3|2.16|size= 0.75}} [[createMarker]]/[[createMarkerLocal]] do '''not''' care about drawing priority and add the created marker to the end of the array, making it top priority. Running [[setMarkerDrawPriority]] again sorts this issue.
 
|s1= [[createMarker]] [name, position, channel, creator]
 
|p1= name: [[String]] - the marker's name, used to reference the marker in scripts.


|p4= channelID: [[Number]] - (Optional) The marker channel for MP. {{since|arma3|2.01.146752}}|Parameter 4=
|p2= position: [[Array]] or [[Object]] - [[Position#Introduction|Position2D]], [[Position#PositionAGL|PositionAGL]] or [[Object]]. In case of an object, the object's '''model centre'''<nowiki/>'s [[Position#PositionASL|PositionASL]] is used (see [[getPosWorld]])


|p5= creator: [[Object]] - (Optional) The marker creator for MP. {{since|arma3|2.01.146752}}|Parameter 5=
|p3= channel: [[Number]] - (Optional, default -1) the marker channel - see [[Channel IDs]] (for multiplayer)
|p3since= arma3 2.02


| [[String]] |Return value=
|p4= creator: [[Object]] - (Optional, default [[objNull]]) the marker creator (for multiplayer)
____________________________________________________________________________________________
|p4since= arma3 2.02
 
|x1= <code>_marker1 = [[createMarker]] ["Marker1", [[position]] [[player]]];
_marker1 [[setMarkerType]] "hd_dot";</code> |Example 1=


|x2= <code>_marker2 = [[createMarker]] ["Marker2", [[player]]];
|r1= [[String]] - the marker's name or empty string if the marker name is not unique.
_marker2 [[setMarkerType]] "hd_dot"; {{codecomment|// since {{arma3}} v1.50}}</code> |Example 2=


|x3= <code>_marker3 = [[createMarker]] ["_USER_DEFINED_Marker3", [[player]]];
|x1= <sqf>_marker1 = createMarker ["Marker1", position player];</sqf>
_marker3 [[setMarkerType]] "hd_dot"; {{codecomment|// This marker can be deleted by  any player}}</code> |Example 3=
____________________________________________________________________________________________


|mp= [[createMarker]] is global which means it will be created for every client and also for [[JIP]], use [[createMarkerLocal]] if you want to create a [[local]] marker. |multiplayer=
|x2= <sqf>_marker2 = createMarker ["Marker2", player]; // since {{arma3}} 1.50</sqf>


| [[allMapMarkers]], [[deleteMarker]], [[createMarkerLocal]], [[allMapMarkers]]
|seealso= [[createMarkerLocal]] [[deleteMarker]] [[BIS_fnc_markerToString]] [[BIS_fnc_stringToMarker]]
[[setMarkerBrush]], [[setMarkerColor]], [[setMarkerDir]]
[[setMarkerPos]], [[setMarkerShape]], [[setMarkerSize]]
[[setMarkerText]], [[setMarkerType]], [[setMarkerAlpha]], [[BIS_fnc_markerToString]], [[BIS_fnc_stringToMarker]] |See also=
}}
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
|user= Soldia
[[Category:Scripting Commands OFP Elite |{{uc:{{PAGENAME}}}}]]
|timestamp= 20150919210200
[[Category:Scripting Commands Armed Assault|{{uc:{{PAGENAME}}}}]]
|text= [[createMarker]] accepts an object as position parameter as well . You could try this with the following code (both SP/MP)
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
<sqf>
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
_markerstr = createMarker ["markername", player];
_markerstr setMarkerShape "RECTANGLE";
_markerstr setMarkerSize [100, 100];
</sqf>
|game= arma3
|version= 1.50
}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= X39
<dd class="notedate">Posted on April 11, 2019 - 07:10 (UTC)</dd>
|timestamp= 20180528115700
<dt class="note">[[User:killzone_kid|killzone_kid]]</dt>
|text= In {{arma3}}, one can create markers which are deletable by the user by prefixing the name with {{hl|_USER_DEFINED}}.
<dd class="note">
Passing object as argument for position may produce slightly different position than when explicitly obtaining object position via position commands, as in
<code>[[createMarker]] ["marker1", _obj]</code>
may slightly differ from
<code>[[createMarker]] ["marker1", [[ASLtoAGL]] [[getPosASL]] _obj]</code>
This is because when object passed as position, the raw [[getPosWorld]] is used
<code>[[createMarker]] ["marker1", [[ASLtoAGL]] [[getPosWorld]] _obj]</code> will produce identical result in this case, but may not be what is required
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
Example:
<dl class="command_description">
<sqf>createMarker "_USER_DEFINED someMarkerName"</sqf>
<dd class="notedate">Posted on May 3, 2019 - 15:53 (UTC)</dd>
}}
<dt class="note">[[User:7erra|7erra]]</dt>
 
<dd class="note">
{{Note
{{GVI|arma3|1.92}} There is a new function with which you can create a marker with all settings applied in one step: [[BIS_fnc_stringToMarker]] and [[BIS_fnc_stringToMarkerLocal]]
|user= 7erra
</dd>
|timestamp= 20190503155300
</dl>
|text= There is a new function with which you can create a marker with all settings applied in one step: [[BIS_fnc_stringToMarker]] and [[BIS_fnc_stringToMarkerLocal]]
<!-- DISCONTINUE Notes -->
|game= arma3
|version= 1.92
}}
 
{{Note
|user= Tirpitz
|timestamp= 20210126224200
|text= When creating a marker with the name format: "_USER_DEFINED #n1/n2/n3".
n1 can be used to set the owner, n2 I think is an incrementing index to ensure markers are unique, to this end also mangle some more characters onto the end of the string, and n3 is the channel ID the marker is in.
<sqf>_markerName = format ["_USER_DEFINED #%1/%2/%3" , clientOwner,_index, _ChannelID];
_marker = createMarkerLocal [_markerName, _pos];</sqf>
}}
 
{{Note
|user= POLPOX
|timestamp= 20230708160357
|text= If you use the letter "/" in the name, it may break the channel visibilities (especially in MP).
Possible reason is described above by Tirpitz, the engine may confuse which channel the marker belongs to after the "/".
}}

Revision as of 13:00, 19 April 2024

Hover & click on the images for description

Description

Description:
Creates a new map marker at the given position. The marker will be created for every connected player as well as all JIP players. The marker name has to be unique; the command will be ignored if a marker with the given name already exists.
The marker will be visible only once at least markerType has been defined:
_marker = createMarker ["markername", player]; // Not visible yet. _marker setMarkerType "hd_dot"; // Visible.
If the marker position is given in 3D format, the z-coordinate is stored with the marker and will be used when the marker is passed to commands such as createVehicle, createUnit, createAgent, createMine or setVehiclePosition.
When a marker is manually placed in the editor, z is always 0, which means the marker is placed on the ground. But when the player places a marker on the map in game, it is placed at sea level, so the z-coordinate of that marker is -getTerrainHeightASL markerPos "userMarker";.
Multiplayer:
Multiplayer optimisation: Global marker commands always broadcast the entire marker state over the network. As such, the number of network messages exchanged when creating or editing a marker can be reduced by performing all but the last operation using local marker commands, then using a global marker command for the last change (and subsequent global broadcast of all changes applied to the marker).
Problems:
setMarkerDrawPriority sorts allMapMarkers from least to most priority. As of Arma 3 logo black.png2.16 createMarker/createMarkerLocal do not care about drawing priority and add the created marker to the end of the array, making it top priority. Running setMarkerDrawPriority again sorts this issue.
Groups:
Markers

Syntax

Syntax:
createMarker [name, position, channel, creator]
Parameters:
name: String - the marker's name, used to reference the marker in scripts.
position: Array or Object - Position2D, PositionAGL or Object. In case of an object, the object's model centre's PositionASL is used (see getPosWorld)
since Arma 3 logo black.png2.02
channel: Number - (Optional, default -1) the marker channel - see Channel IDs (for multiplayer)
since Arma 3 logo black.png2.02
creator: Object - (Optional, default objNull) the marker creator (for multiplayer)
Return Value:
String - the marker's name or empty string if the marker name is not unique.

Examples

Example 1:
_marker1 = createMarker ["Marker1", position player];
Example 2:
_marker2 = createMarker ["Marker2", player]; // since Arma 3 1.50

Additional Information

See also:
createMarkerLocal deleteMarker BIS_fnc_markerToString BIS_fnc_stringToMarker

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
Soldia - c
Posted on Sep 19, 2015 - 21:02 (UTC)

createMarker accepts an object as position parameter as well . You could try this with the following code (both SP/MP)

_markerstr = createMarker ["markername", player]; _markerstr setMarkerShape "RECTANGLE"; _markerstr setMarkerSize [100, 100];

X39 - c
Posted on May 28, 2018 - 11:57 (UTC)
In Arma 3, one can create markers which are deletable by the user by prefixing the name with _USER_DEFINED. Example:
createMarker "_USER_DEFINED someMarkerName"
7erra - c
Posted on May 03, 2019 - 15:53 (UTC)

There is a new function with which you can create a marker with all settings applied in one step: BIS_fnc_stringToMarker and BIS_fnc_stringToMarkerLocal

Tirpitz - c
Posted on Jan 26, 2021 - 22:42 (UTC)
When creating a marker with the name format: "_USER_DEFINED #n1/n2/n3". n1 can be used to set the owner, n2 I think is an incrementing index to ensure markers are unique, to this end also mangle some more characters onto the end of the string, and n3 is the channel ID the marker is in.
_markerName = format ["_USER_DEFINED #%1/%2/%3" , clientOwner,_index, _ChannelID]; _marker = createMarkerLocal [_markerName, _pos];
POLPOX - c
Posted on Jul 08, 2023 - 16:03 (UTC)
If you use the letter "/" in the name, it may break the channel visibilities (especially in MP). Possible reason is described above by Tirpitz, the engine may confuse which channel the marker belongs to after the "/".