Jump to content

Player color


Samy_Romafia

Recommended Posts

yes there is :D

  
local x, y = guiGetScreenSize() 
  
function PlayerNameTags() 
    local players = getElementsByType("player") 
        for k,v in ipairs(players) do 
            if v == getLocalPlayer() then else 
                local r = getElementData(v,"red") 
                local g = getElementData(v,"green") 
                local b = getElementData(v,"blue") 
                local x1,y1,z1 = getElementPosition (getLocalPlayer()) 
                local x2,y2,z2 = getElementPosition (v) 
                local visibleto = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) 
                    if visibleto > 75 then else 
                        local sx,sy = getScreenFromWorldPosition ( x2,y2,z2+1.05 ) 
                            if not sx and not sy then else 
dxDrawText ( string.gsub ( getPlayerName ( v ), "#%x%x%x%x%x%x", "" ).."", sx,sy,sx,sy, tocolor(r,g,b,255), 1.8-visibleto/50, "default-bold", "center","top",false,false,false ) 
                                if y/102-visibleto/5 < 0 then else 
dxDrawRectangle (   sx-x/13/2+visibleto/2, sy+y/27.2-visibleto/3, x/13-visibleto,y/102-visibleto/10, tocolor(0,0,0,255) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/25-visibleto/3, x/14-visibleto,y/146.3-visibleto/10, tocolor(100,0,0,245) ) 
                                    if getElementHealth(v) < 1 then else 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/25-visibleto/3, x/14*getElementHealth(v)/100-visibleto,y/146.3-visibleto/10, tocolor(190,0,0,245) ) 
                                    end 
                                        local armor = getPedArmor(v) 
                                            if armor and armor > 0 then 
dxDrawRectangle (   sx-x/13/2+visibleto/2, sy+y/40.2-visibleto/3, x/13-visibleto,y/102-visibleto/10, tocolor(0,0,0,255) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/38-visibleto/3, x/14-visibleto,y/146.3-visibleto/10, tocolor(100,100,100,245) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/38-visibleto/3, x/14*armor/100-visibleto,y/146.3-visibleto/10, tocolor(190,190,190,245) ) 
                                            end 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),PlayerNameTags) 

Link to comment
yes there is :D
  
local x, y = guiGetScreenSize() 
  
function PlayerNameTags() 
    local players = getElementsByType("player") 
        for k,v in ipairs(players) do 
            if v == getLocalPlayer() then else 
                local r = getElementData(v,"red") 
                local g = getElementData(v,"green") 
                local b = getElementData(v,"blue") 
                local x1,y1,z1 = getElementPosition (getLocalPlayer()) 
                local x2,y2,z2 = getElementPosition (v) 
                local visibleto = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) 
                    if visibleto > 75 then else 
                        local sx,sy = getScreenFromWorldPosition ( x2,y2,z2+1.05 ) 
                            if not sx and not sy then else 
dxDrawText ( string.gsub ( getPlayerName ( v ), "#%x%x%x%x%x%x", "" ).."", sx,sy,sx,sy, tocolor(r,g,b,255), 1.8-visibleto/50, "default-bold", "center","top",false,false,false ) 
                                if y/102-visibleto/5 < 0 then else 
dxDrawRectangle (   sx-x/13/2+visibleto/2, sy+y/27.2-visibleto/3, x/13-visibleto,y/102-visibleto/10, tocolor(0,0,0,255) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/25-visibleto/3, x/14-visibleto,y/146.3-visibleto/10, tocolor(100,0,0,245) ) 
                                    if getElementHealth(v) < 1 then else 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/25-visibleto/3, x/14*getElementHealth(v)/100-visibleto,y/146.3-visibleto/10, tocolor(190,0,0,245) ) 
                                    end 
                                        local armor = getPedArmor(v) 
                                            if armor and armor > 0 then 
dxDrawRectangle (   sx-x/13/2+visibleto/2, sy+y/40.2-visibleto/3, x/13-visibleto,y/102-visibleto/10, tocolor(0,0,0,255) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/38-visibleto/3, x/14-visibleto,y/146.3-visibleto/10, tocolor(100,100,100,245) ) 
dxDrawRectangle (   sx-x/14/2+visibleto/2, sy+y/38-visibleto/3, x/14*armor/100-visibleto,y/146.3-visibleto/10, tocolor(190,190,190,245) ) 
                                            end 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),PlayerNameTags) 

I think he means nametags that shows hexadecimal colors.

...

here i uploaded my custom dxDrawText function that supports hexadecimal colors:

https://community.multitheftauto.com/index.php?p= ... ls&id=3421

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...