Jump to content

help edit


Flipi

Recommended Posts

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) 

Link to comment

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) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...