Feche1320 Posted March 20, 2012 Share Posted March 20, 2012 So, I'm drawing a text on the world, using getScreenFromWorldPosition and getDistanceBetweenPoints3D. Everything works perfect, but there's a little detail: if dist <= 80 then local x, y = getScreenFromWorldPosition(pick.posX, pick.posY, pick.posZ, 0.06) local alpha = 255 - (dist * 3.15) local scale = 1 / (0.7 * (dist / 150)) if x and y then dxDrawText(getVehicleNameFromModel(pick.vehicle), x, y, x, y, tocolor(255, 255, 255, alpha), scale, "bankgothic", "center") end end If I go away, text just get's smaller and it doesn't have a 'relative' value according to the distance. Help would be appreciated, thanks. Link to comment
arezu Posted March 20, 2012 Share Posted March 20, 2012 Do you want the text size to be the stay the same size? or what? Link to comment
drk Posted March 30, 2012 Share Posted March 30, 2012 Do you want the text size to be the stay the same size? or what? Link to comment
qaisjp Posted March 30, 2012 Share Posted March 30, 2012 try this: -- ************************************************* -- * AFS Centre * -- * Written by [AFS]Qais (c) 2011 * -- * Script stealers will suffer eternal damnation * -- ************************************************* ---------------------------- ---Set your options below--- ---------------------------- local font = "bankgothic" --font to show local text=' awesome text' local fontSize = 2 --size to show local maxViewRange = 10 --Max view range for the display local pointX,pointY,pointZ = 1726.1750488281, -1638.0367431641, 21 --------------------------- --------------------------- local screenWidth, screenHeight = guiGetScreenSize() --This handles the FREEROAM VIEWER addEventHandler("onClientRender", getRootElement(), function() local sx,sy = getScreenFromWorldPosition (pointX,pointY,pointZ) local camX,camY,camZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(camX,camY,camZ,pointX,pointY,pointZ) <= maxViewRange then dxDrawRectangle ( sx - 100, sy + 14.5, screenWidth/7.5 + 200, screenHeight/30 + 20 ,tocolor ( 0, 0, 0, 200 ) ) dxDrawText(text, sx - 100, sy, screenWidth, screenHeight,tocolor ( 0, 110, 255, 255 ), fontSize ,font) end end end ) something i made in 2011, you can distribute as you wish clean some components yourself. 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