Difference between revisions of "Color Codes"
m (even more colours) |
|||
Line 8: | Line 8: | ||
The image below depicts the colours the characters produce, except '''^0''' which, stands for black. Notice that some letters and digits produce the same colour.<br><br> | The image below depicts the colours the characters produce, except '''^0''' which, stands for black. Notice that some letters and digits produce the same colour.<br><br> | ||
http://velocity.lunarpages.com/images/colors.jpg | http://velocity.lunarpages.com/images/colors.jpg | ||
+ | |||
+ | ==Code Filtering== | ||
+ | Here is a little php script that can be used to parse colorcodes and return the HTML formatted and colored string: | ||
+ | <pre>// ©2003 Deus@pooHunter.de | ||
+ | // This script uses the original RGB-values that were used in RtCW:OSP which I received directly from rhea. | ||
+ | // AFAIK these RGB values did not change it ET/ETPro | ||
+ | function parse_gamecolors($string) | ||
+ | { | ||
+ | $string = ereg_replace("(\^)?$", "^", $string); | ||
+ | $string = ereg_replace("\^\^", "^^", $string); | ||
+ | $string = ereg_replace("(\^)?$", "", $string); | ||
+ | $string = ereg_replace("\^<", "^|", $string); | ||
+ | $string = ereg_replace("\<", "<", $string); | ||
+ | $string = ereg_replace("\^>", "^^", $string); | ||
+ | $string = ereg_replace("\>", ">", $string); | ||
+ | $string = ereg_replace("\^\^", "^>", $string); | ||
+ | $string = "<font color=\"#FFFFFF\">".$string."</font>"; | ||
+ | |||
+ | $color_def = array | ||
+ | ( | ||
+ | 0 => "#000000", 1 => "#FF0000", 2 => "#00FF00", 3 => "#FFFF00", | ||
+ | 4 => "#0000FF", 5 => "#00FFFF", 6 => "#FF00FF", 7 => "#FFFFFF", | ||
+ | 8 => "#FF7F00", 9 => "#7F7F7F", 10 => "#BFBFBF", 11 => "#007F00", | ||
+ | 12 => "#7FFF00", 13 => "#00007F", 14 => "#7F0000", 15 => "#7F4000", | ||
+ | 16 => "#FF9933", 17 => "#007F7F", 18 => "#7F007F", 19 => "#007F7F", | ||
+ | 20 => "#7F00FF", 21 => "#3399CC", 22 => "#CCFFCC", 23 => "#006633", | ||
+ | 24 => "#FF0033", 25 => "#B21919", 26 => "#993300", 27 => "#CC9933", | ||
+ | 28 => "#999933", 29 => "#FFFFBF", 30 => "#FFFF7F" | ||
+ | ); | ||
+ | |||
+ | $color_chardef = array | ||
+ | ( | ||
+ | "#000000" => array ( 0 => "0", 1 => "P", 2 => "p" ), | ||
+ | "#FF0000" => array ( 0 => "1", 1 => "Q", 2 => "q" ), | ||
+ | "#00FF00" => array ( 0 => "2", 1 => "R", 2 => "r" ), | ||
+ | "#FFFF00" => array ( 0 => "3", 1 => "S", 2 => "s" ), | ||
+ | "#0000FF" => array ( 0 => "4", 1 => "T", 2 => "t" ), | ||
+ | "#00FFFF" => array ( 0 => "5", 1 => "U", 2 => "u" ), | ||
+ | "#FF00FF" => array ( 0 => "6", 1 => "V", 2 => "v" ), | ||
+ | "#FFFFFF" => array ( 0 => "7", 1 => "W", 2 => "w" ), | ||
+ | "#FF7F00" => array ( 0 => "8", 1 => "X", 2 => "x" ), | ||
+ | "#7F7F7F" => array ( 0 => "9", 1 => "Y", 2 => "y" ), | ||
+ | "#BFBFBF" => array ( 0 => ":", 1 => "Z", 2 => "z", | ||
+ | 3 => ";", 4 => "[", 5 => "{" ), | ||
+ | "#007F00" => array ( 0 => "<", 1 => "\\", 2 => "|" ), | ||
+ | "#7FFF00" => array ( 0 => "=", 1 => "]", 2 => "}" ), | ||
+ | "#00007F" => array ( 0 => ">" ), | ||
+ | "#7F0000" => array ( 0 => "?" ), | ||
+ | "#7F4000" => array ( 0 => "@", 1 => "`" ), | ||
+ | "#FF9933" => array ( 0 => "A", 1 => "a", 2 => "!" ), | ||
+ | "#007F7F" => array ( 0 => "B", 1 => "b" ), | ||
+ | "#7F007F" => array ( 0 => "C", 1 => "c", 2 => "#" ), | ||
+ | "#007F7F" => array ( 0 => "D", 1 => "d", 2 => "$" ), | ||
+ | "#7F00FF" => array ( 0 => "E", 1 => "e", 2 => "%" ), | ||
+ | "#3399CC" => array ( 0 => "F", 1 => "f", 2 => "&" ), | ||
+ | "#CCFFCC" => array ( 0 => "G", 1 => "g", 2 => "'" ), | ||
+ | "#006633" => array ( 0 => "H", 1 => "h", 2 => "(" ), | ||
+ | "#FF0033" => array ( 0 => "I", 1 => "i", 2 => ")" ), | ||
+ | "#B21919" => array ( 0 => "J", 1 => "j" ), | ||
+ | "#993300" => array ( 0 => "K", 1 => "k", 2 => "+" ), | ||
+ | "#CC9933" => array ( 0 => "L", 1 => "l", 2 => "," ), | ||
+ | "#999933" => array ( 0 => "M", 1 => "m", 2 => "-" ), | ||
+ | "#FFFFBF" => array ( 0 => "N", 1 => "n", 2 => "." ), | ||
+ | "#FFFF7F" => array ( 0 => "O", 1 => "o", 2 => "/" ) | ||
+ | ); | ||
+ | |||
+ | for ($cd1 = 0; $cd1 < 31; $cd1++) | ||
+ | { | ||
+ | for ($cd2 = 0; $cd2 < count($color_chardef[$color_def[$cd1]]); $cd2++) | ||
+ | { | ||
+ | $string = str_replace("^". $color_chardef[$color_def[$cd1]][$cd2], "</FONT><FONT COLOR=\"" . $color_def[$cd1] . "\">", $string); | ||
+ | } | ||
+ | } | ||
+ | return $string; | ||
+ | } | ||
+ | </pre> |
Revision as of 10:16, 12 November 2005
What are they?
Colour codes, as the name suggests, are used to add colour to texts. They have been introduced in Quake III Arena and are available in most Q3-based games, including Enemy Territory. They can be used in most texts that get displayed ingame, such as player names, chat or notices.
Usage: a dash character (^) followed by another character. Each character produces a different colour.
Example: ^1red ^2green ^4blue
Produces: red green blue
Codes list
The image below depicts the colours the characters produce, except ^0 which, stands for black. Notice that some letters and digits produce the same colour.
http://velocity.lunarpages.com/images/colors.jpg
Code Filtering
Here is a little php script that can be used to parse colorcodes and return the HTML formatted and colored string:
// ©2003 Deus@pooHunter.de // This script uses the original RGB-values that were used in RtCW:OSP which I received directly from rhea. // AFAIK these RGB values did not change it ET/ETPro function parse_gamecolors($string) { $string = ereg_replace("(\^)?$", "^", $string); $string = ereg_replace("\^\^", "^^", $string); $string = ereg_replace("(\^)?$", "", $string); $string = ereg_replace("\^<", "^|", $string); $string = ereg_replace("\<", "<", $string); $string = ereg_replace("\^>", "^^", $string); $string = ereg_replace("\>", ">", $string); $string = ereg_replace("\^\^", "^>", $string); $string = "<font color=\"#FFFFFF\">".$string."</font>"; $color_def = array ( 0 => "#000000", 1 => "#FF0000", 2 => "#00FF00", 3 => "#FFFF00", 4 => "#0000FF", 5 => "#00FFFF", 6 => "#FF00FF", 7 => "#FFFFFF", 8 => "#FF7F00", 9 => "#7F7F7F", 10 => "#BFBFBF", 11 => "#007F00", 12 => "#7FFF00", 13 => "#00007F", 14 => "#7F0000", 15 => "#7F4000", 16 => "#FF9933", 17 => "#007F7F", 18 => "#7F007F", 19 => "#007F7F", 20 => "#7F00FF", 21 => "#3399CC", 22 => "#CCFFCC", 23 => "#006633", 24 => "#FF0033", 25 => "#B21919", 26 => "#993300", 27 => "#CC9933", 28 => "#999933", 29 => "#FFFFBF", 30 => "#FFFF7F" ); $color_chardef = array ( "#000000" => array ( 0 => "0", 1 => "P", 2 => "p" ), "#FF0000" => array ( 0 => "1", 1 => "Q", 2 => "q" ), "#00FF00" => array ( 0 => "2", 1 => "R", 2 => "r" ), "#FFFF00" => array ( 0 => "3", 1 => "S", 2 => "s" ), "#0000FF" => array ( 0 => "4", 1 => "T", 2 => "t" ), "#00FFFF" => array ( 0 => "5", 1 => "U", 2 => "u" ), "#FF00FF" => array ( 0 => "6", 1 => "V", 2 => "v" ), "#FFFFFF" => array ( 0 => "7", 1 => "W", 2 => "w" ), "#FF7F00" => array ( 0 => "8", 1 => "X", 2 => "x" ), "#7F7F7F" => array ( 0 => "9", 1 => "Y", 2 => "y" ), "#BFBFBF" => array ( 0 => ":", 1 => "Z", 2 => "z", 3 => ";", 4 => "[", 5 => "{" ), "#007F00" => array ( 0 => "<", 1 => "\\", 2 => "|" ), "#7FFF00" => array ( 0 => "=", 1 => "]", 2 => "}" ), "#00007F" => array ( 0 => ">" ), "#7F0000" => array ( 0 => "?" ), "#7F4000" => array ( 0 => "@", 1 => "`" ), "#FF9933" => array ( 0 => "A", 1 => "a", 2 => "!" ), "#007F7F" => array ( 0 => "B", 1 => "b" ), "#7F007F" => array ( 0 => "C", 1 => "c", 2 => "#" ), "#007F7F" => array ( 0 => "D", 1 => "d", 2 => "$" ), "#7F00FF" => array ( 0 => "E", 1 => "e", 2 => "%" ), "#3399CC" => array ( 0 => "F", 1 => "f", 2 => "&" ), "#CCFFCC" => array ( 0 => "G", 1 => "g", 2 => "'" ), "#006633" => array ( 0 => "H", 1 => "h", 2 => "(" ), "#FF0033" => array ( 0 => "I", 1 => "i", 2 => ")" ), "#B21919" => array ( 0 => "J", 1 => "j" ), "#993300" => array ( 0 => "K", 1 => "k", 2 => "+" ), "#CC9933" => array ( 0 => "L", 1 => "l", 2 => "," ), "#999933" => array ( 0 => "M", 1 => "m", 2 => "-" ), "#FFFFBF" => array ( 0 => "N", 1 => "n", 2 => "." ), "#FFFF7F" => array ( 0 => "O", 1 => "o", 2 => "/" ) ); for ($cd1 = 0; $cd1 < 31; $cd1++) { for ($cd2 = 0; $cd2 < count($color_chardef[$color_def[$cd1]]); $cd2++) { $string = str_replace("^". $color_chardef[$color_def[$cd1]][$cd2], "</FONT><FONT COLOR=\"" . $color_def[$cd1] . "\">", $string); } } return $string; }