Jump to content

getPlayerNameTagColor..


Annas

Recommended Posts

Hi , i have made a script , but i failed :/

This script is about:

1- player did /superadvert TEXT and it will be shows a text to all players

function advertising ( thePlayer, ...  ) 
    local message = table.concat( {...}, " " ) 
    local r, g, b = getPlayerNametagColor(thePlayer) 
    if message == "" then 
        outputChatBox("You didnt enter a message!", thePlayer, 200, 0, 0) 
    return  
    end 
    if isPlayerMuted(thePlayer) then 
        outputChatBox("You are muted!", thePlayer, 255, 0, 0) 
    return 
    end 
    outputChatBox("#FF6464(ADVERT) ".. getPlayerName(thePlayer).."#FFFFFF: "..message, root, r, g, b, true) 
end 
addCommandHandler ( "superadvert", advertising ) 

I wanna it get the player name tag color ONLY for the player name!

Only this be with the currently name tag color of the player

outputChatBox("#FF6464(ADVERT) ".. getPlayerName(thePlayer).." #FFFFFF: "..message, root, r, g, b, true)

So when the player will did the command

/superadvert Message for test

& his name tag color is (R: 0 - G: 0 - B: 0)

and his name TEST

so the output will be like this

(ADVERT) Test : Message for test

Wish you understand me
Link to comment

You've got to use

hex = string.format("#%X%X%X", r, g, b) 

to convert RGB to Hex color (with preceding hash sign), which you then append as prefix to the player name, and change it to another hex on the suffix of the name or on the succeeding word.

Example:

local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%X%X%X", r, g, b) 
local text = "#FF6464(ADVERT) "..hex .. getPlayerName(thePlayer).." #FFFFFF: "..message 

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