Jump to content
RicardoLew

Updating vehicle height on map

Recommended Posts

I made a script that makes a vehicle marked on the map, showing its display name, custom made callsign and height.

The problem is that i cant make the height to update automatically, i have to close and open the map so it updates.

I would like to know if anyone have a clue how to do so i dont need to close the map to update the height all the time, so i can just open the screen and manage the air transport easily.

Thanks!

Share this post


Link to post
Share on other sites

Perhaps, you should write your script here. It's difficult to fix it without any line. Anyway, this could be a simple loop to add, refreshing the position, height or what you need.

Share this post


Link to post
Share on other sites

private["_name","_markers"];

waituntil{visiblemap};

_markers = [];

_anaccar = nearestObject [player, "ivory_suburban_anac"];
{if( _x isKindOf "Air") then
    {
            _rand = round (random(999));
            _pos = getpos _x;
            _altura = _pos select 2;
            _marker = createMarkerLocal [format["%1_TRACKING",_rand],visiblePosition _x];
            _marker setMarkerColorLocal "ColorRed";
            _marker setMarkerTypeLocal "mil_circle";
            _text = format["Modelo-%1. Registro-%2. Altura-%3m.", getText(configFile >> "cfgVehicles" >> typeOf _x >> "displayName"),_x getVariable["anac_air","Desconhecido"],str _altura];
            _marker setMarkerTextLocal _text;
            _markers pushBack [_marker,_x];
   };
} foreach vehicles;


while {visibleMap} do
{
    {
        private["_marker","_unit"];
        _marker = _x select 0;
        _unit = _x select 1;

        if(!isNil "_unit") then
        {
            if(!isNull _unit) then
            {
                _marker setMarkerPosLocal (visiblePosition _unit);
            };
        };

    } foreach _markers;
    if(!visibleMap) exitWith {};
    uiSleep 0.05;
};

{deleteMarkerLocal (_x select 0);} foreach _markers;
 

Share this post


Link to post
Share on other sites
49 minutes ago, pierremgi said:

Perhaps, you should write your script here. It's difficult to fix it without any line. Anyway, this could be a simple loop to add, refreshing the position, height or what you need.

Good point!

 

private["_name","_markers"];

waituntil{visiblemap};

_markers = [];

_anaccar = nearestObject [player, "ivory_suburban_anac"];
{if( _x isKindOf "Air") then
    {
            _rand = round (random(999));
            _pos = getpos _x;
            _altura = _pos select 2;
            _marker = createMarkerLocal [format["%1_TRACKING",_rand],visiblePosition _x];
            _marker setMarkerColorLocal "ColorRed";
            _marker setMarkerTypeLocal "mil_circle";
            _text = format["Modelo-%1. Registro-%2. Altura-%3m.", getText(configFile >> "cfgVehicles" >> typeOf _x >> "displayName"),_x getVariable["anac_air","Desconhecido"],str _altura];
            _marker setMarkerTextLocal _text;
            _markers pushBack [_marker,_x];
   };
} foreach vehicles;


while {visibleMap} do
{
    {
        private["_marker","_unit"];
        _marker = _x select 0;
        _unit = _x select 1;

        if(!isNil "_unit") then
        {
            if(!isNull _unit) then
            {
                _marker setMarkerPosLocal (visiblePosition _unit);
            };
        };

    } foreach _markers;
    if(!visibleMap) exitWith {};
    uiSleep 0.05;
};

{deleteMarkerLocal (_x select 0);} foreach _markers;

Share this post


Link to post
Share on other sites
// private["_name","_markers"];

waituntil {visiblemap};
_markers = [];
//   _anaccar = nearestObject [player, "ivory_suburban_anac"];
{
            _rand = round (random(999));
            _pos = getpos _x;
            _marker = createMarkerLocal [format["%1_TRACKING",_rand],visiblePosition _x];
            _marker setMarkerColorLocal "ColorRed";
            _marker setMarkerTypeLocal "mil_circle";
            _markers pushBack [_marker,_x];
} foreach vehicles select { _x isKindOf "Air"};

while {visibleMap} do
{
    {
        params ["_marker","_unit"];
        _altura = (getposAtl _x) select 2;
        if(!isNil "_unit" && {!isNull _unit}) then
            {
                _marker setMarkerPosLocal (visiblePosition _unit);
                _text = format["Modelo-%1. Registro-%2. Altura-%3m.", getText(configFile >> "cfgVehicles" >> typeOf _unit >> "displayName"),_unit getVariable["anac_air","Desconhecido"],str _altura];
                _marker setMarkerTextLocal _text;
            };
    } foreach _markers;
    uiSleep 0.05;
};
{deleteMarkerLocal (_x select 0)} foreach _markers;

 

Share this post


Link to post
Share on other sites

Or

addMissionEventHandler [ "Map", {
	_nul = findDisplay 12 displayCtrl 51 ctrlAddEventHandler [ "Draw", {
		{
			_vehicle = _x;

			_vehicle getVariable [ "markerData", [] ] params[
				"_marker",
				[ "_displayName", getText(configFile >> "cfgVehicles" >> typeOf _vehicle >> "displayName") ],
				[ "_regName", _vehicle getVariable[ "anac_air", "Desconhecido" ] ],
				[ "_nextUpdate", time ]
			];

			if ( isNil "_marker" ) then {
				_marker = createMarkerLocal [ format[ "%1_TRACKING", _x call BIS_fnc_netId ], getPosATLVisual _vehicle ];
				_marker setMarkerColorLocal "ColorRed";
				_marker setMarkerTypeLocal "mil_circle";
			};

			if ( _nextUpdate <= time ) then {
				_marker setMarkerPosLocal (getPosASLVisual _vehicle);
				_marker setMarkerTextLocal format["Modelo-%1. Registro-%2. Altura-%3m.", _displayName, _regName, [ 0, ( getPosATLVisual _vehicle ) select 2 ] select !isTouchingGround _vehicle ];

				_vehicle setVariable[ "markerData", [
					_marker,
					_displayName,
					_regName,
					time + 0.05
				]];
			};
		}forEach ( vehicles select { _x isKindOf "Air" } );
	}];
}];

 

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

×