Jump to content

Hex colors


[DMC]

Recommended Posts

Posted

no example , my name is DMC

when i type in the edit and i type lolololol

it wil make my name lololololdmc

but i want just hex and nothing else

so i only can type a hex code in there :D

logo_left.png
Posted
  
function isColorCode(str) 
  if (string.find(str, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$")) return true 
  return false 
end 
function isContainingColorCode(str) 
  if (string.find(str, "#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]")) return true 
  return false 
end 
function isBeginningWithColorCode(str) 
  if (string.find(str, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]")) return true 
  return false 
end 
  

examples:

  
isColorCode("#ff00ff is cool color") -- false 
isColorCode("#ff0000") -- true 
isColorCode("i like this color: #00ff00") -- false 
  
isContainingColorCode("#ff00ff is cool color") -- true 
isContainingColorCode("#ff0000") -- true 
isContainingColorCode("i like this color: #00ff00") -- true 
  
isBeginningWithColorCode("#ff00ff is cool color") -- true 
isBeginningWithColorCode("#ff0000") -- true 
isBeginningWithColorCode("i like this color: #00ff00") -- false 
  

btw: i have written this thing, but not tested it ;)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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