#RooTs Posted June 8, 2014 Share Posted June 8, 2014 how to create one text 3d in map show me one example in LUA ( Please ) I know it is something about dxDrawText3D more not know how it starts Image example Link to comment
Den. Posted June 8, 2014 Share Posted June 8, 2014 (edited) Here's an untested example that draws nametags above player's heads: addEventHandler("onClientRender", root, function() local players = getElementsByType("player") --Get all players currently in the server. local x, y, z = getElementPosition(localPlayer) --Get the position of the local player. for key, player in ipairs(players) do if player ~= localPlayer and isElementOnScreen(player) then --If the player is on localPlayer's screen local px, py, pz = getElementPosition(player) --Get position of player to draw nametag if isLineOfSightClear(x, y, z, px, py, pz) then --If the localPlayer can see the target player local distance = getDistanceBetweenPoints3D(x, y, z, px, py, pz) --Get the distance to determine scale if distance <= 50 then local sx, sy = getScreenFromWorldPosition(px, py, pz+1) --Get the localPlayer's screen position to draw the nametag at, from the target player's world positon. if sx then --Make sure the function didn't return false local scale = math.min(15 / distance, 1.4) --Determine text scale dxDrawText(tostring(getPlayerName(player)), sx, sy, sx, sy, tocolor(0, 0, 0), scale) --Draw the text end end end end end end) Another untested example which draws text at fixed locations given by a table: addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) --localPlayer's pos for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) --get the string to draw and the position to draw it at from the table. local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) --Distance between player and text position if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) --Get the local player's screen position to draw the text at, from the text's world position. if sx then --Make sure the function didn't return false. local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) It should be obvious now that you need to use getScreenFromWorldPosition to draw texts at positions relative to the world. Edited June 9, 2014 by Guest Link to comment
#RooTs Posted June 9, 2014 Author Share Posted June 9, 2014 Another untested example which draws text at fixed locations given by a table: addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) if sx then local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) where do I change the text? ,, "my text here" and how can this script with a text which line? Link to comment
Den. Posted June 9, 2014 Share Posted June 9, 2014 Just have a table called texts in the above example at the beginning of the script: local texts = {{"My text here", x, y, z}, {"My second text", x, y, z}} --x, y, z denotes the world position of the text I don't understand your second question, please be clear. Link to comment
#RooTs Posted June 9, 2014 Author Share Posted June 9, 2014 is right? addEventHandler("onClientRender", root, function() local texts = { {"My text here", x, y, z}, {"My second text", x, y, z} } local x, y, z = getElementPosition(localPlayer) for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) if sx then local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) Link to comment
Price. Posted June 9, 2014 Share Posted June 9, 2014 yes without function please? you don't create a table with function or eventhandler. Link to comment
Den. Posted June 9, 2014 Share Posted June 9, 2014 Simply like this: local texts = {{"My text here", x, y, z}, {"My second text", x, y, z}} --x, y, z denotes the world position of the text addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) if sx then local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) Link to comment
#RooTs Posted June 19, 2014 Author Share Posted June 19, 2014 Hi, someone add border in my code, and color text,, Please.... local texts = { {"My text here", 2484.67993, -1666.70923, 13.34375}, {"My second text", 2443.40234, -1662.02771, 13.30280} } addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) for key, text in ipairs(texts) do local str, tx, ty, tz = unpack(text) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if distance <= 50 then local sx, sy = getScreenFromWorldPosition(tx, ty, tz) if sx then local scale = math.min(15/distance, 1.4) dxDrawText(str, sx, sy, sx, sy, nil, scale) end end end end) Imagen example: Link to comment
xXMADEXx Posted June 19, 2014 Share Posted June 19, 2014 How about you try adding it yourself? This is the function that I use function dxDrawBoarderedText ( text, x, y, endX, endY, color, size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) local text = tostring ( text ) local x = tonumber(x) or 0 local y = tonumber(y) or 0 local endX = tonumber(endX) or x local endY = tonumber(endY) or y local color = color or tocolor ( 255, 255, 255, 255 ) local size = tonumber(size) or 1 local font = font or "default" local alignX = alignX or "left" local alignY = alignY or "top" local clip = clip or false local wordBreak = wordBreak or false local postGUI = postGUI or false local colorCode = colorCode or false local subPixelPos = subPixelPos or false local fRot = tonumber(fRot) or 0 local fRotCX = tonumber(fRotCX) or 0 local fRotCY = tonumber(fRotCy) or 0 local offSet = tonumber(offSet) or 1 local t_g = text:gsub ( "#%x%x%x%x%x%x", "" ) dxDrawText ( t_g, x-offSet, y-offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x-offSet, y, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x, y-offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x+offSet, y+offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x+offSet, y, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x, y+offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) return dxDrawText ( text, x, y, endX, endY, color, size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) end Link to comment
#RooTs Posted June 19, 2014 Author Share Posted June 19, 2014 How about you try adding it yourself?This is the function that I use function dxDrawBoarderedText ( text, x, y, endX, endY, color, size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) local text = tostring ( text ) local x = tonumber(x) or 0 local y = tonumber(y) or 0 local endX = tonumber(endX) or x local endY = tonumber(endY) or y local color = color or tocolor ( 255, 255, 255, 255 ) local size = tonumber(size) or 1 local font = font or "default" local alignX = alignX or "left" local alignY = alignY or "top" local clip = clip or false local wordBreak = wordBreak or false local postGUI = postGUI or false local colorCode = colorCode or false local subPixelPos = subPixelPos or false local fRot = tonumber(fRot) or 0 local fRotCX = tonumber(fRotCX) or 0 local fRotCY = tonumber(fRotCy) or 0 local offSet = tonumber(offSet) or 1 local t_g = text:gsub ( "#%x%x%x%x%x%x", "" ) dxDrawText ( t_g, x-offSet, y-offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x-offSet, y, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x, y-offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x+offSet, y+offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x+offSet, y, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) dxDrawText ( t_g, x, y+offSet, endX, endY, tocolor(0,0,0,255), size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) return dxDrawText ( text, x, y, endX, endY, color, size, font, alignX, alignY, clip, wordBreak, postGUI, colorCode, subPixelPos, fRot, fRotCX, fRotCY, offSet ) end need of all that only add border and color ? 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