Killerhamster10 Posted April 6, 2010 Posted April 6, 2010 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
Gamesnert Posted April 6, 2010 Posted April 6, 2010 Hint: Always show what errors you get. Might help us a lot to help you. ... = 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)
Killerhamster10 Posted April 6, 2010 Author Posted April 6, 2010 Okay i added: local thePlayer = getPlayerName(thePlayer) But now it says: atempt to to index local 'theplayer' I really don't know what to do >.< Greetings
Killerhamster10 Posted April 6, 2010 Author Posted April 6, 2010 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
50p Posted April 6, 2010 Posted April 6, 2010 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.
Killerhamster10 Posted April 7, 2010 Author Posted April 7, 2010 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?
DakiLLa Posted April 7, 2010 Posted April 7, 2010 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 )
DakiLLa Posted April 7, 2010 Posted April 7, 2010 Well, little typo, he wants that the name of player will be another color: outputChatBox('#E76A0C'..thePlayer..': #FAFAFA'..message,getRootElement(),0,0,0,true)
Killerhamster10 Posted April 9, 2010 Author Posted April 9, 2010 Okay it is working, thx! But now we have another problem: We want to use teamchat for admins only, so that only admins can read it. With the script i'm now using the teamchat doesn't work Is there a way to make it work again? Greetingsd
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now