Flipi Posted August 30, 2013 Posted August 30, 2013 hi, how to add or enable color codes in the names? hehe? IMG: http://img19.imageshack.us/img19/2115/0yld.png local textFont = "default-bold" local textScale = 1 local heightPadding = 1 local widthPadding = 1 local xOffset = 8 local minAlpha = 10 local textAlpha = 255 local rectangleColor = tocolor(0,0,0,230) local floor = math.floor local w,h = guiGetScreenSize() local function drawMapStuff() if isPlayerMapVisible() then local sx,sy,ex,ey = getPlayerMapBoundingBox() local mw,mh = ex-sx,sy-ey local cx,cy = (sx+ex)/2,(sy+ey)/2 local ppuX,ppuY = mw/6000,mh/6000 local fontHeight = dxGetFontHeight(textScale,textFont) local yOffset = fontHeight/2 local blips = getElementsByType("blip") for k,v in ipairs(blips) do local attached=getElementAttachedTo(v) if isElement(attached) and getElementType(attached)=="player" then local px,py = getElementPosition(attached) local x = floor(cx+px*ppuX+xOffset) local y = floor(cy+py*ppuY-yOffset) local pname = getPlayerName(attached) local nameLength = dxGetTextWidth(pname,textScale,textFont) local r,g,b = getPlayerNametagColor(attached) local _,_,_,a = getBlipColor(v) if a>minAlpha then dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*2,rectangleColor,false) dxDrawText(pname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false) end end end end end addEventHandler("onClientRender",getRootElement(),drawMapStuff)
Castillo Posted August 30, 2013 Posted August 30, 2013 Simple, just enable the "colorCoded" argument of dxDrawText, here: local textFont = "default-bold" local textScale = 1 local heightPadding = 1 local widthPadding = 1 local xOffset = 8 local minAlpha = 10 local textAlpha = 255 local rectangleColor = tocolor(0,0,0,230) local floor = math.floor local w,h = guiGetScreenSize() local function drawMapStuff() if isPlayerMapVisible() then local sx,sy,ex,ey = getPlayerMapBoundingBox() local mw,mh = ex-sx,sy-ey local cx,cy = (sx+ex)/2,(sy+ey)/2 local ppuX,ppuY = mw/6000,mh/6000 local fontHeight = dxGetFontHeight(textScale,textFont) local yOffset = fontHeight/2 local blips = getElementsByType("blip") for k,v in ipairs(blips) do local attached=getElementAttachedTo(v) if isElement(attached) and getElementType(attached)=="player" then local px,py = getElementPosition(attached) local x = floor(cx+px*ppuX+xOffset) local y = floor(cy+py*ppuY-yOffset) local pname = getPlayerName(attached) local nameLength = dxGetTextWidth(pname,textScale,textFont) local r,g,b = getPlayerNametagColor(attached) local _,_,_,a = getBlipColor(v) if a>minAlpha then dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*2,rectangleColor,false) dxDrawText(pname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) end end end end end addEventHandler("onClientRender",getRootElement(),drawMapStuff) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Flipi Posted August 30, 2013 Author Posted August 30, 2013 thanks!, but there is another problem IMG: http://img42.imageshack.us/img42/4075/jtt1.png help me fix it?
Sasu Posted August 30, 2013 Posted August 30, 2013 Line 34: local nameLength = dxGetTextWidth(pname,textScale,textFont) -> local nameLength = dxGetTextWidth(pname:gsub("#%x%x%x%x%x%x", "") ,textScale,textFont) State: Inactive
Flipi Posted August 30, 2013 Author Posted August 30, 2013 Line 34: local nameLength = dxGetTextWidth(pname,textScale,textFont) -> local nameLength = dxGetTextWidth(pname:gsub("#%x%x%x%x%x%x", "") ,textScale,textFont) wow thanks !!
Castillo Posted August 30, 2013 Posted August 30, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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