View Single Post
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 07-09-2009 , 12:26   Re: [INC] Colors
Reply With Quote #2

FAQ


1. How can I use color tags?

Just place color tag in the text where you want your color to start from.
PHP Code:
CPrintToChat(client"This text is {green}green{default} and this is {red}red"); 
Output: [IMG]http://img694.**************/img694/6613/dedust20008p.jpg[/IMG]


2. Is it possible to use red, blue or lightgreen colors in one string?

No. You can only have one team color in a string.


3. How do formatting rules work for these functions?

They work in exactly same way as for default SM functions (like PrintToChat).
PHP Code:
CPrintToChatAll("This number {green}%d{default} is green"5); 
Output: [IMG]http://img199.**************/img199/8122/dedust20009j.jpg[/IMG]


4. Can I use color tags inside of translations files?

Yes, you can.
Translation file:
Code:
"Phrases"
{
	"My phrase"
	{
		"en"			"My {green}phrase"
		"ru"			"Моя {green}фраза"
	}
}
In the code:
PHP Code:
CPrintToChatAll("%t""My phrase"); 
Output for english clients: [IMG]http://img46.**************/img46/5854/dedust20010c.jpg[/IMG]
Output for russian clients: [IMG]http://img14.**************/img14/9972/dedust20011e.jpg[/IMG]


5. How to install it?

Put colors.inc into sourcemod/scripting/include folder.
Add this into the code:
PHP Code:
#include <colors> 

6. Is it possible to use grey color?

Yes, it is. But there is no grey tag because it requires at least one player in spectators team. This situation happens not often. But you can use grey in team color based functions.
PHP Code:
CPrintToChatEx(clientauthor"{teamcolor}Hello, this is author's team color"); 
Output when author is spectator: [IMG]http://img199.**************/img199/7830/dedust20013dt.jpg[/IMG]
Output when author is Red/T/Infected/Rebel: [IMG]http://img694.**************/img694/5869/dedust20012.jpg[/IMG]
Output when author is Blue/CT/Survivor/Combine: [IMG]http://img145.**************/img145/5875/dedust20014.jpg[/IMG]


7. Why red/blue colors sometimes show as green?

There must be at least one player in each team for proper red and blue colors working. Otherwise these tags will be replaced with green.


8. What does CSkipNextClient function do?

It tells to CPrintToChatAll and CPrintToChatAllEx to skip client when printing message to all clients. Should be always called right in front of those functions if you want to skip someone.
For example, you want to print message to all clients when client attacked someone and you don't want attacker and victim to see this message. Then you can use this code:
PHP Code:
CSkipNextClient(attacker);
CSkipNextClient(victim);
CPrintToChatAll("%N attacked %N"attackervictim); 
In next call of CPrintToChatAll or CPrintToChatAllEx function those clients will no longer be skipped and if you want to skip someone again then you need to call CSkipNextClient again.
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-29-2010 at 06:29.
exvel is offline
Send a message via ICQ to exvel