Jump to content

Change nametag color on injure


Recommended Posts

Hi everybody! So I have a nametag resource, and I modificatied it. When somebody punches, or hits somebody with weapon, the attacker's nametag color turns to purple for 5 seconds. But I don't know how to change the injured person's nametag color on hit. Because I want to make this script work like when you hit somebody your nametag color turns to purple, and the injured person's nametag color turns to red. How can I make this? Here's a bit of the script when it changes to purple:

g_Attacker = getLocalPlayer(attacker) 
  
addEventHandler("onClientPlayerDamage", g_Attacker, 
function (red, green, blue, alpha, attacker) 
     
    color = tocolor(107, 6, 82, 255) 
     
    setTimer ( function() 
        color = tocolor(212, 201, 174, 255) 
    end, 5000, 1 ) 
end 
) 
  
  
  
-- and the dxDrawColorText which is draws the names 
  
 dxDrawColorText (  getPlayerName(player):gsub("_", " ") .. " (".. id .. ") ", sx-w, sy - offset, sx, sy - offset, color, textscale*NAMETAG_TEXTSIZE, srfont, "center", "bottom", false, false, false ) 

Thank you for the help!

Link to comment

I'm not sure, but it looks like this

local color = tonumber ( 212, 201, 174, 255 ) 
  
addEventHandler ( "onClientPlayerDamage", root, 
    function ( )        
        color = tocolor ( 255, 0, 0, 255 )        
        setTimer ( function() 
            color = tocolor ( 212, 201, 174, 255 ) 
        end, 5000, 1 )       
    end 
) 
  
addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( )     
        color = tocolor ( 107, 6, 82, 255 ) 
        setTimer ( function() 
            color = tocolor ( 212, 201, 174, 255 ) 
        end, 5000, 1 )       
    end 
)    
  
  
addEventHandler ( "onClientRender", root,     
    function ( ) 
        dxDrawColorText (  getPlayerName(player):gsub("_", " ") .. " (".. id .. ") ", sx-w, sy - offset, sx, sy - offset, color, textscale*NAMETAG_TEXTSIZE, srfont, "center", "bottom", false, false, false ) 
    end 
) 

Link to comment
I'm not sure, but it looks like this
local color = tonumber ( 212, 201, 174, 255 ) 
  
addEventHandler ( "onClientPlayerDamage", root, 
    function ( )        
        color = tocolor ( 255, 0, 0, 255 )        
        setTimer ( function() 
            color = tocolor ( 212, 201, 174, 255 ) 
        end, 5000, 1 )       
    end 
) 
  
addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( )     
        color = tocolor ( 107, 6, 82, 255 ) 
        setTimer ( function() 
            color = tocolor ( 212, 201, 174, 255 ) 
        end, 5000, 1 )       
    end 
)    
  
  
addEventHandler ( "onClientRender", root,     
    function ( ) 
        dxDrawColorText (  getPlayerName(player):gsub("_", " ") .. " (".. id .. ") ", sx-w, sy - offset, sx, sy - offset, color, textscale*NAMETAG_TEXTSIZE, srfont, "center", "bottom", false, false, false ) 
    end 
) 

Not excatly what I'm thinking about :/ I mean, if somebody gets injured, his nametag color turns to red, but if somebody shoots someone else, the attacker's nametag is purple, but the injured's nametag is red.

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