'LinKin Posted March 30, 2014 Posted March 30, 2014 Hello, I want to check if the thing that a player writes is a hex color. This is the code I have addCommandHandler("color", function(p,c,color) if string.match(color ,"%x%x%x%x%x%x") then outputChatBox("You've written a colorcode", p) end end) But, for example if I type /color 00FF00Hola. It will be true, thus it will say I typed a colorcode.. How can I make it so that it ONLY works if what I type is 00FF00 - Not 00FF00Hola or mthElse00FF00. I tried if color == "%x%x%x%x%x%x" But it didnt work.
.:HyPeX:. Posted March 30, 2014 Posted March 30, 2014 outputChatBox("#0046C8[bF3]: Player "..string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").. "#0046C8 Logged in", getRootElement(), TextColour.R, TextColour.G, TextColour.B,true) You must make a pattern to look after in order to use %x: "#%x%x%x%x%x%x" will catch the 6 inmediate characters after #.
'LinKin Posted March 31, 2014 Author Posted March 31, 2014 Yes but if I write #FF0000F (One extra F at the end) it will still be true, thus it'd fail.
WhoAmI Posted March 31, 2014 Posted March 31, 2014 onPlayerChat - there is message in 1st argument if message == "#%x%x%x%x%x%x" then
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