Jump to content
Sign in to follow this  
Darksoul4774

Making a vehicle marker script

Recommended Posts

Hello,

I'm attempting to make a very simple vehicle marker script where all it does is show on the map a black marker with the vehicle name. Can someone help me out?

Thanks! -Darksoul

Share this post


Link to post
Share on other sites

You can just pop this in the vehicles/units init box

null=[this] spawn {_unit = _this select 0;while {alive _unit} do  {  _marker  =  createMarker ["", GetPosASL _unit];  _marker setMarkerType "Dot";  _marker setMarkerColor "ColorBlack";  _marker setMarkerPos getpos _unit;  sleep 0.1;  };};

Share this post


Link to post
Share on other sites
You can just pop this in the vehicles/units init box

null=[this] spawn {_unit = _this select 0;while {alive _unit} do  {  _marker  =  createMarker ["", GetPosASL _unit];  _marker setMarkerType "Dot";  _marker setMarkerColor "ColorBlack";  _marker setMarkerPos getpos _unit;  sleep 0.1;  };};

Will this still work after the unit or vehicle respawns?

Ok seems it does, is there a way I can execute this as a script file from the units init? I just tried doing it but couldn't get it working.

I have:

// movemarker.sqf

null=[this] spawn {_unit = _this select 0; 
while {alive _unit} do  {  _marker  =  createMarker ["", GetPosASL _unit];  
_marker setMarkerType "b_air";  
_marker setMarkerColor "ColorBlue";  
_marker setMarkerText "CH47;  
_marker setMarkerPos getpos _unit;  
sleep 0.1;  
};};

Is there a problem with that? and what should I put in the unit's init to execute that script? Thanks

Edited by clydefrog

Share this post


Link to post
Share on other sites

I haven't done any MP stuff so I wouldn't have much of a clue sorry.

Share this post


Link to post
Share on other sites

Ok, what about using it on multiple units? I just tried adding it to the init fields of 4 helicopters but it would only show the marker on one of them, any way around that? I tried renaming the _marker parts to _marker2 for one of the other helicopters but it made no difference.

Share this post


Link to post
Share on other sites

In scripting it's quite easy. Just place null=[this] execvm "movemarker.sqf" in each units init.

// null=[this] execvm "movemarker.sqf"
_unit = _this select 0; 
_marker_name = "marker" + str _unit;
_marker  =  createMarker [_marker_name , getPosASL _unit];
  _marker setMarkerType "b_air"; 
   _marker setMarkerColor "ColorBlue"; 
   while {alive _unit} do { 
    _marker setMarkerPos getpos _unit; 
           _marker setMarkerText format ["ALT %1", floor (GetPosASL _unit select 2)] ;// optional  Altitude 
     sleep 0.1;  
     };

This may also give you some ideas http://forums.bistudio.com/showthread.php?107880-marker-on-map-script-respawn-Q!&p=1758964&viewfull=1#post1758964

Edited by F2k Sel

Share this post


Link to post
Share on other sites
In scripting it's quite easy. Just place null=[this] execvm "movemarker.sqf" in each units init.

// null=[this] execvm "movemarker.sqf"
_unit = _this select 0; 
_marker_name = "marker" + str _unit;
_marker  =  createMarker [_marker_name , getPosASL _unit];
  _marker setMarkerType "b_air"; 
   _marker setMarkerColor "ColorBlue"; 
   while {alive _unit} do { 
    _marker setMarkerPos getpos _unit; 
           _marker setMarkerText format ["ALT %1", floor (GetPosASL _unit select 2)] ;// optional  Altitude 
     sleep 0.1;  
     };

This may also give you some ideas http://forums.bistudio.com/showthread.php?107880-marker-on-map-script-respawn-Q!&p=1758964&viewfull=1#post1758964

Thanks for that, one problem though, it doesn't follow the unit/vehicle haha.

Edit: nm I recopied it and now it works, did you edit it?

That works thanks, it just doesn't work again after respawning, the marker doesn't respawn

Edited by clydefrog

Share this post


Link to post
Share on other sites
it just doesn't work again after respawning

You need to make sure you're using a respawn script that will reapply the init field to the vehicle. Tophe's Simple Vehicle Respawn Script 0.7 does for example. Or make the script loop after it's !alive.

Share this post


Link to post
Share on other sites

Hmm, pretty sure I'm using that respawn script. Yeah I am.

/*  
=========================================================
 Simple Vehicle Respawn Script v1.7
 by Tophe of Östgöta Ops [OOPS]

 Put this in the vehicles init line:
 veh = [this] execVM "vehicle.sqf"


 Options:
 There are some optional settings. The format for these are:
 veh = [this, Delay, Deserted timer, Respawns, Effect, Static] execVM "vehicle.sqf"


 Default respawn delay is 30 seconds, to set a custom
 respawn delay time, put that in the init as well. 
 Like this:
 veh = [this, 15] execVM "vehicle.sqf"

 Default respawn time when vehicle is deserted, but not
 destroyed is 120 seconds. To set a custom timer for this 
 first put the respawn delay, then the deserted vehicle timer. (0 = disabled)
 Like this:  
 veh = [this, 15, 10] execVM "vehicle.sqf"

 By default the number of respawns is infinite. To set a limit
 First set the other values then the number of respawns you want (0 = infinite).
 Like this:
 veh = [this, 15, 10, 5] execVM "vehicle.sqf"


 Set this value to TRUE to add a special explosion effect to the wreck when respawning.
 Default value is FALSE, which will simply have the wreck disappear.
 Like this:
 veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"

 By default the vehicle will respawn to the point where it first
 was when the mission started (static). This can be changed to 
 dynamic. Then the vehicle will respawn to the position where it was destroyed. 
 First set all the other values then set TRUE for dynamic or FALSE for static.
 Like this:
 veh = [this, 15, 10, 5, TRUE, TRUE] execVM "vehicle.sqf"

 If you you want to set the INIT field of the respawned vehicle, first set all other 
 values, then set init commands. Those must be inside quotations.
 Like this:
 veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

 Default values of all settings are:
 veh = [this, 30, 120, 0, FALSE, FALSE] execVM "vehicle.sqf"




Contact & Bugreport: harlechin@hotmail.com

=========================================================
*/

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{	
sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
	if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
	{
		_timeout = time + _deserted;
		sleep 0.1;
	 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
		if ({alive _x} count crew _unit > 0) then {_dead = false}; 
		if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
		if !(alive _unit) then {_dead = true; _nodelay = false}; 
	};
};

// Respawn vehicle
     if (_dead) then 
{	
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
	sleep 0.1;

	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;

	if (_haveinit) then 
				{_unit setVehicleInit format ["%1;", _unitinit];
				processInitCommands;};
	if (_hasname) then 
				{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
				processInitCommands;};
	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
};

Share this post


Link to post
Share on other sites

Yup, that's it. So your vehicle's init would be:

veh = [this, 30, 500, 0, FALSE, FALSE, "null=[this] execvm 'movemarker.sqf'"] execVM "vehicle.sqf"; null=[this] execvm "movemarker.sqf";

Share this post


Link to post
Share on other sites
Yup, that's it. So your vehicle's init would be:

veh = [this, 30, 500, 0, FALSE, FALSE, "null=[this] execvm 'movemarker.sqf'"] execVM "vehicle.sqf"; null=[this] execvm "movemarker.sqf";

Ahhh I see. It works perfectly now, thanks all.

Share this post


Link to post
Share on other sites

Hei F2k Sel!

null=[this] spawn {_unit = _this select 0;while {alive _unit} do { _marker = createMarker ["", GetPosASL _unit]; _marker setMarkerType "Dot"; _marker setMarkerColor "ColorBlack"; _marker setMarkerPos getpos _unit; sleep 0.1; };};

I make wrong something? If i write script to all my vehicles init, then will on the map show only 1 marker there. How can fix that?

Cheers!

Edited by Katzok

Share this post


Link to post
Share on other sites

F2k Sel: In scripting it's quite easy. Just place null=[this] execvm "movemarker.sqf" in each units init.

// null=[this] execvm "movemarker.sqf"
_unit = _this select 0; 
_marker_name = "marker" + str _unit;
_marker  =  createMarker [_marker_name , getPosASL _unit];
  _marker setMarkerType "b_air"; 
   _marker setMarkerColor "ColorBlue"; 
   while {alive _unit} do { 
    _marker setMarkerPos getpos _unit; 
           _marker setMarkerText format ["ALT %1", floor (GetPosASL _unit select 2)] ;// optional  Altitude 
     sleep 0.1;  
     };

Okey, i'm get my dots now with names, but how not try, it will not loop if respawn. After respawns markers disappears. I'm understand nothing, but something code i get. At first marker green and if get killed, then is a red short time(until remove dead body), it works. That respawn staff i can't fix and find this >>>this<<< by Killzone_Kid

for [{_i=0},{true},{_i=_i+1}] do {

_unit = _this select _i;

_marker_name = "marker" + str _unit;

_marker = createMarker [_marker_name , getPosASL _unit];

while {alive _unit} do {

_marker setMarkerType "dot";

_marker setMarkerColor "ColorGreen";

_marker setMarkerPos getpos _unit;

_marker setMarkerTextLocal format ["%1",_unit];

sleep 0.1;

};

if (!alive _unit) then {

_marker setMarkerColor "ColorRed"} else {false};

sleep 0.1;

};

Edited by Katzok

Share this post


Link to post
Share on other sites
Yup, that's it. So your vehicle's init would be:

veh = [this, 30, 500, 0, FALSE, FALSE, "null=[this] execvm 'movemarker.sqf'"] execVM "vehicle.sqf"; null=[this] execvm "movemarker.sqf";

Hi kylania

Im use that respawn and searched info about the code. Like other writing, then all works except init variant.

Share this post


Link to post
Share on other sites

//It's looping code and after respawns markers not disappear, but can't read vehicle side. Any help?

while {true} do

{

_x = vehicles;

for "i" from 0 to (count _x) do

{

unit =_x select i;

deleteMarker ("marker"+ (str i));

marker = "marker" + (str i);

marker = createMarker [marker,getPosASL unit];

marker setMarkerType "dot";

marker setMarkerPos (getPos unit);

marker setMarkerColor ("ColorGreen");

marker setMarkerText format ["%1",unit];

sleep 0.1;

}

};

Edited by Katzok

Share this post


Link to post
Share on other sites

OK i see, that script is absolutely disaster! I write "sqf" to my team vehicle init, but code shows up all vehicles on map and enemy too. Why? Can anyone fix?

Edited by Katzok

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×