Gongas Posted March 28, 2013 Posted March 28, 2013 How i can put names in PED head? for example "Mechanic", can someone tell me how i can do it?
Castillo Posted March 28, 2013 Posted March 28, 2013 Use dx drawing functions. https://wiki.multitheftauto.com/wiki/Cl ... _functions
CaptainZ. Posted March 28, 2013 Posted March 28, 2013 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 )
Gongas Posted March 28, 2013 Author Posted March 28, 2013 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
Gongas Posted March 28, 2013 Author Posted March 28, 2013 Just use my code and change position... "add3DText( 1177.9,-1328.4,15.3, "Test", 6, 183, 248 )" of this?
CaptainZ. Posted March 28, 2013 Posted March 28, 2013 Yes, copypaste it if you want more texts (put them below)
Gongas Posted March 28, 2013 Author Posted March 28, 2013 well i maked that but the text isnt in ped head , what i make?
Castillo Posted March 29, 2013 Posted March 29, 2013 Is that some sort of joke? how would he attach a dx text to an element with that function?
][sojn][ Posted March 29, 2013 Posted March 29, 2013 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??
CaptainZ. Posted March 29, 2013 Posted March 29, 2013 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
K4stic Posted March 29, 2013 Posted March 29, 2013 "distance" isn't defined anywhere. and what you think is this? maxrange = 20
Perfect Posted March 29, 2013 Posted March 29, 2013 "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??
Gongas Posted March 29, 2013 Author Posted March 29, 2013 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?
Perfect Posted March 29, 2013 Posted March 29, 2013 What Debugscript Says ? and did you put it client side or server ?
Gongas Posted March 29, 2013 Author Posted March 29, 2013 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" />
iPrestege Posted March 29, 2013 Posted March 29, 2013 Try this : "WoRMs" description="3D Text" version="1.0" type="script" />
Gongas Posted March 29, 2013 Author Posted March 29, 2013 Try this : "WoRMs" description="3D Text" version="1.0" type="script" /> Worked thx since i am new on scripting i want learn to be good 1 day
manve1 Posted March 29, 2013 Posted March 29, 2013 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 )
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