Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Making a vehicle marker script

  1. #1

    Making a vehicle marker script

    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

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

    PHP Code:
    null=[thisspawn {_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;  };}; 

  3. #3
    Quote Originally Posted by F2k Sel View Post
    You can just pop this in the vehicles/units init box

    PHP Code:
    null=[thisspawn {_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:

    PHP Code:
    // movemarker.sqf

    null=[thisspawn {_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
    Last edited by clydefrog; Aug 17 2012 at 12:57.

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

  5. #5
    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.

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

    PHP Code:
    // 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/showthrea...=1#post1758964
    Last edited by F2k Sel; Aug 17 2012 at 14:01.

  7. #7
    Quote Originally Posted by F2k Sel View Post
    In scripting it's quite easy. Just place null=[this] execvm "movemarker.sqf" in each units init.

    PHP Code:
    // 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/showthrea...=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
    Last edited by clydefrog; Aug 17 2012 at 14:24.

  8. #8
    Quote Originally Posted by clydefrog View Post
    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.

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

    Code:
    /*  
    =========================================================
      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;};
    	};
    };

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

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

Page 1 of 2 12 LastLast

Similar Threads

  1. Vehicle marker
    By Filip5 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 3
    Last Post: Apr 3 2011, 17:26
  2. making a marker on click
    By Shammy2010 in forum ARMA 2 & OA : ADDONS - Configs & Scripting
    Replies: 1
    Last Post: Aug 10 2010, 10:37
  3. marker to fallow vehicle
    By Woodstock21 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 3
    Last Post: Mar 15 2010, 18:57
  4. How to make Marker Follow Vehicle
    By mwsteve in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 4
    Last Post: Nov 9 2009, 00:02
  5. Making a marker move to a random spawning object.
    By MechaStalin in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 1
    Last Post: Jan 5 2009, 12:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •