Jump to content
Sign in to follow this  
dragonsyr

distance from targer indicator

Recommended Posts

how can i add a distance from target indicator in player screen? (like the speed/alt indicator or as a hint )

Share this post


Link to post
Share on other sites

I mean this isn't exactly what you want but cant you just attach a waypoint to the target?? It won't show the way you want but its similar..

Share this post


Link to post
Share on other sites

i ll try that thanks...

---------- Post added at 21:23 ---------- Previous post was at 21:22 ----------

but i think that this gives me only visual help and not the meters inc/dec from target

Share this post


Link to post
Share on other sites

true sorry man, I have no idea... How to do that sorry, I will work on it.

Share this post


Link to post
Share on other sites

http://community.bistudio.com/wiki/screenToWorld

Here is a way that should work, all depend of the context you want to use it in.

// init.sqf
[] execVM "getAimDistance.sqf";

// getAimDistance.sqf
while {alive player} do {
   hintSilent format ["Distance: %1", player distance ([b]screenToWorld [0.5,0.5][/b])];
   sleep 0.5;
};

you could use Dialogs but this is more complex

Edited by Zigomarvin
  • Thanks 1

Share this post


Link to post
Share on other sites

Created this for our own framework:

/****************************************************************
L.A.M.B.S. Mission Framework
LAF3 version: 0.3.d / 08 DEC 2013

Script: Distance calculator (player to object)
Author: Whiztler
Script version: 1.0

Game type: n/a
File: LAF3_snipDistance.sqf
****************************************************************
Instructions:

Place a small object on the map and name it "obj" (without the ")

Create a trigger with the following params:
Axes A = 0
Axes B = 0
Type: none
Activation: Radio Charlie
Repeatedly
On Act.: null = execVM "Dev\LAF3_snipDistance.sqf";

In your init.sqf, add the following line:
3 setRadioMsg "Show Distance Object-Player"; // Debugging/MM only!

In game use 0-0-3 to check the distance to the object
****************************************************************/

if (isnil "obj") exitwith { // The object does not not exist. Display an error message
Hint parseText format ["
<t color='#FE2E2E' align='left' size='1.2'>Error!</t><br/><br/>
<t color='#C1C3CB' align='left'>You need to place an object on the map and name it: </t><t color='#FFFFFF' align='left'>obj</t><br/><br/>
<t color='#C1C3CB' align='left'>The script calculates the distance between you (player) and the object.</t>"];
};

n = 2; nL = 4; // nr. of decimals to round off to

_objDisR = 0;
_objDis = player distance obj; // Check the distance in meters
if (_objDis > 1000) then {disVal = "kilometres"; _objDisR = round ((_objDis * (10 ^ n)) / (10 ^ n) / 1000);}; // Set to kilometres (rounded)
if (_objDis < 1000) then {disVal = "meters"; _objDisR = round (_objDis * (10 ^ n)) / (10 ^ n);}; // Meters (rounded)
if (_objDis < 1) then {disVal = "centimetres"; _objDisR = round (_objDis * 100);}; // Centimtres (rounded)

_objDir = [player, obj] call BIS_fnc_relativeDirTo; // Check the direction of the object relative to the player
if (_objDir < 0) then {_objDir = (360 + _objDir);};
if (_objDir > 360) then {_objDir = (_objDir - 360);};
_objDir = round _objDir;
_objLat = round (((getPos obj select 0) * (10 ^ nL)) / (100 ^ nL) * 100); // Latitude of the object (rounded)
_objLon = round (((getPos obj select 1) * (10 ^ nL)) / (100 ^ nL) * 100); // Longitude of the object (rounded)
_objAlt = round ((getPosASL obj select 2) * (10 ^ n)) / (10 ^ n); // ASL altitude of the object (rounded)

// Create the hint with all the data:
HintSilent parseText format["
<t size='1.2' color='#ffffff' align='left'>Distance Calculator</t><br/><br/>
<t color='#C1C3CB' align='left'>You are </t><t align='left' color='#F7D358'>%1</t><t color='#C1C3CB' align='left'> %2 away from the object.</t><br/><br/>
<t color='#C1C3CB' align='left'>The object is at </t><t align='left' color='#F7D358'>%3</t><t color='#C1C3CB' align='left'> degrees, relative from your current position</t><br/><br/>
<t color='#C1C3CB' align='left'>The object is located at grid: <t align='left' color='#F7D358'>%4 %5 </t>and is <t align='left' color='#F7D358'>%6 </t>meter(s) above sea level.</t>
",_objDisR, disVal, _objDir, _objLat, _objLon, _objAlt];

Share this post


Link to post
Share on other sites
http://community.bistudio.com/wiki/screenToWorld

Here is a way that should work, all depend of the context you want to use it in.

// init.sqf
[] execVM "getAimDistance.sqf";

// getAimDistance.sqf
while {alive player} do {
   hintSilent format ["Distance: %1", player distance ([b]screenToWorld [0.5,0.5][/b])];
   sleep 0.5;
};

you could use Dialogs but this is more complex

i think this is that i want, but i need player distance from specific object and not what aim the player (if i undertand right what this does)

while {alive player} do {
   hintSilent format ["Distance: %1", player distance _myobject ([b]screenToWorld [0.5,0.5][/b])];
   sleep 0.5;
}

can i use it like this?

---------- Post added at 14:02 ---------- Previous post was at 13:56 ----------

i m not in front of my computer right now....... in a few hours can make tests......

Edited by dragonsyr

Share this post


Link to post
Share on other sites

oh, ok, yes you can but remove screenToWorld part:

while {alive player} do {
   hintSilent format ["Distance: %1", player distance _myObject];
   sleep 0.5;
};

  • Thanks 1

Share this post


Link to post
Share on other sites

@ zigomarvin ok. i tried all this but nothing happend. no distance for aim and no distance for object...

---------- Post added at 16:28 ---------- Previous post was at 16:20 ----------

@whiztler this working fine !!

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  

×