Русское сообщество по скриптингу

Цветное сообщение в чат  [Решено]

Все вопросы по работе и настройке AMXX и его плагинов.

Модератор: liFe iS GoOD

Правила форума
1. Запрещено материться и оскорблять других участников форума.
2. Запрещен флуд, оффтоп, дабл постинг во всех разделах форума, кроме раздела "Болтовня".
3. Запрещено взламывать сайт/форум или наносить любой вред проекту.
4. Запрещено рекламировать другие ресурсы.
5. Запрещено создавать темы без информативного названия. Название темы должно отображать ее смысл.

В данном разделе форума разрешено создавать темы, касающие только вопросов по AMX Mod X и его плагинам.

Цветное сообщение в чат

Сообщение DeIIyTaT » 08 фев 2018, 22:28

Вот код допустим хочу чтоб всё сообщение было зеленым как это сделшать ?

Код: Выделить всё
client_print(pPlayer, print_chat,
"[Скриншоты]: Недостаточно прав! Только Для Гл.админов !"); 

Название темы скорректировано // Subb98
Мой проект CSSURF.RU | SURF Сервера с RPG
amx-x.ru - Вы красавчики спасибо что вы есть ! :thumbs_up
Аватара пользователя
DeIIyTaT
 
Сообщения: 66
Зарегистрирован: 29 авг 2014, 13:53
Благодарил (а): 13 раз.
Поблагодарили: 0 раз.
Опыт программирования: Около года
Языки программирования: Counter-Strike 1.6
html,php

Re: Цветное сообщение в чат

Сообщение Subb98 » 08 фев 2018, 22:34

Какая версия AMXX?
«Очень хорошо. Лучше вы, чем я» © Donald J. Trump
Аватара пользователя
Subb98
Модератор
 
Сообщения: 5485
Зарегистрирован: 24 мар 2011, 19:42
Откуда: г. Пермь
Благодарил (а): 1329 раз.
Поблагодарили: 2343 раз.
Опыт программирования: Больше трех лет
Языки программирования: PHP

Re: Цветное сообщение в чат

Сообщение DeIIyTaT » 08 фев 2018, 22:38

AMX Mod X 1.8.1 RUS
Мой проект CSSURF.RU | SURF Сервера с RPG
amx-x.ru - Вы красавчики спасибо что вы есть ! :thumbs_up
Аватара пользователя
DeIIyTaT
 
Сообщения: 66
Зарегистрирован: 29 авг 2014, 13:53
Благодарил (а): 13 раз.
Поблагодарили: 0 раз.
Опыт программирования: Около года
Языки программирования: Counter-Strike 1.6
html,php

Re: Цветное сообщение в чат  [Решено]

Сообщение Subb98 » 08 фев 2018, 22:40

DeIIyTaT, используйте любой инклуд / сток цветного чата, например, Вы должны зарегистрироваться, чтобы видеть ссылки.:

Код: Выделить всё
#if defined _colorchat_included
    #endinput
#endif
#define _colorchat_included

/* ColorChat Support */
#define NORMAL    DontChange
#define GREEN    DontChange
#define RED        Red
#define BLUE    Blue
#define GREY    Grey
#define ColorChat client_print_color

#define MAX_TRANSLATION_LENGTH 2048

enum {
    
DontChange 0,
    
Grey = -1,
    
Red = -2,
    
Blue = -3
};

#define print_team_default  DontChange
#define print_team_grey     Grey
#define print_team_red      Red
#define print_team_blue     Blue

stock client_print_color(idsender, const fmt[], any:...)
{
    
// check if id is different from 0
    
if (id && !is_user_connected(id))
    {
        return 
0;
    }

    if (
sender Blue || sender 32)
    {
        
sender DontChange;
    }
    else if (
sender DontChange)
    {
        
sender = -sender 32// align indexes to the TeamInfo ones
    
}

    static const 
szTeamName[][] =
    {
        
"",
        
"TERRORIST",
        
"CT"
    
};

    new 
szMessage[191];

    new 
iParams numargs();

    
// Specific player code
    
if (id)
    {
        if (
iParams == 3)
        {
            
copy(szMessagecharsmax(szMessage), fmt); // copy so message length doesn't exceed critical 192 value
        
}
        else
        {
            
vformat(szMessagecharsmax(szMessage), fmt4);
        }

        if (
sender > (32 Grey))
        {
            if (
sender > (32 Blue))
            {
                
sender id;
            }
            else
            {
                
_CC_TeamInfo(idsenderszTeamName[sender - (32 Grey)]);
            }
        }
        
_CC_SayText(idsenderszMessage);
    }

    
// Send message to all players
    
else
    {
        
// Figure out if at least 1 player is connected
        // so we don't execute useless useless code if not
        
new iPlayers[32], iNum;
        
get_players(iPlayersiNum"ch");
        if (!
iNum)
        {
            return 
0;
        }

        new 
iMlNumberij;
        new Array:
aStoreML ArrayCreate();
        if (
iParams >= 5// ML can be used
        
{
            for (
3iParamsj++)
            {
                
// retrieve original param value and check if it's LANG_PLAYER value
                
if (getarg(j) == LANG_PLAYER)
                {
                    
0;
                    
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
                    
while ((szMessage[i] = getarg(1i++))) {}
                    if (
GetLangTransKey(szMessage) != TransKey_Bad)
                    {
                        
// Store that arg as LANG_PLAYER so we can alter it later
                        
ArrayPushCell(aStoreMLj++);

                        
// Update ML array saire so we'll know 1st if ML is used,
                        // 2nd how many args we have to alterate
                        
iMlNumber++;
                    }
                }
            }
        }

        
// If arraysize == 0, ML is not used
        // we can only send 1 MSG_ALL message if sender != 0
        
if (!iMlNumber)
        {
            if (
iParams == 3)
            {
                
copy(szMessagecharsmax(szMessage), fmt);
            }
            else
            {
                
vformat(szMessagecharsmax(szMessage), fmt4);
            }
            if (
sender < (32 Blue)) // if 0 is passed, need to loop
            
{
                if (
sender > (32 Grey))
                {
                    
_CC_TeamInfo(0senderszTeamName[sender - (32 Grey)]);
                }
                
_CC_SayText(0senderszMessage);
                return 
1;
            }
        }

        if (
sender > (32 Blue))
        {
            
sender 0// use receiver index
        
}

        for (--
iNumiNum >= 0iNum--)
        {
            
id iPlayers[iNum];

            if (
iMlNumber)
            {
                for (
0iMlNumberj++)
                {
                    
// Set all LANG_PLAYER args to player index ( = id )
                    // so we can format the text for that specific player
                    
setarg(ArrayGetCell(aStoreMLj), _id);
                }

                
// format string for specific player
                
vformat(szMessagecharsmax(szMessage), fmt4);
            }

            if (
sender > (32 Grey))
            {
                
_CC_TeamInfo(idsenderszTeamName[sender - (32 Grey)]);
            }
            
_CC_SayText(idsenderszMessage);
        }

        
ArrayDestroy(aStoreML);
    }
    return 
1;
}

stock _CC_TeamInfo(iReceiveriSenderszTeam[])
{
    static 
iTeamInfo 0;
    if (!
iTeamInfo)
    {
        
iTeamInfo get_user_msgid("TeamInfo");
    }
    
message_begin(iReceiver MSG_ONE MSG_ALLiTeamInfo_iReceiver);
    
write_byte(iSender);
    
write_string(szTeam);
    
message_end();
}

stock _CC_SayText(iReceiveriSenderszMessage[])
{
    static 
iSayText 0;
    if (!
iSayText)
    {
        
iSayText get_user_msgid("SayText");
    }

    
// Prevent sending format and localization strings via chat
    
for (new 0192i++)
    {
        if (
szMessage[i] == 0) break;
        if (
szMessage[i] == '%' ||
            
szMessage[i] == '#')
            
szMessage[i] = ' ';
    }
    
    
message_begin(iReceiver MSG_ONE MSG_ALLiSayText_iReceiver);
    
write_byte(iSender iSender iReceiver);
    if (
szMessage[0] > 4)
    {
        
write_byte(1);
        
szMessage[192 1] = 0;    // Two write_byte + string terminator
        
write_string(szMessage);
    }
    else
    {
        
szMessage[192 1] = 0;    // One write_byte + string terminator
        
write_string(szMessage);
    }
    
message_end();
}

new 
_translation_szBuffer[MAX_TRANSLATION_LENGTH];

stock register_dictionary_colored(const filename[])
{
    if (!
register_dictionary(filename))
    {
        return 
0;
    }

    new 
szFileName[256];
    
get_localinfo("amxx_datadir"szFileNamecharsmax(szFileName));
    
format(szFileNamecharsmax(szFileName), "%s/lang/%s"szFileNamefilename);
    new 
fp fopen(szFileName"rt");
    if (!
fp)
    {
        
log_amx("Failed to open %s"szFileName);
        return 
0;
    }

    new 
szLang[3], szKey[64], TransKey:iKey;

    while (!
feof(fp))
    {
        
fgets(fp_translation_szBuffercharsmax(_translation_szBuffer));
        
trim(_translation_szBuffer);

        if (
_translation_szBuffer[0] == '[')
        {
            
strtok(_translation_szBuffer[1], szLangcharsmax(szLang), _translation_szBuffer1']');
        }
        else if (
_translation_szBuffer[0])
        {
            
strbreak(_translation_szBufferszKeycharsmax(szKey), _translation_szBuffercharsmax(_translation_szBuffer));
            
iKey GetLangTransKey(szKey);
            if (
iKey != TransKey_Bad)
            {
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "!g""^4");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "!t""^3");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "!n""^1");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "^^4""^4");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "^^3""^3");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "^^1""^1");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "^^n""^n");
                
replace_all(_translation_szBuffercharsmax(_translation_szBuffer), "^^t""^t");
                
AddTranslation(szLangiKey_translation_szBuffer[2]);
            }
        }
    }

    
fclose(fp);
    return 
1;
}

/* ML from AMXX 1.8.3 support */
#define register_dictionary register_dictionary_colored 
«Очень хорошо. Лучше вы, чем я» © Donald J. Trump
Аватара пользователя
Subb98
Модератор
 
Сообщения: 5485
Зарегистрирован: 24 мар 2011, 19:42
Откуда: г. Пермь
Благодарил (а): 1329 раз.
Поблагодарили: 2343 раз.
Опыт программирования: Больше трех лет
Языки программирования: PHP


Вернуться в Вопросы по AMXX и его плагинам

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 6