ATS#Nexus Posted August 3, 2012 Posted August 3, 2012 1. I need to make colored names for other players. 2. I need to make colored name for ghost racer. Using this resource - https://community.multitheftauto.com/index.php?p= ... ls&id=3799
Castillo Posted August 3, 2012 Posted August 3, 2012 You can either wait for the release of MTA 1.3.1 for the "colorCoded" argument at dxDrawText or use this function: https://wiki.multitheftauto.com/wiki/DxDrawColorText Then you would need to edit the nametags of both race and ghostracer script. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 You can either wait for the release of MTA 1.3.1 for the "colorCoded" argument at dxDrawText or use this function:https://wiki.multitheftauto.com/wiki/DxDrawColorText Then you would need to edit the nametags of both race and ghostracer script. but idk how to do this can u tell me like to a noob?
Castillo Posted August 3, 2012 Posted August 3, 2012 You better start learning then, I won't do it for you. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MIKI785 Posted August 3, 2012 Posted August 3, 2012 Just paste that function https://wiki.multitheftauto.com/wiki/DxDrawColorText at the end of the client script in the resource you're using and replace any "dxDrawText" with dxDrawColorText. Lua Scripter Owner of mshost.cz MTA portal.
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 Just paste that function https://wiki.multitheftauto.com/wiki/DxDrawColorText at the end of the client script in the resource you're using and replace any "dxDrawText" with dxDrawColorText. i have repleaced and now driver have'nt name
MIKI785 Posted August 3, 2012 Posted August 3, 2012 Show the code... it should work. Use [lua] tag. Lua Scripter Owner of mshost.cz MTA portal.
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 Show the code... it should work. Use [lua] tag. --Draw our text local r,g,b = 150,150,150 local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 dxDrawText ( info.name, sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) --We draw three parts to make the healthbar. First the outline/background local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset --[[local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health = getElementHealth(vehicle) health = math.max(health - 250, 0)/750 local p = -510*(health^2) local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) )--]] dxDrawText ( info.time, sx, drawY, sx, drawY, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE*0.8, "default", "center", "top", false, false, false ) end
arezu Posted August 3, 2012 Posted August 3, 2012 dxDrawText with colorCode support is already added, use it instead because it works much faster.
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 dxDrawText with colorCode support is already added, use it instead because it works much faster. If dxDrawText with colorCode support is already added then why i see color code instead of colored name?
MIKI785 Posted August 3, 2012 Posted August 3, 2012 Try: Put this outside the onClientRender event: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" if alignX then if alignX == "center" then ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 elseif alignX == "right" then ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) end end if alignY then if alignY == "center" then ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 elseif alignY == "bottom" then ay = by - dxGetFontHeight(scale, font) end end local alpha = string.format("%08X", color):sub(1,2) 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(getColorFromString("#"..col..alpha)) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(getColorFromString("#"..col..alpha)) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) dxDrawText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) end end And put this into that event --Draw our text local r,g,b = 150,150,150 local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 dxDrawColorText ( info.name, sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) --We draw three parts to make the healthbar. First the outline/background local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset --[[local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health = getElementHealth(vehicle) health = math.max(health - 250, 0)/750 local p = -510*(health^2) local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) )--]] dxDrawText ( info.time, sx, drawY, sx, drawY, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE*0.8, "default", "center", "top", false, false, false ) end Lua Scripter Owner of mshost.cz MTA portal.
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 Try:Put this outside the onClientRender event: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" if alignX then if alignX == "center" then ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 elseif alignX == "right" then ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) end end if alignY then if alignY == "center" then ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 elseif alignY == "bottom" then ay = by - dxGetFontHeight(scale, font) end end local alpha = string.format("%08X", color):sub(1,2) 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(getColorFromString("#"..col..alpha)) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(getColorFromString("#"..col..alpha)) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) dxDrawText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) end end And put this into that event --Draw our text local r,g,b = 150,150,150 local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 dxDrawColorText ( info.name, sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) --We draw three parts to make the healthbar. First the outline/background local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset --[[local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health = getElementHealth(vehicle) health = math.max(health - 250, 0)/750 local p = -510*(health^2) local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) )--]] dxDrawText ( info.time, sx, drawY, sx, drawY, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE*0.8, "default", "center", "top", false, false, false ) end For ghost is done but how to make for other players whyle spectating? .
TwiX! Posted August 3, 2012 Posted August 3, 2012 For ghost is done but how to make for other players whyle spectating? You better start learning then, I won't do it for you. - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
ATS#Nexus Posted August 3, 2012 Author Posted August 3, 2012 For ghost is done but how to make for other players whyle spectating? You better start learning then, I won't do it for you. Its easy to say "start learning" but its hard
Cadu12 Posted August 3, 2012 Posted August 3, 2012 It is not hard to make colored, I already made it. Just edit ghost a bit. I wont do request it for you. Ingame nick: Cadu12
MIKI785 Posted August 3, 2012 Posted August 3, 2012 For ghost is done but how to make for other players whyle spectating? What? You can do the same in the nametags.lua in the race if that's what you want. Lua Scripter Owner of mshost.cz MTA portal.
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