Jump to content

Custom Colors for members


Recommended Posts

Hey,

I try to make a script which do, that users which nicks includes a special tag, write in another color as normal users

Is this possible?

I tried it with this script but i allways get errors:

function setPlayerChatColor(message)
thePlayer = getPlayerName(thePlayer) 
if thePlayer:find("TAG//") then
      outputChatBox(..message..,231,106,12)
end
cancelEvent() 
end
 
addEventHandler( "onPlayerChat", getRootElement(), setPlayerChatColor() )

Greetings,

Killerhamster

Link to comment

Hint: Always show what errors you get. Might help us a lot to help you. :P

... = getPlayerName(thePlayer)

I don't see "thePlayer" being defined anywhere, do you?

Use "source" instead of "thePlayer".

Also:

outputChatBox(..message..,231,106,12)

If you just want to output the message itself, then remove the "..", because this means merging 2 values into a string. (for instance combining a string with another string, or adding a number in a string)

Link to comment
I replaced now the theplayer with source but some error.

Maybe i understood something wrong?

I'm new to coding, so please don't be angry about me ;)

Greetings

Which thePlayer did you change? The first one? You should use source (this is player element since onPlayer... events give you player element in source variable) in your getPlayerName() call.

Link to comment

Hey,

This is my script:

function setPlayerChatColor(message)
local thePlayer = getPlayerName(source) 
if thePlayer:find("TAG//") then
      outputChatBox(message,231,106,12)
end
end
 
addEventHandler( "onPlayerChat", getRootElement(), setPlayerChatColor )

And now it writes the message in the outputChatBox, but my problem is, that this is not why i really want :?

I only want that members who have the Clan Tag in there name write in another color :/

Maybe you can tell me how to do this?

Link to comment

eh, i think it should be like

function setPlayerChatColor(message)
local thePlayer = getPlayerName(source)
if thePlayer:find("TAG//") then
cancelEvent()
outputChatBox(thePlayer..': '..message,getRootElement(),231,106,12)
end
end
 
addEventHandler( "onPlayerChat", getRootElement(), setPlayerChatColor )

:wink:

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