OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: stephen271276 on 31 Jan 2011, 21:53:17

Title: Attatch marker to Unit/Vehicle/object
Post by: stephen271276 on 31 Jan 2011, 21:53:17
Is there a simple way to attatch a marker that will move round the map with the item its attatched to so it can be tracked by the player via the map?
NOTE:
Am really crap at scripting hence asking for a simple way or script??
Title: Re: Attatch marker to Unit/Vehicle/object
Post by: SaOk on 31 Jan 2011, 22:19:20
You can use endless loop or change the "true" to something else e.g. (alive itemname).

ScriptName.sqf:
Code: [Select]
while {true} do {sleep 0.05; "MarkerName" setmarkerpos (position itemname);};
In a Trigger (condition true):
Code: [Select]
_nul = [] execVM "ScriptName.sqf";
Title: Re: Attatch marker to Unit/Vehicle/object
Post by: stephen271276 on 31 Jan 2011, 22:43:43
"Markername"
Is this specifying the type of marker or is it just the name Im to give it?
Title: Re: Attatch marker to Unit/Vehicle/object
Post by: SaOk on 31 Jan 2011, 22:49:11
Thats the name you give to the marker. You can write e.g. Mname1 to the name field when creating marker and then use the loop like this:
Code: [Select]
while {true} do {sleep 0.05; "Mname1" setmarkerpos (position itemname);};
In the same way the script name can be anything, just with the sqf end (or sqs but then execVM needs to be just exec).

Edit: And if you have many markers, you dont need to make a separate script for every marker. Just change the script to look like this:
Code: [Select]
_m = _this select 0;
_i = _this select 1;
while {true} do {sleep 0.05; _m setmarkerpos (position _i);};

And use the script like this:
Code: [Select]
_nul = ["Mname1",itemname] execVM "ScriptName.sqf";
_nul = ["Mname2",player] execVM "ScriptName.sqf";

Or just add more markers to move to the loop:
Code: [Select]
while {true} do {sleep 0.05;
"Mname1" setmarkerpos (position itemname);
"Mname2" setmarkerpos (position player);};
Title: Re: Attatch marker to Unit/Vehicle/object
Post by: stephen271276 on 01 Feb 2011, 09:48:57
GREAT!
Works a treat, thanks man!