Jump to content

dxDrawRectangle


Recommended Posts

Posted

Hola chicos del MTA!

Tengo un problema que no tengo idea de como resolverlo..

Lo que pasa es que quisiera que quede así la Rectangle
PD: Lo hice con el guieditor para hacerme explicar

Pero cuando pongo el Rectangle se pone así :(

cuando muevo cámara se pone así también

Alguna manera de arreglarlo dejo la función aquí mismo!

 

addEventHandler("onClientRender", root,
	function()
		for k, v in ipairs(getElementsByType("ped")) do
			local x, y, z = getElementPosition(localPlayer)
			local x2, y2, z2 = getElementPosition(v)
			local a, b = 100, 100
			local cx, cy, cz = getCameraMatrix()
			if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2 + 0.5) < 7 and isLineOfSightClear(cx, cy, cz, x2, y2, z2 + 0.5, true, true, false) then
			local sx, sy = getScreenFromWorldPosition(x2, y2, z2 + 0.5)
				if sx and sy then
					sx, sy = sx - a, sy - b
					dxDrawRectangle(sx - 10, sy, sx + 20, sy + 20, tocolor(0, 0, 0, 100))
					dxDrawText("Salud: ".. math.ceil(getElementHealth(v)).."", sx - 10, sy, sx + 500, sy + 500, tocolor(0, 255, 0, 100), 1.2, "default-bold")
				end
			end
		end
	end	
)

Por favor necesito ayuda es para mi Roleplay :'(

Posted

Estás sumando la posición x al width y la y al height, ¿con qué propósito haces esto? Ese es el fallo.

Posted (edited)
21 minutes ago, MarkFlash said:

Por más que lo ponga derecho el problema sigue al mover la cámara se ancha más y baja más...

Ya te he dicho por qué sucede esto, lee mi primer comentario y razona.

Edited by danibayez
Posted

El fallo es que estás sumando al ancho y al alto del rectángulo la posición obtenida con getScreenFromWorldPosition. ¿Lo entiendes ahora?

Posted
6 hours ago, danibayez said:

El fallo es que estás sumando al ancho y al alto del rectángulo la posición obtenida con getScreenFromWorldPosition. ¿Lo entiendes ahora?

Ah ya entendí, veré si funciona :)

Posted

Cambia la línea 12.

 

dxDrawRectangle( sx - 10, sy, 20, 20, tocolor( 0, 0, 0, 100 ) )

A ver si así lo llegas a entender.

Posted

 

On 2017-5-7 at 05:07, danibayez said:

Cambia la línea 12.

 


dxDrawRectangle( sx - 10, sy, 20, 20, tocolor( 0, 0, 0, 100 ) )

A ver si así lo llegas a entender.

man he hecho lo que me dices pero sigue..

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...