drk Posted December 25, 2011 Share Posted December 25, 2011 I want to turn this distance between two points: function drawDistance ( ) local x, y, sx, sy loadHunterPosition ( ) local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance x, y = AbsoluteToRelativ(1920-721, 1080-55) sx, sy = AbsoluteToRelativ( 1920-515,1080-36 ) dxDrawText (" Distance:",x, y, sx, sy,tocolor(192,255,62,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text x, y = AbsoluteToRelativ(1920-699, 1080-31) sx, sy = AbsoluteToRelativ( 265, 30 ) dxDrawImage( x, y, sx, sy,"images/DistToHunter-Logo.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) x, y = AbsoluteToRelativ(1920-494, 1080-54) sx, sy = AbsoluteToRelativ( 1920-366,800-10 ) dxDrawText( string.format("%.0f",distFromVehicleToHunter).."m",x, y, sx, sy,tocolor(255,255,255,255),0.6,"bankgothic","left","top",false,false,false) end into a percentage. It can be done? If it can be done anyone can help me how to do Link to comment
bossyboy Posted December 25, 2011 Share Posted December 25, 2011 I don't understand how you would turn a distance into a percentage as what would 0% be? Link to comment
Jaysds1 Posted December 25, 2011 Share Posted December 25, 2011 I know it can be done, but it's gonna take some math logic and some more scripting, srry i'm not good with percentage or math Link to comment
drk Posted December 25, 2011 Author Share Posted December 25, 2011 \õ/ I want to made a script that appear on the local player screen with percentage of distance missing to reach hunter. Understand? Link to comment
drk Posted December 25, 2011 Author Share Posted December 25, 2011 I know it can be done, but it's gonna take some math logic and some more scripting, srry i'm not good with percentage or math Im not good with percentage or math too Link to comment
karlis Posted December 25, 2011 Share Posted December 25, 2011 distance=pos2-pos1 --use getDistanceBetweenPoints if 2/3D needed currentDistance=pos2-yourPos --use getDistanceBetweenPoints if 2/3D needed precents=math.min(math.max(math.abs(currentDistance/distance*100),0),100) seriously, you should figure this easy thing on yourself Link to comment
Wojak Posted December 25, 2011 Share Posted December 25, 2011 viewtopic.php?p=376761#p376761 Link to comment
drk Posted December 25, 2011 Author Share Posted December 25, 2011 Thanks karlis ....... Link to comment
Terilu Posted April 24, 2012 Share Posted April 24, 2012 To turn a distance between two points you can take help and advices from an expert who can give you advices about it. I am sure that, an expert has a vast knowledge about it, So, i think taking help from an expert is the best option for you. Link to comment
arezu Posted April 24, 2012 Share Posted April 24, 2012 the easiest way is to just: local hunterDistance = currentDistanceToHunter/maxDistanceToHunter where currentDistanceToHunter is current distance between player and hunter pickup, and maxDistanceToHunter is distance between player spawn position and hunter pickup. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now