Jump to content

3D Names in PED


Gongas

Recommended Posts

sx,sy = guiGetScreenSize() 
textsToDraw = {} 
maxrange = 20 
  
  
function NPCnametag() 
end 
  
addEventHandler("onClientRender",root, 
    function() 
        for a,b in pairs(textsToDraw) do 
            x,y,z = b[1],b[2],b[3] 
            scx,scy = getScreenFromWorldPosition (x,y,z) 
            camX,camY,camZ = getCameraMatrix() 
            if scx and scy and getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z+5) <= maxrange then  
            dxDrawFramedText(b[4],scx-0.5*dxGetTextWidth(b[4],0.30,"pricedown"),scy+30-0.5*dxGetFontHeight(0.30,"pricedown"),sx, sy+5,tocolor ( b[5], b[6], b[7], 255 ), 0.80,"pricedown") 
            end 
        end 
    end 
) 
  
function add3DText(x,y,z,text,r,g,b) 
    table.insert(textsToDraw,{x,y,z,text,r,g,b}) 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI , frameColor ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    dxDrawText ( message , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
end 
  
add3DText( 1177.9,-1328.4,15.3, "Test", 6, 183, 248 ) 
  

Link to comment
sx,sy = guiGetScreenSize() 
textsToDraw = {} 
maxrange = 20 
  
  
function NPCnametag() 
end 
  
addEventHandler("onClientRender",root, 
    function() 
        for a,b in pairs(textsToDraw) do 
            x,y,z = b[1],b[2],b[3] 
            scx,scy = getScreenFromWorldPosition (x,y,z) 
            camX,camY,camZ = getCameraMatrix() 
            if scx and scy and getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z+5) <= maxrange then  
            dxDrawFramedText(b[4],scx-0.5*dxGetTextWidth(b[4],0.30,"pricedown"),scy+30-0.5*dxGetFontHeight(0.30,"pricedown"),sx, sy+5,tocolor ( b[5], b[6], b[7], 255 ), 0.80,"pricedown") 
            end 
        end 
    end 
) 
  
function add3DText(x,y,z,text,r,g,b) 
    table.insert(textsToDraw,{x,y,z,text,r,g,b}) 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI , frameColor ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    dxDrawText ( message , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
end 
  
add3DText( 1177.9,-1328.4,15.3, "Test", 6, 183, 248 ) 
  

i taked the script then i edited "textsToDraw" but the script dont maked the Text what i have to put more? and sorry for the double posting i am realy annoying whit this script help plz

Link to comment

Example incomplete

function sojn() 
    local x,y,z=getElementPosition(sam) 
    local X,Y=getScreenFromWorldPosition(x,y,z) 
    local px,py,pz=getElementPosition(getLocalPlayer()) 
    local dystans=getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
    if dystans < distance then 
    dxDrawText(getPlayerName(sam) .. " ( " .. getPlayerName(sam) .. " )",X,Y) 
    end 

solidsnake

What's wrong with this?? :oops:

Link to comment
"distance" isn't defined anywhere.

and what you think is this?

maxrange = 20

I think he is talking about this post.

Example incomplete
function sojn() 
    local x,y,z=getElementPosition(sam) 
    local X,Y=getScreenFromWorldPosition(x,y,z) 
    local px,py,pz=getElementPosition(getLocalPlayer()) 
    local dystans=getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
    if dystans < distance then 
    dxDrawText(getPlayerName(sam) .. " ( " .. getPlayerName(sam) .. " )",X,Y) 
    end 

solidsnake

What's wrong with this?? :oops:

Link to comment
well i maked that but the text isnt in ped head , what i make?

Are you sure about the positions of text?

For me, it works perfectly

yea i am sure and it still not working idk why..

sx,sy = guiGetScreenSize() 
textsToDraw = {} 
maxrange = 20 
  
  
function NPCnametag() 
end 
  
addEventHandler("onClientRender",root, 
    function() 
        for a,b in pairs(textsToDraw) do 
            x,y,z = b[1],b[2],b[3] 
            scx,scy = getScreenFromWorldPosition (x,y,z) 
            camX,camY,camZ = getCameraMatrix() 
            if scx and scy and getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z+5) <= maxrange then 
            dxDrawFramedText(b[4],scx-0.5*dxGetTextWidth(b[4],0.30,"pricedown"),scy+30-0.5*dxGetFontHeight(0.30,"pricedown"),sx, sy+5,tocolor ( b[5], b[6], b[7], 255 ), 0.80,"pricedown") 
            end 
        end 
    end 
) 
  
function add3DText(x,y,z,text,r,g,b) 
    table.insert(textsToDraw,{x,y,z,text,r,g,b}) 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI , frameColor ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    dxDrawText ( message , left + 1 , top + 1 , width + 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left + 1 , top - 1 , width + 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top + 1 , width - 1 , height + 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left - 1 , top - 1 , width - 1 , height - 1 , frameColor , scale , 5 , alignX , alignY , clip , wordBreak , postGUI ) 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
end 
  
add3DText( -1624.6945800781,666.45471191406,8.1875, "Police", 6, 183, 248 ) 

Whats wrong on this?

Link to comment
What Debugscript Says ?

and did you put it client side or server ?

Debugscript says: Error: attempt to call globa 'guiGetScreenSize' ( a nil value)

and the script i just maked this to meta :

    "WoRMs" description="3D Text" version="1.0" type="script" /> 
    

Link to comment

I tested CaptainZ. code and i found few errors on it, so i fixed it and it works perfectly

sx,sy = guiGetScreenSize() 
textsToDraw = {} 
maxrange = 20 
  
addEventHandler("onClientRender",root, 
    function() 
        for a,b in pairs(textsToDraw) do 
            x,y,z = b[1],b[2],b[3] 
            scx,scy = getScreenFromWorldPosition (x,y,z) 
            camX,camY,camZ = getCameraMatrix() 
            if scx and scy and getDistanceBetweenPoints3D(camX,camY,camZ,x,y,z+5) <= maxrange then 
            dxDrawFramedText(b[4],scx-0.5*dxGetTextWidth(b[4],0.30,"pricedown"),scy+30-0.5*dxGetFontHeight(0.30,"pricedown"),sx, sy+5,tocolor ( b[5], b[6], b[7], 255 ), 0.80,"pricedown") 
            end 
        end 
    end 
) 
  
function add3DText(x,y,z,text,r,g,b) 
    table.insert(textsToDraw,{x,y,z,text,r,g,b}) 
end 
  
function dxDrawFramedText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI , frameColor ) 
    color = color or tocolor ( 255 , 255 , 255 , 255 ) 
    frameColor = frameColor or tocolor ( 0 , 0 , 0 , 255 ) 
    scale = scale or 1 
    alignX = alignX or "left" 
    alignY = alignY or "top" 
    clip = clip or false 
    wordBreak = wordBreak or false 
    postGUI = postGUI or false 
    dxDrawText ( message , left , top , width , height , color , scale , font , alignX , alignY , clip , wordBreak , postGUI ) 
end 
  
add3DText( 1177.9,-1328.4,15.3, "Test", 6, 183, 248 ) 

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