Jump to content

Ayuda con uso de funcion isLineOfSightClear para dibujar texto en marcador siempre y cuando no se interponga un obstaculo.


Hukaeshi

Recommended Posts

Buen día quiero ponerle texto a un marcador pero que cuando un obstáculo este entre el texto no se vea, este es el código que tengo:

 

local g_screenX, g_screenY = guiGetScreenSize(); 
local gScale = 0.3; 
local gAlphaDistance = 25; 
local gMaxDistance = 50; 
local gTextAlpha = 255; 
local gTextSize = 0.7; 
local gAlphaDiff = gMaxDistance - gAlphaDistance;  
gScale = 1 / gScale * 800 / g_screenY; 
local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
  
local BincoSkinLS = createMarker( 207.69, -100.3, 1003.9 , 'Cylinder', 1.5, 0, 0, 255, 150 ); 

  
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        -- 
        local px, py, pz = getElementPosition ( localPlayer  ); 
        local x, y, z = getCameraMatrix(); 
        local x1, y1, z1 = getElementPosition ( BincoSkinLS ); 
 
        local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 

   
        if distance_1 <= gMaxDistance then 
            local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); 

            if x1_ and y1_ then 
                -- 
                local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); 
                local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 

                dxDrawText( "Skins", x1_, y1_, x1_, y1_, tocolor ( 0, 255, 0, textalpha ), textscale * gTextSize, "bankgothic", "center", "bottom", false, false, false, true ); 
        
            end
          end
        
    end 
); 
  

local g_screenX, g_screenY = guiGetScreenSize(); 
local gScale = 0.3; 
local gAlphaDistance = 25; 
local gMaxDistance = 50; 
local gTextAlpha = 255; 
local gTextSize = 0.45; 
local gAlphaDiff = gMaxDistance - gAlphaDistance;  
gScale = 1 / gScale * 800 / g_screenY; 
local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 

 

Agradeciera la ayuda, gracias...

Link to comment

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...