[HELP] How to fix the size problem in my script?

Recommended Posts

this is the code:


addEventHandler( "onClientRender", root, function (  )
       local x, y, z = getElementPosition( merker1 )
       local Mx, My, Mz = getCameraMatrix(   )
        if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 30 ) then
           local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z +1, 0.07 )
            if ( WorldPositionX and WorldPositionY ) then
				dxDrawRectangle(WorldPositionX -100, WorldPositionY -17, 200, 35, tocolor(0, 0, 0, 175), false)
			    dxDrawText("Pay'n'Spray", WorldPositionX, WorldPositionY, WorldPositionX, WorldPositionY, tocolor(255, 255, 255, 255), 2, "default", "center", "center", false, false, false, false, false)
			    dxDrawImage(WorldPositionX - 100, WorldPositionY -200, 200, 200, "paynspray.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)


and the problem: if i'm far away then the dx elements will be bigger, and when i'm closer.. how to fix this? :) 

Share this post

Link to post

Divide the size by the distance. For example:

local d = getDistanceBetweenPoints3D(x, y, z, Mx, My, Mz);
dxDrawRectangle(x, y, 500/d, 250/d);
dxDrawText("Pay'n'Spray", x, y, x, y, tocolor(255,0,0), 55/d);


Edited by Tails

Share this post

Link to post

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.