Andrey
пишу код за еду
- Сообщения
- 3,386
- Реакции
- 4,018
- Команда форума
- Автор ресурса
- #1
Colors
Функции для легкого управления цветом чата
Функции для легкого управления цветом чата
Описание:
Этот файл позволяет разработчикам легко управлять цветами шрифта чата в различных игровых модах, использовать теги цветов, использовать теги в файлах перевода и автоматически заменять цвета в моде, которые не поддерживают их (любой цвет, который не поддерживается, будет заменен на зеленый цвет).
Функции:
- CPrintToChat
- CPrintToChatAll
- CPrintToChatEx
- CPrintToChatAllEx
- CRemoveTags
- CSkipNextClient
Регулярные фунции:
PHP:
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock CPrintToChat(client, const String:szMessage[], any:...)
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules)
* @return No return
*/
stock CPrintToChatAll(const String:szMessage[], any:...)
Основные цвета: default, green (желтый в L4D), olive.
Командные цвета: lightgreen, red, blue.
Примечания:
- You can use only one team color (like lightgreen, red or blue) in the message.
- In hl2dm colors are different for classic deathmatch and team deathmatch.
- If some color is not supported by the mod it will be automatically replaced with green
- You can use these functions instead of default SM function, they are supports formatting (%d, %s, %t, etc.)
- Green color is yellow in L4D and yellow is green in all other games. You can use tag that you prefer.
- 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.
Team color based functions:
PHP:
/**
* 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 szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client or author are not connected an error will
* be thrown.
*/
stock CPrintToChatEx(client, author, const String:szMessage[], 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 szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the author is not connected an error will
* be thrown.
*/
stock CPrintToChatAllEx(author, const String:szMessage[], any:...)
Основные цвета: default, green (желтый в L4D), olive.
Командные цвета: based on author's team color.
Примечания:
- Author index is any client index whose team color you want to be used for {teamcolor} tag
- Tag {teamcolor} replaces {red}, {blue} and {lightgreen} tags
- All notes for regular functions are used for these function too.
Другое:
PHP:
/**
* Removes color tags from the string.
*
* @param szMessage String.
* @param maxlength Maximum length of the string buffer.
* @return No return
*/
stock CRemoveTags(String:szMessage[], maxlength)
/**
* This function should only be used right in front of
* CPrintToChatAll or CPrintToChatAllEx and it tells
* to those funcions to skip specified client when printing
* message to all clients. After message is printed client will
* no more be skipped.
*
* @param client Client index
* @return No return
*/
stock CSkipNextClient(client)
FAQ
1. Как использовать цвет?
Просто пометьте текст тегом цвета
PHP:
CPrintToChat(client, "This text is {green}green{default} and this is {red}red");
2. Можно ли использовать красный синий и зеленый цвет в одной строке?
Нет. Можно использовать только один цвет команды в строке. (Либо синий либо красный)
3. Какой формат работы функции?
Они работают точно так же, как по умолчанию SM функции (например, PrintToChat)
PHP:
CPrintToChatAll("This number {green}%d{default} is green", 5);
4. Можно ли использовать цвета в файлах перевода?
Да, можно.
Пример:
C-подобный:
"Phrases"
{
"My phrase"
{
"en" "My {green}phrase"
"ru" "Моя {green}фраза"
}
}
PHP:
CPrintToChatAll("%t", "My phrase");
5. Как его установить?
Потожить colors.inc в папку sourcemod/scripting/include
Добавить в код:
PHP:
#include <colors>
Можно. Но для этого требуется хотябы один игрок в наблюдателях.
7. Почему иногда красный-синий цвета иногда показывает зеленым?
Должен быть хотя бы один игрок в каждой команде для надлежащего красного и синего цвета. В противном случае эти теги будут заменены на зеленый.
Оригинал
Последнее редактирование модератором: