megaman54 Posted June 15, 2013 Share Posted June 15, 2013 (edited) Hi all! I'm trying to make a box ESP script but i have problems with the lines being too big. Here is 2 pics to help understand the problem: Here everything is nice when i'm close to the ped: But here the lines are too big when i'm far away: Here is my code so far: function render() for i,v in ipairs(getElementsByType("ped"))do local x1,y1,z1 = getElementPosition(localPlayer) local x2,y2,z2 = getElementPosition(v) local fDistance = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) if(v ~= localPlayer)then local sx,sy = getScreenFromWorldPosition(x2,y2,z2) dxDrawLine(sx-80, sy-200, sx-80, sy+200, tocolor(255, 0, 0, 255), 2) dxDrawLine(sx-80, sy-200, sx+80, sy-200, tocolor(255, 0, 0, 255), 2) end end end addEventHandler("onClientRender", root, render) Edited June 15, 2013 by Guest Link to comment
Moderators IIYAMA Posted June 15, 2013 Moderators Share Posted June 15, 2013 Why don't you use: https://wiki.multitheftauto.com/wiki/DxDrawLine3D easier to make 2D/3D boxes. Link to comment
megaman54 Posted June 15, 2013 Author Share Posted June 15, 2013 But i prefer dxDrawLine because its already 2D. Link to comment
Moderators IIYAMA Posted June 15, 2013 Moderators Share Posted June 15, 2013 The problem is that you can't really compare distance with camera size.(as far as I know) But you can try: You have two screenshots, create two times this structure. One close and another one far away. This is just a sample:The size of the small one is: 50 px The size of the large one is: 200 px The distance is: 10 units. 200 - 50 = 150 -- differences --differences/ units = 150 / 10 = 15 -- amount of size de-increase per unit local newsize = size -(units * 15) if newsize > 0 then -- do something. end Link to comment
DiSaMe Posted June 15, 2013 Share Posted June 15, 2013 IIYAMA, I don't know what you're talking about. The size of the camera is 0 because camera is at one definite point. It doesn't have a size. megaman54, it's simple to figure out logically. When you are further from the object, it looks smaller. That means, if the distance is bigger, the observable size is smaller. The arithmetic operation whose result is closer to zero with bigger operand is division. So you need to divide the size by distance to get the visible size. Link to comment
megaman54 Posted June 15, 2013 Author Share Posted June 15, 2013 I will try dividing the distance. Thanks EDIT: well it dint really wrok, the line goed to wroing direction when i moved.. Link to comment
denny199 Posted June 16, 2013 Share Posted June 16, 2013 You could use getElementBoundingBox Something like this: local minx, miny, minz, mx, my, mz = getElementBoundingBox(value) local x, y, z = getElementPosition(value) dxDrawLine3D(minx+x, miny+y, mz+z+5, minx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(minx+x, miny+y, mz+z+5, mx+x, miny+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(mx+x, my+y, mz+z+5, minx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(mx+x, miny+y, mz+z+5, mx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) [This will create a square arround the player, used this for a predator missle] This will resize automatic, as i saw on your picture, you are tryting to make a info box right? Link to comment
megaman54 Posted June 16, 2013 Author Share Posted June 16, 2013 You could use getElementBoundingBox Something like this: local minx, miny, minz, mx, my, mz = getElementBoundingBox(value) local x, y, z = getElementPosition(value) dxDrawLine3D(minx+x, miny+y, mz+z+5, minx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(minx+x, miny+y, mz+z+5, mx+x, miny+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(mx+x, my+y, mz+z+5, minx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) dxDrawLine3D(mx+x, miny+y, mz+z+5, mx+x, my+y ,mz+z+5, tocolor(255, 0, 0, 255), 15, false, 0) [This will create a square arround the player, used this for a predator missle] This will resize automatic, as i saw on your picture, you are tryting to make a info box right? Yes something like that but 2D. Isn't there anyway to scale them in 2D? Link to comment
denny199 Posted June 16, 2013 Share Posted June 16, 2013 Use https://wiki.multitheftauto.com/wiki/Ge ... ldPosition Link to comment
megaman54 Posted June 16, 2013 Author Share Posted June 16, 2013 Thats what im doing already. See code in original post: https://forum.multitheftauto.com/viewtopic.php?f=91&t=60806&sid=ada856ec7f87816253df745c4ce7276f#p579319 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