Cadu12 Posted April 1, 2011 Share Posted April 1, 2011 How to make dxDrawText with color, and center? I know, thats hard... Link to comment
Castillo Posted April 1, 2011 Share Posted April 1, 2011 Someone else was asking for the same, and he got many answers, check this topic: viewtopic.php?f=91&t=30227&p=329942&hilit=dxDrawcolorText#p329942 Link to comment
Cadu12 Posted April 1, 2011 Author Share Posted April 1, 2011 But center doesnt works ;/ Link to comment
Castillo Posted April 1, 2011 Share Posted April 1, 2011 Well, you gotta make that part, do you think you can request stuff and get it done? Link to comment
Cadu12 Posted April 1, 2011 Author Share Posted April 1, 2011 Yes, im sure edit: If you have msn, please send me a PM? Link to comment
Castillo Posted April 1, 2011 Share Posted April 1, 2011 Do you mean, you are saying you can request stuff and get it done? lol? Link to comment
Cadu12 Posted April 1, 2011 Author Share Posted April 1, 2011 I can do it, but i dont knows how do it center We can make X and Y? edit: there is code: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "center", "bottom", false, false, false ) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "center", "bottom", false, false, false ) end end Link to comment
Buffalo Posted April 2, 2011 Share Posted April 2, 2011 It's very simple to get it centered: local sx,sy = guiGetScreenSize() --get player's current resolution dxDrawText('Text',sx/2-70,sy/2-20,sx/2+70,sy/2+20,tocolor(255,170,0,255),1.0,'bankgothic','center','center') -- draw text in the center according to resolution Link to comment
Castillo Posted April 2, 2011 Share Posted April 2, 2011 He gave you the code, use it. Link to comment
Cadu12 Posted April 2, 2011 Author Share Posted April 2, 2011 Doesnt works, but it is bugged on nametag... http://img16.imageshack.us/i/bugged2.png/ Link to comment
Castillo Posted April 2, 2011 Share Posted April 2, 2011 You wanted this for player nametag? Link to comment
Castillo Posted April 3, 2011 Share Posted April 3, 2011 Then, you should have told us that before. function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "center", "bottom", false, false, false ) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "center", "bottom", false, false, false ) end end function drawPlayerTags() for i,v in ipairs(getElementsByType("player")) do if not v == getLocalPlayer() then local name = getPlayerName(v) local x,y,z = getElementPosition(v) local cx,cy,cz = getCameraMatrix() if isLineOfSightClear(cx,cy,cz,x,y,z,true,true,false,true,false,true,false,v) then if getDistanceBetweenPoints3D(cx,cy,cz,x,y,z) <= 45 then local px,py = getScreenFromWorldPosition(x,y,z+0.3,0.06) if px then r,g,b = getPlayerNametagColor(v) dxDrawColorText(name, px-60, py, px, py, tocolor(r, g, b, 255), 2, "default") end end end end end end addEventHandler("onClientRender",getRootElement(),drawPlayerTags) There, it works fine here, should work "there" too. And please, don't think we're your "slaves" our something like that Link to comment
Cadu12 Posted April 3, 2011 Author Share Posted April 3, 2011 nametag.lua in race resource? I did, doesnt show name it no errors . . . Link to comment
Castillo Posted April 4, 2011 Share Posted April 4, 2011 I have no idea where you want to use it, but this it is working. I have tested it myself. http://img824.imageshack.us/i/mtascreen ... 22724.png/ Link to comment
Cadu12 Posted April 4, 2011 Author Share Posted April 4, 2011 I saw your image, you can make 100% center like EPG and SHC I know its harder there is image: http://img848.imageshack.us/g/mtascreen ... 14202.jpg/ Link to comment
Castillo Posted April 4, 2011 Share Posted April 4, 2011 I can, but that doesn't means i will 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