Jump to content

Namecolor Player !


//_Dragon

Recommended Posts

function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
outputChatBox("(Local) "..hex..name..": #ffffff"..message, getRootElement(), 255, 255, 0, true) -- this is actually sent to everyone, so it's not actually local chat - I will leave it to you to adapt it to your needs. 
end 
addCommandHandler("Local", localMessage) 

Link to comment
  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  
local Pr, Pg, Pb = 255, 255, 255 
function globalMessage(thePlayer, cmd, ...) 
local message = table.concat ( { ... }, " " ) 
local name = getPlayerName(thePlayer) 
local r,g,b = getPlayerNametagColor ( thePlayer ) -- add 
if r and g and b then 
outputChatBox(RGBToHex(r,g,b) .." [Local] ".. RGBToHex(Pr,Pg,Pb) ..""..name..": #ffffff"..message, getRootElement(), r, g, b, true) 
end 
end 
addCommandHandler("Local", globalMessage) 

Link to comment
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  
local Pr, Pg, Pb = 255, 255, 255 
function globalMessage(thePlayer, cmd, ...) 
local message = table.concat ( { ... }, " " ) 
local name = getPlayerName(thePlayer) 
local r,g,b = getPlayerNametagColor ( thePlayer ) -- add 
if r and g and b then 
outputChatBox(RGBToHex(r,g,b) .." [Local] ".. RGBToHex(Pr,Pg,Pb) ..""..name..": "..message, getRootElement(), r, g, b, true) 
end 
end 
addCommandHandler("Local", globalMessage) 

Link to comment
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  
local Pr, Pg, Pb = 255, 255, 255 
function globalMessage(thePlayer, cmd, ...) 
local message = table.concat ( { ... }, " " ) 
local name = getPlayerName(thePlayer) 
local r,g,b = getPlayerNametagColor ( thePlayer ) -- add 
if r and g and b then 
outputChatBox(RGBToHex(r,g,b) .." [Local] ".. RGBToHex(Pr,Pg,Pb) ..""..name..": "..message, getRootElement(), r, g, b, true) 
end 
end 
addCommandHandler("Local", globalMessage) 

You didn't saw my problem !!

The problem is :arrowdown::arrowdown:

But i have a little problem this local chat i made it in place chatbox i mean bindkey T but when i do some command's mta doesnt work like /reconnect when i do it it be righting in chatbox (local) :/ how i can fixe this problem ? :roll:

Check this pic :arrow:http://imgur.com/3V4CqvK

Link to comment

When i do some command's mta in localchat , doesnt work :/

Like /reconnect or /nick

Anyone help ?

Here is my script :arrowdown:

function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
outputChatBox("(Local) "..hex..name..": #ffffff"..message, getRootElement(), 255, 255, 0, true) 
end 
addCommandHandler("Local", localMessage) 

Link to comment
  • 3 weeks later...
if message:sub(1,1) == "/" then -- if message proceeds a forward slash (i.e. message is a command) 
  local command = message:sub(2) 
  local command = split(command, " ") 
  local cmd = table.remove(command, 1) -- returns and removes the value on key 1 
  executeCommandHandler(cmd, thePlayer, unpack(command)) -- this won't work for commands like /login, /logout, /quit, /reconnect, /name etc 
  return 0; --stop function here 
end 

executeCommandHandler

[…]

NOTE: You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons.

executeCommandHandler

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