AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] More Colors (1.9.1) (https://forums.alliedmods.net/showthread.php?t=185016)

Dr. McKay 05-11-2012 23:22

[INC] More Colors (1.9.1)
 
(More) Colors
More functions for easy chat color management
http://i.imgur.com/v0BWE.png
About:
Adds a whole bunch of colors (thanks asherkin!) for plugins to use in chat. Fully (I think) backwards-compatible with the original colors.inc. You can use multiple team colors in the same message!

Only works in Source 2009 games, which include:
  • Team Fortress 2
  • Counter-Strike: Source
  • Half-Life 2: Deathmatch
  • Day of Defeat: Source

Important! In order for your plugins to load properly on older versions of SourceMod, you need to include this in your plugin:

PHP Code:

public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max) {
    
MarkNativeAsOptional("GetUserMessageType");
    return 
APLRes_Success;


Functions:
PHP Code:

/**
 * Prints a message to a specific client in the chat area.
 * Supports color tags.
 * 
 * @param client        Client index.
 * @param message        Message (formatting rules).
 * @noreturn
 * 
 * On error/Errors:        If the client is not connected an error will be thrown.
 */
stock CPrintToChat(client, const String:message[], any:...)


/**
 * Prints a message to all clients in the chat area.
 * Supports color tags.
 * 
 * @param client        Client index.
 * @param message        Message (formatting rules).
 * @noreturn
 */
stock CPrintToChatAll(const String:message[], any:...)


/**
 * Prints a message to a specific client in the chat area.
 * Supports color tags and teamcolor tag.
 * 
 * @param client        Client index.
 * @param author        Author index whose color will be used for teamcolor tag.
 * @param message        Message (formatting rules).
 * @noreturn
 * 
 * On error/Errors:        If the client or author are not connected an error will be thrown
 */
stock CPrintToChatEx(clientauthor, const String:message[], any:...)


/**
 * Prints a message to all clients in the chat area.
 * Supports color tags and teamcolor tag.
 *
 * @param author      Author index whos color will be used for teamcolor tag.
 * @param message   Message (formatting rules).
 * @noreturn
 * 
 * On error/Errors:   If the author is not connected an error will be thrown.
 */
stock CPrintToChatAllEx(author, const String:message[], any:...)


/**
 * This function should only be used right in front of
 * CPrintToChatAll or CPrintToChatAllEx. It causes those functions
 * to skip the specified client when printing the message.
 * After printing the message, the client will no longer be skipped.
 * 
 * @param client   Client index
 * @noreturn
 */
stock CSkipNextClient(client)


/**
 * Adds a color to the colors trie
 *
 * @param name            Color name, without braces
 * @param color            Hexadecimal representation of the color (0xRRGGBB)
 * @return                True if color was added successfully, false if a color already exists with that name
 */
stock bool:CAddColor(const String:name[], color)


/**
 * Removes color tags from a message
 * 
 * @param message        Message to remove tags from
 * @param maxlen        Maximum buffer length
 * @noreturn
 */
stock CRemoveTags(String:message[], maxlen)

/**
 * Replies to a command with colors
 * 
 * @param client        Client to reply to
 * @param message        Message (formatting rules)
 * @noreturn
 */
stock CReplyToCommand(client, const String:message[], any:...)

/**
 * Replies to a command with colors
 * 
 * @param client        Client to reply to
 * @param author        Client to use for {teamcolor}
 * @param message        Message (formatting rules)
 * @noreturn
 */
stock CReplyToCommandEx(clientauthor, const String:message[], any:...)

/**
 * Shows admin activity with colors
 * 
 * @param client        Client performing an action
 * @param message        Message (formatting rules)
 * @noreturn
 */
stock CShowActivity(client, const String:message[], any:...)

/**
 * Shows admin activity with colors
 * 
 * @param client        Client performing an action
 * @param tag            Tag to prepend to the message (color tags supported)
 * @param message        Message (formatting rules)
 * @noreturn
 */
stock CShowActivityEx(client, const String:tag[], const String:message[], any:...)

/**
 * Shows admin activity with colors
 * 
 * @param client        Client performing an action
 * @param tag            Tag to prepend to the message (color tags supported)
 * @param message        Message (formatting rules)
 * @noreturn
 */
stock CShowActivity2(client, const String:tag[], const String:message[], any:...)

/**
 * Determines whether a color name exists
 * 
 * @param color            The color name to check
 * @return                True if the color exists, false otherwise
 */
stock bool:CColorExists(const String:color[])

/**
 * Returns the hexadecimal representation of a client's team color (will NOT initialize the trie, so if you use only this function from this include file, your plugin's memory usage will not increase)
 *
 * @param client        Client to get the team color for
 * @return                Client's team color in hexadecimal, or green if unknown
 * On error/Errors:        If the client index passed is invalid or not in game.
 */
stock CGetTeamColor(client

Colors:
Just put the color name in curly braces (i.e. {cyan})
PHP Code:

    SetTrieValue(hTrie"aliceblue"0xF0F8FF);
    
SetTrieValue(hTrie"allies"0x4D7942); // same as Allies team in DoD:S
    
SetTrieValue(hTrie"ancient"0xEB4B4B); // same as Ancient item rarity in Dota 2
    
SetTrieValue(hTrie"antiquewhite"0xFAEBD7);
    
SetTrieValue(hTrie"aqua"0x00FFFF);
    
SetTrieValue(hTrie"aquamarine"0x7FFFD4);
    
SetTrieValue(hTrie"arcana"0xADE55C); // same as Arcana item rarity in Dota 2
    
SetTrieValue(hTrie"axis"0xFF4040); // same as Axis team in DoD:S
    
SetTrieValue(hTrie"azure"0x007FFF);
    
SetTrieValue(hTrie"beige"0xF5F5DC);
    
SetTrieValue(hTrie"bisque"0xFFE4C4);
    
SetTrieValue(hTrie"black"0x000000);
    
SetTrieValue(hTrie"blanchedalmond"0xFFEBCD);
    
SetTrieValue(hTrie"blue"0x99CCFF); // same as BLU/Counter-Terrorist team color
    
SetTrieValue(hTrie"blueviolet"0x8A2BE2);
    
SetTrieValue(hTrie"brown"0xA52A2A);
    
SetTrieValue(hTrie"burlywood"0xDEB887);
    
SetTrieValue(hTrie"cadetblue"0x5F9EA0);
    
SetTrieValue(hTrie"chartreuse"0x7FFF00);
    
SetTrieValue(hTrie"chocolate"0xD2691E);
    
SetTrieValue(hTrie"collectors"0xAA0000); // same as Collector's item quality in TF2
    
SetTrieValue(hTrie"common"0xB0C3D9); // same as Common item rarity in Dota 2
    
SetTrieValue(hTrie"community"0x70B04A); // same as Community item quality in TF2
    
SetTrieValue(hTrie"coral"0xFF7F50);
    
SetTrieValue(hTrie"cornflowerblue"0x6495ED);
    
SetTrieValue(hTrie"cornsilk"0xFFF8DC);
    
SetTrieValue(hTrie"corrupted"0xA32C2E); // same as Corrupted item quality in Dota 2
    
SetTrieValue(hTrie"crimson"0xDC143C);
    
SetTrieValue(hTrie"cyan"0x00FFFF);
    
SetTrieValue(hTrie"darkblue"0x00008B);
    
SetTrieValue(hTrie"darkcyan"0x008B8B);
    
SetTrieValue(hTrie"darkgoldenrod"0xB8860B);
    
SetTrieValue(hTrie"darkgray"0xA9A9A9);
    
SetTrieValue(hTrie"darkgrey"0xA9A9A9);
    
SetTrieValue(hTrie"darkgreen"0x006400);
    
SetTrieValue(hTrie"darkkhaki"0xBDB76B);
    
SetTrieValue(hTrie"darkmagenta"0x8B008B);
    
SetTrieValue(hTrie"darkolivegreen"0x556B2F);
    
SetTrieValue(hTrie"darkorange"0xFF8C00);
    
SetTrieValue(hTrie"darkorchid"0x9932CC);
    
SetTrieValue(hTrie"darkred"0x8B0000);
    
SetTrieValue(hTrie"darksalmon"0xE9967A);
    
SetTrieValue(hTrie"darkseagreen"0x8FBC8F);
    
SetTrieValue(hTrie"darkslateblue"0x483D8B);
    
SetTrieValue(hTrie"darkslategray"0x2F4F4F);
    
SetTrieValue(hTrie"darkslategrey"0x2F4F4F);
    
SetTrieValue(hTrie"darkturquoise"0x00CED1);
    
SetTrieValue(hTrie"darkviolet"0x9400D3);
    
SetTrieValue(hTrie"deeppink"0xFF1493);
    
SetTrieValue(hTrie"deepskyblue"0x00BFFF);
    
SetTrieValue(hTrie"dimgray"0x696969);
    
SetTrieValue(hTrie"dimgrey"0x696969);
    
SetTrieValue(hTrie"dodgerblue"0x1E90FF);
    
SetTrieValue(hTrie"exalted"0xCCCCCD); // same as Exalted item quality in Dota 2
    
SetTrieValue(hTrie"firebrick"0xB22222);
    
SetTrieValue(hTrie"floralwhite"0xFFFAF0);
    
SetTrieValue(hTrie"forestgreen"0x228B22);
    
SetTrieValue(hTrie"frozen"0x4983B3); // same as Frozen item quality in Dota 2
    
SetTrieValue(hTrie"fuchsia"0xFF00FF);
    
SetTrieValue(hTrie"fullblue"0x0000FF);
    
SetTrieValue(hTrie"fullred"0xFF0000);
    
SetTrieValue(hTrie"gainsboro"0xDCDCDC);
    
SetTrieValue(hTrie"genuine"0x4D7455); // same as Genuine item quality in TF2
    
SetTrieValue(hTrie"ghostwhite"0xF8F8FF);
    
SetTrieValue(hTrie"gold"0xFFD700);
    
SetTrieValue(hTrie"goldenrod"0xDAA520);
    
SetTrieValue(hTrie"gray"0xCCCCCC); // same as spectator team color
    
SetTrieValue(hTrie"grey"0xCCCCCC);
    
SetTrieValue(hTrie"green"0x3EFF3E);
    
SetTrieValue(hTrie"greenyellow"0xADFF2F);
    
SetTrieValue(hTrie"haunted"0x38F3AB); // same as Haunted item quality in TF2
    
SetTrieValue(hTrie"honeydew"0xF0FFF0);
    
SetTrieValue(hTrie"hotpink"0xFF69B4);
    
SetTrieValue(hTrie"immortal"0xE4AE33); // same as Immortal item rarity in Dota 2
    
SetTrieValue(hTrie"indianred"0xCD5C5C);
    
SetTrieValue(hTrie"indigo"0x4B0082);
    
SetTrieValue(hTrie"ivory"0xFFFFF0);
    
SetTrieValue(hTrie"khaki"0xF0E68C);
    
SetTrieValue(hTrie"lavender"0xE6E6FA);
    
SetTrieValue(hTrie"lavenderblush"0xFFF0F5);
    
SetTrieValue(hTrie"lawngreen"0x7CFC00);
    
SetTrieValue(hTrie"legendary"0xD32CE6); // same as Legendary item rarity in Dota 2
    
SetTrieValue(hTrie"lemonchiffon"0xFFFACD);
    
SetTrieValue(hTrie"lightblue"0xADD8E6);
    
SetTrieValue(hTrie"lightcoral"0xF08080);
    
SetTrieValue(hTrie"lightcyan"0xE0FFFF);
    
SetTrieValue(hTrie"lightgoldenrodyellow"0xFAFAD2);
    
SetTrieValue(hTrie"lightgray"0xD3D3D3);
    
SetTrieValue(hTrie"lightgrey"0xD3D3D3);
    
SetTrieValue(hTrie"lightgreen"0x99FF99);
    
SetTrieValue(hTrie"lightpink"0xFFB6C1);
    
SetTrieValue(hTrie"lightsalmon"0xFFA07A);
    
SetTrieValue(hTrie"lightseagreen"0x20B2AA);
    
SetTrieValue(hTrie"lightskyblue"0x87CEFA);
    
SetTrieValue(hTrie"lightslategray"0x778899);
    
SetTrieValue(hTrie"lightslategrey"0x778899);
    
SetTrieValue(hTrie"lightsteelblue"0xB0C4DE);
    
SetTrieValue(hTrie"lightyellow"0xFFFFE0);
    
SetTrieValue(hTrie"lime"0x00FF00);
    
SetTrieValue(hTrie"limegreen"0x32CD32);
    
SetTrieValue(hTrie"linen"0xFAF0E6);
    
SetTrieValue(hTrie"magenta"0xFF00FF);
    
SetTrieValue(hTrie"maroon"0x800000);
    
SetTrieValue(hTrie"mediumaquamarine"0x66CDAA);
    
SetTrieValue(hTrie"mediumblue"0x0000CD);
    
SetTrieValue(hTrie"mediumorchid"0xBA55D3);
    
SetTrieValue(hTrie"mediumpurple"0x9370D8);
    
SetTrieValue(hTrie"mediumseagreen"0x3CB371);
    
SetTrieValue(hTrie"mediumslateblue"0x7B68EE);
    
SetTrieValue(hTrie"mediumspringgreen"0x00FA9A);
    
SetTrieValue(hTrie"mediumturquoise"0x48D1CC);
    
SetTrieValue(hTrie"mediumvioletred"0xC71585);
    
SetTrieValue(hTrie"midnightblue"0x191970);
    
SetTrieValue(hTrie"mintcream"0xF5FFFA);
    
SetTrieValue(hTrie"mistyrose"0xFFE4E1);
    
SetTrieValue(hTrie"moccasin"0xFFE4B5);
    
SetTrieValue(hTrie"mythical"0x8847FF); // same as Mythical item rarity in Dota 2
    
SetTrieValue(hTrie"navajowhite"0xFFDEAD);
    
SetTrieValue(hTrie"navy"0x000080);
    
SetTrieValue(hTrie"normal"0xB2B2B2); // same as Normal item quality in TF2
    
SetTrieValue(hTrie"oldlace"0xFDF5E6);
    
SetTrieValue(hTrie"olive"0x9EC34F);
    
SetTrieValue(hTrie"olivedrab"0x6B8E23);
    
SetTrieValue(hTrie"orange"0xFFA500);
    
SetTrieValue(hTrie"orangered"0xFF4500);
    
SetTrieValue(hTrie"orchid"0xDA70D6);
    
SetTrieValue(hTrie"palegoldenrod"0xEEE8AA);
    
SetTrieValue(hTrie"palegreen"0x98FB98);
    
SetTrieValue(hTrie"paleturquoise"0xAFEEEE);
    
SetTrieValue(hTrie"palevioletred"0xD87093);
    
SetTrieValue(hTrie"papayawhip"0xFFEFD5);
    
SetTrieValue(hTrie"peachpuff"0xFFDAB9);
    
SetTrieValue(hTrie"peru"0xCD853F);
    
SetTrieValue(hTrie"pink"0xFFC0CB);
    
SetTrieValue(hTrie"plum"0xDDA0DD);
    
SetTrieValue(hTrie"powderblue"0xB0E0E6);
    
SetTrieValue(hTrie"purple"0x800080);
    
SetTrieValue(hTrie"rare"0x4B69FF); // same as Rare item rarity in Dota 2
    
SetTrieValue(hTrie"red"0xFF4040); // same as RED/Terrorist team color
    
SetTrieValue(hTrie"rosybrown"0xBC8F8F);
    
SetTrieValue(hTrie"royalblue"0x4169E1);
    
SetTrieValue(hTrie"saddlebrown"0x8B4513);
    
SetTrieValue(hTrie"salmon"0xFA8072);
    
SetTrieValue(hTrie"sandybrown"0xF4A460);
    
SetTrieValue(hTrie"seagreen"0x2E8B57);
    
SetTrieValue(hTrie"seashell"0xFFF5EE);
    
SetTrieValue(hTrie"selfmade"0x70B04A); // same as Self-Made item quality in TF2
    
SetTrieValue(hTrie"sienna"0xA0522D);
    
SetTrieValue(hTrie"silver"0xC0C0C0);
    
SetTrieValue(hTrie"skyblue"0x87CEEB);
    
SetTrieValue(hTrie"slateblue"0x6A5ACD);
    
SetTrieValue(hTrie"slategray"0x708090);
    
SetTrieValue(hTrie"slategrey"0x708090);
    
SetTrieValue(hTrie"snow"0xFFFAFA);
    
SetTrieValue(hTrie"springgreen"0x00FF7F);
    
SetTrieValue(hTrie"steelblue"0x4682B4);
    
SetTrieValue(hTrie"strange"0xCF6A32); // same as Strange item quality in TF2
    
SetTrieValue(hTrie"tan"0xD2B48C);
    
SetTrieValue(hTrie"teal"0x008080);
    
SetTrieValue(hTrie"thistle"0xD8BFD8);
    
SetTrieValue(hTrie"tomato"0xFF6347);
    
SetTrieValue(hTrie"turquoise"0x40E0D0);
    
SetTrieValue(hTrie"uncommon"0xB0C3D9); // same as Uncommon item rarity in Dota 2
    
SetTrieValue(hTrie"unique"0xFFD700); // same as Unique item quality in TF2
    
SetTrieValue(hTrie"unusual"0x8650AC); // same as Unusual item quality in TF2
    
SetTrieValue(hTrie"valve"0xA50F79); // same as Valve item quality in TF2
    
SetTrieValue(hTrie"vintage"0x476291); // same as Vintage item quality in TF2
    
SetTrieValue(hTrie"violet"0xEE82EE);
    
SetTrieValue(hTrie"wheat"0xF5DEB3);
    
SetTrieValue(hTrie"white"0xFFFFFF);
    
SetTrieValue(hTrie"whitesmoke"0xF5F5F5);
    
SetTrieValue(hTrie"yellow"0xFFFF00);
    
SetTrieValue(hTrie"yellowgreen"0x9ACD32); 

There are also 2 special color codes: {default} and {teamcolor}. {default} resets the chat to its default color and {teamcolor} is replaced with the color code for the client's team in PrintToChatEx and PrintToChatAllEx.

You can see all the colors in action here. Plugin authors: feel free to link to this page in your plugin threads to show users what colors are available.

Changelog:
  • v1.9.0 (1/2/14)
    • VoiDeD is bad (also added a few more colors)
  • v1.8.0 (5/13/13)
    • Added CShowActivity, CShowActivityEx, and CShowActivity2
  • v1.7.0 (2/7/13)
    • Improved team color handing on non-SayText2 games (currently only DoD:S is supported)
    • Added support for protobuf usermessages for if/when Source 2009 games are updated in the future
  • v1.6.0 (1/7/13)
    • Changed the way {teamcolor} is handled so it relies on the game's built-in team colors instead of predefined values
    • Messages will now be printed to clients' consoles
  • v1.5.0 (12/31/12)
    • Added CColorExists
    • Added axis, allies, normal, unique, vintage, genuine, strange, strange, unusual, haunted, community, selfmade, and valve colors
  • v1.4.0 (10/3/12)
    • Added CReplyToCommand
    • Added CReplyToCommandEx (1.4.1)
  • v1.3.0 (9/12/12)
    • Fixed tag mismatch warning
    • Fixed issue with CPrintToChatAllEx
  • v1.2.0 (9/9/12)
    • Updated to use a SayText2 usermessage instead of PrintToChat
  • v1.1.0BETA (5/28/12)
    • Fixed bug in CPrintToChatAllEx
    • Added StrToLower documentation
    • Added CRemoveTags
    • Added CGetTeamColor stock, which returns the hexadecimal representation of a client's team color (without initializing the trie)
  • v1.0.0BETA (5/11/12)
    • Initial release

Download morecolors.inc

.

Franc1sco 05-12-2012 07:45

Re: [INC] More Colors (1.0.0BETA)
 
Can use multiple team colors in the same message, multiple colors... woo very nice!

But could be done for CS:S ? or you think it would be possible?

Zephyrus 05-12-2012 07:53

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by Franc1sco (Post 1707323)
Can use multiple team colors in the same message, multiple colors... woo very nice!

But could be done for CS:S ? or you think it would be possible?

support for RGB colors was presented in the latest tf2 update, its not something that he achieved, theres no css support atm

kiki33hun 05-12-2012 14:31

Re: [INC] More Colors (1.0.0BETA)
 
Nice

ReFlexPoison 05-12-2012 14:42

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by Zephyrus (Post 1707334)
...theres no css support atm

Which is a shame because now game checks for CVars are necessary, at least in my plugin. :down:

Dr. McKay 05-12-2012 16:40

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by ReFlexPoison (Post 1707559)
Which is a shame because now game checks for CVars are necessary, at least in my plugin. :down:

Just upload separate versions of plugins that use colors. Use this include for yourplugin-tf2.smx and the original colors.inc for yourplugin-others.smx

That being said, please don't use this include in a published plugin yet. It's liable to explode.

disawar1 05-13-2012 02:37

Re: [INC] More Colors (1.0.0BETA)
 
Hello, is it possible to add support for other games? now its look like that
https://forums.alliedmods.net/attach...6&d=1336890795

Dr. McKay 05-13-2012 02:58

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by disawar1 (Post 1707930)
Hello, is it possible to add support for other games? now its look like that
https://forums.alliedmods.net/attach...6&d=1336890795

Not till Valve does.

Zephyrus 05-13-2012 08:36

Re: [INC] More Colors (1.0.0BETA)
 
theres no CSGO support either, also it was talked about here on the forums. ive just tried

minimoney1 05-14-2012 01:02

Re: [INC] More Colors (1.0.0BETA)
 
Equivalent of CRemoveTags?

Dr. McKay 05-14-2012 07:06

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by Dr. McKay (Post 1707148)
Known Issues:
  • CPrintToChatAllEx sometimes causes an "invalid client index" error
  • Needs a CRemoveTags stock


FlaminSarge 05-14-2012 23:17

Re: [INC] More Colors (1.0.0BETA)
 
McKay, any chance of adding support for {#FFFFFF} tags, as that one advertisements plugin already has? And even {##FFFFFFAA} for alpha as well using \x08?

Dr. McKay 05-14-2012 23:19

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by FlaminSarge (Post 1709129)
McKay, any chance of adding support for {#FFFFFF} tags, as that one advertisements plugin already has? And even {##FFFFFFAA} for alpha as well using \x08?

Sure. I just don't really understand why wrapping {} around an RGB color code is easier than just typing out \x07RRGGBB...

bl4nk 05-15-2012 15:07

Re: [INC] More Colors (1.0.0BETA)
 
Thought this might come of use to some people:
PHP Code:

stock GetRandomRGB() {
    
SetRandomSeed(RoundFloat(GetEngineTime()));
    return (((
GetRandomInt(0,255) & 0xFF) << 16) | ((GetRandomInt(0,255) & 0xFF) << 8) | ((GetRandomInt(0,255) & 0xFF) << 0));



berni 05-18-2012 22:23

Re: [INC] More Colors (1.0.0BETA)
 
bl4nk, wouldn't it be easier to just use GetRandomInt(0, MAXSIZE) and set the alpha bits to 0xFF ?

11530 05-20-2012 01:59

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by FlaminSarge (Post 1709129)
McKay, any chance of adding support for {#FFFFFF} tags, as that one advertisements plugin already has? And even {##FFFFFFAA} for alpha as well using \x08?

My code found here should do it relatively quickly and safely should you want to copy it McKay.

bl4nk 05-22-2012 02:15

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by berni (Post 1711864)
bl4nk, wouldn't it be easier to just use GetRandomInt(0, MAXSIZE) and set the alpha bits to 0xFF ?

I suppose that would work as well.

Powerlord 05-22-2012 16:33

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by berni (Post 1711864)
bl4nk, wouldn't it be easier to just use GetRandomInt(0, MAXSIZE) and set the alpha bits to 0xFF ?

Why would the alpha bits be necessary? There's a reason Valve included two versions of the colored code... so you only had to set the alpha if you wanted transparency.

berni 05-22-2012 17:45

Re: [INC] More Colors (1.0.0BETA)
 
sure, but you don't want to have random transparency, do you ? :P

Dr. McKay 05-22-2012 19:08

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by berni (Post 1714543)
sure, but you don't want to have random transparency, do you ? :P

Text is fully opaque if you use \x07. Alpha is only present if you use \x08.

berni 05-23-2012 04:19

Re: [INC] More Colors (1.0.0BETA)
 
Ok, but my previous question was just pointed at bl4nk's code :3

FlaminSarge 05-24-2012 05:18

Re: [INC] More Colors (1.0.0BETA)
 
I added in CRemoveTags. I didn't include bl4nk's random RGB, yet, though. I'm also slightly worried about the idea of having a trie and an array for each plugin using colors. While a bit strange, using a plugin to manage color stocks may be a bit better, though then plugins would have to share the same custom colors added via CAddColor... I dunno. And yes, it's probably just easier to use \x07CUSTOM instead of {#CUSTOM}, but I was concerned about if it was fine in translation files, so I made the suggestion anyways.

If you're planning on implementing \x08, for simplicity I'd suggest having everything use \x08, using FF for the alpha for the included colors that are using \x07 right now.

... https://forums.alliedmods.net/showpo...0&postcount=25

Dr. McKay 05-24-2012 07:12

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by FlaminSarge (Post 1715554)
I added in CRemoveTags. I didn't include bl4nk's random RGB, yet, though. I'm also slightly worried about the idea of having a trie and an array for each plugin using colors. While a bit strange, using a plugin to manage color stocks may be a bit better, though then plugins would have to share the same custom colors added via CAddColor... I dunno. And yes, it's probably just easier to use \x07CUSTOM instead of {#CUSTOM}, but I was concerned about if it was fine in translation files, so I made the suggestion anyways.

If you're planning on implementing \x08, for simplicity I'd suggest having everything use \x08, using FF for the alpha for the included colors that are using \x07 right now.

I'll update the .inc in the OP when I get to a computer.

I was slightly concerned about every plugin having its own trie, but whatever.

I'd rather continue using \x07 for text with full alpha, since color codes take up part of the maximum chat message length. Each color would take up two additional characters.

noodleboy347 05-27-2012 04:21

Re: [INC] More Colors (1.0.0BETA)
 
This is pretty much unusable [for me] because CPrintToChatAllEx never works

FlaminSarge 05-27-2012 06:03

Re: [INC] More Colors (1.0.0BETA)
 
1 Attachment(s)
Technically, we don't need CPrintToChatAllEx anymore, it's only there for backwards compatibility with colors.inc-using plugins. Its only function was to specify a color based on a particular client via the {teamcolor} tag, but you can do that now in various other ways, so.... yeah. What's the issue you're having with it?

Ooh, found the bug. VFormat under CPrintToChatAllEx should have '3' as the last arg, not '2'. McKay, you've gotta be saying 'damn you copypaste' right about now. Change that and you should be good to go, noodle.

McKay: your concerns over the extra 2 chars makes sense, considering some of the stuff people like to print to clients.

EDIT: Here.

Dr. McKay 05-27-2012 09:07

Re: [INC] More Colors (1.0.0BETA)
 
Oops…

I'll try to update it today. That being said, this is still a beta and shouldn't be used in any released plugins…

noodleboy347 05-27-2012 15:37

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by FlaminSarge (Post 1717390)
Technically, we don't need CPrintToChatAllEx anymore, it's only there for backwards compatibility with colors.inc-using plugins. Its only function was to specify a color based on a particular client via the {teamcolor} tag, but you can do that now in various other ways, so.... yeah. What's the issue you're having with it?

Ooh, found the bug. VFormat under CPrintToChatAllEx should have '3' as the last arg, not '2'. McKay, you've gotta be saying 'damn you copypaste' right about now. Change that and you should be good to go, noodle.

McKay: your concerns over the extra 2 chars makes sense, considering some of the stuff people like to print to clients.

EDIT: Here.

Thanks breh

Dr. McKay 05-27-2012 16:00

Re: [INC] More Colors (1.0.0BETA)
 
FlaminSarge: I'm not a huge fan of the way you're using both an array and a trie… uses up more memory and is a bit unnecessary. I prefer to parse the string to find tags then check if they match a color tag, but that's just me.

FlaminSarge 05-28-2012 04:33

Re: [INC] More Colors (1.0.0BETA)
 
You'd still have to iterate through the trie's keys, and for that you need an array. Think about it:
1) Parse string, find { } tags. Save these locations somewhere.
2) At each location, check to see if the tag matches any color tags. You'll need to check every key in the trie, but you can't iterate through tries, so you'll need to go through some other thing that stores the keys. That's what the array's for (you could use the non-ADT array, but that won't have dynamic sizing so you'd have to have a MAX_COLORS define).
3) You replace those with empty space. You'd have to move all other pieces of the string down to where the tag is removed.

I believe in either case, you'd need something like that. Using ReplaceString and iterating through the array is much easier than manually editing the string like that.

If you're worried about space, you could make this a plugin, and then all plugins using it would share the same set of colors, and each time you added a color all plugins would get that color. That may or may not be a good thing.

asherkin 05-28-2012 04:52

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by FlaminSarge (Post 1717957)
2) At each location, check to see if the tag matches any color tags. You'll need to check every key in the trie, but you can't iterate through tries, so you'll need to go through some other thing that stores the keys. That's what the array's for (you could use the non-ADT array, but that won't have dynamic sizing so you'd have to have a MAX_COLORS define).

Just use GetTrieString and check it doesn't return false. It's whole point is that it's a Trie so lookups are fast, iterating the whole list would be stupidly slow.

Dr. McKay 05-28-2012 15:51

Re: [INC] More Colors (1.0.0BETA)
 
Quote:

Originally Posted by asherkin (Post 1717969)
Just use GetTrieString and check it doesn't return false. It's whole point is that it's a Trie so lookups are fast, iterating the whole list would be stupidly slow.

I did this in the .inc in the OP.

Dr. McKay 05-28-2012 16:36

Re: [INC] More Colors (1.0.0BETA)
 
Alright, I've updated it to 1.1.0. It's still in beta, but it now has a CRemoveTags stock. I've also fixed the bug with CPrintToChatAllEx.

Here's a full changelog:
  • Fixed bug in CPrintToChatAllEx
  • Added StrToLower documentation
  • Added CRemoveTags
  • Added CGetTeamColor stock, which returns the hexadecimal representation of a client's team color (without initializing the trie)

11530 05-29-2012 00:07

Re: [INC] More Colors (1.1.0BETA)
 
These may already be included in the list (since I don't know their hex values) but what would you think of adding item-type colors, such as Unusual, Strange, Genuine, Vintage etc. (swatch here) as well as the various single-tone paints in the game?

Dr. McKay 05-29-2012 02:02

Re: [INC] More Colors (1.1.0BETA)
 
Quote:

Originally Posted by 11530 (Post 1718512)
These may already be included in the list (since I don't know their hex values) but what would you think of adding item-type colors, such as Unusual, Strange, Genuine, Vintage etc. (swatch here) as well as the various single-tone paints in the game?

Not a bad idea.

FlaminSarge 05-29-2012 05:02

Re: [INC] More Colors (1.1.0BETA)
 
From ClientScheme.res:
Code:

        "QualityColorNormal"                    "178 178 178 255"
        "QualityColorrarity1"                    "77 116 85 255"
        "QualityColorrarity2"                    "141 131 75 255"
        "QualityColorrarity3"                    "112 85 15 255"
        "QualityColorrarity4"                    "134 80 172 255"
        "QualityColorVintage"                    "71 98 145 255"
        "QualityColorUnique"                    "255 215 0 255"
        "QualityColorCommunity"                    "112 176 74 255"
        "QualityColorDeveloper"                    "165 15 121 255"
        "QualityColorSelfMade"                    "112 176 74 255"
        "QualityColorCustomized"                "71 98 145 255"
        "QualityColorStrange"                    "207 106 50 255"
        "QualityColorCompleted"                    "134 80 172 255"
        "QualityColorHaunted"                    "134 80 172 255"

(Of course, custom ClientScheme.res files can change these, so you'll only have the default ones defined)

There's a lot more colors defined in ClientScheme, so take a look.
Of interesting note:
Code:

        //"Black"                "0 0 0 255"
        //Changed black to a NTSC safe color
       
        "Black"                "46 43 42 255"

Also, you didn't use any of my typo/spacing fixes :C

Dr. McKay 05-29-2012 06:39

Re: [INC] More Colors (1.1.0BETA)
 
Thanks for the ClientScheme.res tip, I was just going to use the colors from the wiki.
Quote:

Originally Posted by FlaminSarge (Post 1718596)
Also, you didn't use any of my typo/spacing fixes :C

Where were those?

FlaminSarge 05-30-2012 01:40

Re: [INC] More Colors (1.1.0BETA)
 
Mostly in the documentation. Do a diff with the morecolors.inc I posted a few posts up, you'll see 'em.

Dr. McKay 05-31-2012 19:05

Re: [INC] More Colors (1.1.0BETA)
 
I've added a lite version, morecolorslite.inc.

It only has one stock:

PHP Code:

/** 
 * Returns the hexadecimal representation of a client's team color (will NOT initialize the trie, so if you use only this function from this include file, your plugin's memory usage will not increase) 
 * 
 * @param client        Client to get the team color for 
 * @return                Client's team color in hexadecimal, or green if unknown 
 * On error/Errors:        If the client index passed is invalid or not in game. 
 */ 
stock CGetTeamColor(client

Pretty much the only stock I'm ever going to use, since the rest of the .inc simply attaches names to colors. This just gives me a client's team color simply and easily, without all the extra baggage.

Note: If you include morecolors.inc and only use CGetTeamColor, it'll be basically the same since none of the other stocks will be compiled into the plugin, and the trie will never be initialized.

Razmo51 06-04-2012 17:12

Re: [INC] More Colors (1.1.0BETA)
 
very nice; I'm in love with this include *.*

AeroAcrobat 06-22-2012 18:26

Re: [INC] More Colors (1.1.0BETA)
 
Chat colors [PSD] v3.0

Bored of edit the color -> reloading -> edit again...
Those days are over now!


Get instant feedback in Adobe Photoshop.

https://dl.dropbox.com/u/10877736/al.../06540651d.gif

https://dl.dropbox.com/u/10877736/al...or_changer.gif

Download the PSD file:
- click here -

Looking for color combinations ?
https://kuler.adobe.com
http://colourlovers.com/palettes/mos...ites/all-time/


All times are GMT -4. The time now is 13:55.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.