Jump to content

[Help] 3D Text


3B00DG4MER

Recommended Posts

local pedX, pedY, pedZ = 0, 0, 0 
local maxDistance = 12 -- the distance showing 3dtext 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local pX, pY, pZ = getElementPosition ( localPlayer ) 
        local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
         
        if ( distance <= maxDistance ) then 
            local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
            if ( x and y ) then 
                dxDrawText( "text", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) 
            end 
        end 
    end 
) 

It should work, but I'm not sure, couse I was writing it kinda fast. :P

Link to comment
local pedX, pedY, pedZ = 0, 0, 0 
local maxDistance = 12 -- the distance showing 3dtext 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local pX, pY, pZ = getElementPosition ( localPlayer ) 
        local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
         
        if ( distance <= maxDistance ) then 
            local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
            if ( x and y ) then 
                dxDrawText( "text", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) 
            end 
        end 
    end 
) 

It should work, but I'm not sure, couse I was writing it kinda fast. :P

Don't Work

I tried to Attach the Text to a Ped

local ped = createPed          (21, 2000.6636962891, 1538.318359375, 13.5859375) 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
    local pX, pY, pZ = getElementPosition ( ped ) 
        local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
        
        if ( distance <= maxDistance ) then 
            local x, y = getScreenFromWorldPosition ( pX, pY, pZ ) 
            if ( x and y ) then 
            dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) 
            end 
        end 
    end 
) 

But the same fix it with Ped PLease

Link to comment
    local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) 
      
    addEventHandler ( "onClientRender", root, 
        function ( ) 
            local pX, pY, pZ = getElementPosition ( player ) 
            local pedX, pedY, pedZ = getElementPosition ( ped ) 
            local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
            
            if ( distance <= 12 ) then 
                local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                if ( x and y ) then 
                dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) 
                end 
            end 
        end 
    ) 

Link to comment
    local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) 
      
    addEventHandler ( "onClientRender", root, 
        function ( ) 
            local pX, pY, pZ = getElementPosition ( player ) 
            local pedX, pedY, pedZ = getElementPosition ( ped ) 
            local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) 
            
            if ( distance <= 12 ) then 
                local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) 
                if ( x and y ) then 
                dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) 
                end 
            end 
        end 
    ) 

Problem with line "if (distance <= 12) then"

Attempt to compare Boolean with number

i think you must convert distance to number tonumber(distance) afaik

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