Modafinil Posted October 27 Share Posted October 27 Hello everyone ! I'm trying to create a 3D rectangle using dxDrawRectangle + getScreenFromWorldPosition to function as a health bar. I'm having difficulty adjusting the width and height. I want the rectangle to get smaller as it moves away from the ped, until it is no longer rendered. local x, y, z = getElementPosition(ped) local lpx, lpy, lpz = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(x, y, z, lpx, lpy, lpz) if dist > 20 then return end local x2, y2 = getScreenFromWorldPosition(x, y, z) local health = getElementHealth(ped) local per = (health * 70) / 100 dxDrawRectangle(x2, y2, 70, 9, tocolor(128, 0, 0, 255)) dxDrawRectangle(x2, y2, per, 9, tocolor(255, 0, 0, 255)) Could someone help me find the correct calculation? 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