Заказать игровой сервер Контакты (заказать плагин/исправить ошибки/другое) Поиск

[ вход ]
[ последние сообщения ]

  • Страница 1 из 1
  • 1
Форум » SourceMod >> CS:Source >> CSGO » Обсуждение » Проблемы с выводом текста в чат
Проблемы с выводом текста в чат
BlackHead1673 Дата: Пятница, 16.06.2023, 01:07:01 | Сообщение # 1
Сообщений: 18
Репутация: 0 [ +/- ]
У меня в чат выводит такое сообщение: ���������� Skazka
Это из-за кодировки, или из-за чего ?

Код
        char str[32] = {"Артур Skazka"};
        char color[9][10] = {{"{red}"}, {"{blue}"}, {"{purple}"}, {"{yellow}"}, {"{gray}"}, {"{black}"}, {"{green}"}, {"{cyan}"}, {"{brown}"}};
        char output[256] = "";
        for (int i = 0; i < strlen(str); i++)
        {
            int xxx = i % 5;
            FormatEx(output, sizeof(output), "%s%s%c", output, color[xxx], str[i]);
        }
        MC_PrintToChat(client, "%s", output);

Гости не могут скачивать файлы


Сообщение отредактировал BlackHead1673 - Пятница, 16.06.2023, 01:08:57
 
ggsanhon Дата: Вторник, 27.06.2023, 09:21:47 | Сообщение # 2
Сообщений: 3
Репутация: 0 [ +/- ]
возможно игра или сервер не воспринимает такую кодировку
 
BlackHead1673 Дата: Понедельник, 03.07.2023, 02:14:20 | Сообщение # 3
Сообщений: 18
Репутация: 0 [ +/- ]
Если для кого-то это актуально, то вот как получилось решить проблему
Код
#include <clientmod>
#include <clientmod/multicolors>

char cColor[9][] = {
    "{indigo}",
    "{darkmagenta}",
    "{purple}",
    "{valve}",
    "{darkviolet}",
    "{blueviolet}",
    "{mediumorchid}",
    "{magenta}",
    "{legendary}"
};

public void OnPluginStart() {
    RegConsoleCmd("say", cmd_say);
}

public Action cmd_say(int client, int args){
    char Nick[64];
    char GetText[512];
            
    GetClientName(client, Nick, sizeof(Nick));
    GetCmdArgString(GetText, sizeof(GetText));
    StripQuotes(GetText);

    if (client)
    {
        char CustomText[512];
        FormatText(CustomText, sizeof(CustomText), Nick);
        MC_PrintToChatAll("%s:{default} %s", CustomText, GetText);
    }
    return Plugin_Handled;
}

public void FormatText(char[] cResult, int iMaxSize, const char[] text) {
    int iCount = 0;
    int SizeText = strlen(text);
    int iResIndex = 0;

    for (int i = 0; i < SizeText;)
    {
        int sym = text[i] & 0xFF;
        int bytes = 0;

        if ((sym & 0x80) == 0)
            bytes = 1;
        else if ((sym & 0xE0) == 0xC0)
            bytes = 2;
        else if ((sym & 0xF0) == 0xE0)
            bytes = 3;
        else if ((sym & 0xF8) == 0xF0)
            bytes = 4;
        else
            break;

        if (text[i] != ' ')
        {
            for (int j = 0; j < strlen(cColor[iCount % 9]); ++j)
            {
                cResult[iResIndex] = cColor[iCount % 9][j];
                iResIndex++;
            }
        }

        for (int j = 0; j < bytes; ++j)
        {
            cResult[iResIndex] = text[i + j];
            iResIndex++;
        }

        i += bytes;
        iCount++;
    }

    cResult[iResIndex] = '\0';

    for (int i = 0; i < iResIndex && i < iMaxSize - 1; ++i)
        cResult[i] = cResult[i];

    cResult[iMaxSize-1] = '\0';
}

Гости не могут скачивать файлы


Сообщение отредактировал BlackHead1673 - Понедельник, 03.07.2023, 02:16:17
 
Форум » SourceMod >> CS:Source >> CSGO » Обсуждение » Проблемы с выводом текста в чат
  • Страница 1 из 1
  • 1
Поиск: