Урезание Слов в плагине Chat Colour Menu

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
81
Реакции
24
Ошибка
Не полные слова в меню
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5249 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Jun 19 2019 13:31:53
Built from: https://github.com/alliedmodders/amxmodx/commit/6cecb34
Build ID: 5249:6cecb34
Core mode: JIT+ASM32
Билд
ReHLDS version: 3.4.0.639-dev
Build date: 17:47:13 Feb 21 2018 (1411)
Build from: https://github.com/dreamstalker/rehlds/commit/822df9a
ReGamedll
Отсутствует
Версия Metamod
Metamod-r v1.3.0.106, API (5:13)
Metamod-r build: 18:46:29 Jan 26 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/80555d
Список метамодулей
description   stat pend  file                      vers         src  load  unload
[ 1] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5249 ini Start ANY
[ 2] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5249 pl1 ANY ANY
[ 3] CSX RUN - csx_amxx_i386.so v1.9.0.5249 pl1 ANY ANY
3 plugins, 3 running
Список плагинов
name                    version     author            file             status   
[ 1] Admin Base 1.9.0.5249 AMXX Dev Team admin.amxx running
[ 2] Admin Commands 1.9.0.5249 AMXX Dev Team admincmd.amxx running
[ 3] Admin Help 1.9.0.5249 AMXX Dev Team adminhelp.amxx running
[ 4] Slots Reservation 1.9.0.5249 AMXX Dev Team adminslots.amxx running
[ 5] Multi-Lingual System 1.9.0.5249 AMXX Dev Team multilingual.am running
[ 6] Menus Front-End 1.9.0.5249 AMXX Dev Team menufront.amxx running
[ 7] Commands Menu 1.9.0.5249 AMXX Dev Team cmdmenu.amxx running
[ 8] Players Menu 1.9.0.5249 AMXX Dev Team plmenu.amxx running
[ 9] Maps Menu 1.9.0.5249 AMXX Dev Team mapsmenu.amxx running
[ 10] Plugin Menu 1.9.0.5249 AMXX Dev Team pluginmenu.amxx running
[ 11] Admin Chat 1.9.0.5249 AMXX Dev Team adminchat.amxx running
[ 12] Anti Flood 1.9.0.5249 AMXX Dev Team antiflood.amxx running
[ 13] Scrolling Message 1.9.0.5249 AMXX Dev Team scrollmsg.amxx running
[ 14] Info. Messages 1.9.0.5249 AMXX Dev Team imessage.amxx running
[ 15] Admin Votes 1.9.0.5249 AMXX Dev Team adminvote.amxx running
[ 16] NextMap 1.9.0.5249 AMXX Dev Team nextmap.amxx running
[ 17] Nextmap Chooser 1.9.0.5249 AMXX Dev Team mapchooser.amxx running
[ 18] TimeLeft 1.9.0.5249 AMXX Dev Team timeleft.amxx running
[ 19] Pause Plugins 1.9.0.5249 AMXX Dev Team pausecfg.amxx running
[ 20] Stats Configuration 1.9.0.5249 AMXX Dev Team statscfg.amxx running
[ 21] StatsX 1.9.0.5249 AMXX Dev Team statsx.amxx running
[ 22] Chat Colour Menu 1.50 shadow.hk colourmenu.amxx running
22 plugins, 22 running
Автор плагина
shadow.hk
Версия плагина
1.50
Исходный код
#pragma semicolon 1

// Includes
////////////

#include <amxmodx>
#include <amxmisc>

// Defines
////////////

#define MAX_PLAYERS 32

// Arrays
////////////

new Array:g_aColourName;
new Array:g_aColourSettings;

// Integers
////////////

new g_iColour[MAX_PLAYERS+1][3];
new g_iCustomColour[MAX_PLAYERS+1][3];

new g_iTemp[MAX_PLAYERS+1];
new g_iMenuPage[MAX_PLAYERS+1];

new g_iMaxColours;

//////////////////////////////////////////////////////////////
// Plugin Forwards //
//////////////////////////////////////////////////////////////

public plugin_init()
{
register_plugin("Chat Colour Menu", "1.50", "shadow.hk");

register_dictionary("common.txt");
register_dictionary("colourmenu.txt");

register_clcmd("say /colours", "ColourMenu");
register_clcmd("say colours", "ColourMenu");

register_clcmd("colour_value", "cmdColourValue", -1, "<value>");

register_menucmd(register_menuid("Chat Colour Menu"), 1023, "ColourMenu_handler");
register_menucmd(register_menuid("Custom Colour Menu"), 1023, "CustomMenu_handler");
}

public plugin_cfg()
{
g_aColourName = ArrayCreate(16);
g_aColourSettings = ArrayCreate(3);

new configsdir[32], file[64];
get_configsdir(configsdir, 31);
format(file, 63, "%s/colours.ini", configsdir);

LoadFile(file);
}

//////////////////////////////////////////////////////////////
// Client Forwards //
//////////////////////////////////////////////////////////////

public client_putinserver(id)
{
g_iCustomColour[id] = { 0, 0, 0 };
set_task(0.5, "taskColours", id);
}

//////////////////////////////////////////////////////////////
// Commands //
//////////////////////////////////////////////////////////////

public cmdColourValue(id)
{
new szArg[4];
read_argv(1, szArg, 3);

if( !is_str_num(szArg) )
{
return PLUGIN_HANDLED;
}

g_iCustomColour[id][g_iTemp[id]] = clamp(str_to_num(szArg), 0, 255);

CustomMenu(id);
return PLUGIN_HANDLED;
}

//////////////////////////////////////////////////////////////
// Menus & Menu Handlers //
//////////////////////////////////////////////////////////////

// taken from alka's voteban source code
public ColourMenu(id, iPos)
{
static i, iKeys, szMenu[512], iCurrPos;
iCurrPos = 0;

static iStart, iEnd;
iStart = iPos * 6;

static iPages;
iPages = floatround(float(g_iMaxColours) / 6.0, floatround_ceil);

iEnd = iStart + 6;
iKeys = ( MENU_KEY_0 | MENU_KEY_7 | MENU_KEY_8 );

if( iEnd > g_iMaxColours )
{
iEnd = g_iMaxColours;
}

// heading
static iLen;
iLen = formatex(szMenu, sizeof(szMenu) - 1, "\y%L (\w%i/%i\y):^n^n", id, "MENU_COLOUR", g_iMenuPage[id] + 1, iPages);

// colour keys
for(i = iStart; i < iEnd; i++)
{
iKeys |= ( 1<<iCurrPos++ );
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r%d. \w%a^n", iCurrPos, ArrayGetStringHandle(g_aColourName, i));
}

iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r7. \y%L", id, "MENU_CUSTOM");
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r8. \y%L^n", id, "COLOUR_DEFAULT");

// forward key
if( iEnd == g_iMaxColours )
{
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r9. \d%L", id, "MORE");
}
else
{
iKeys |= MENU_KEY_9;
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r9. \w%L", id, "MORE");
}

// exit key
if( !g_iMenuPage[id] )
{
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r0. \w%L", id, "EXIT");
}
else
{
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "^n\r0. \w%L", id, "BACK");
}

show_menu(id, iKeys, szMenu, -1, "Chat Colour Menu");
return PLUGIN_HANDLED;
}

public ColourMenu_handler(id, key)
{
switch( key )
{
case 6:
{
CustomMenu(id);
return PLUGIN_HANDLED;
}
case 7:
{
client_cmd(id, "con_color ^"%i %i %i^"", g_iColour[id][0], g_iColour[id][1], g_iColour[id][2]);
client_print(id, print_chat, "[CC] %L %L", id, "COLOUR_SET", id, "COLOUR_DEFAULT");
}
case 8: ++g_iMenuPage[id];
case 9:
{
if( !g_iMenuPage[id] )
{
return PLUGIN_HANDLED;
}

--g_iMenuPage[id];
}
default:
{
static colour, colours[3];
colour = ( g_iMenuPage[id] * 6 + key );

ArrayGetArray(g_aColourSettings, colour, colours);

client_cmd(id, "con_color ^"%i %i %i^"", colours[0], colours[1], colours[2]);
client_print(id, print_chat, "[CC] %L %a", id, "COLOUR_SET", ArrayGetStringHandle(g_aColourName, colour));
}
}

ColourMenu(id, g_iMenuPage[id]);
return PLUGIN_HANDLED;
}

public CustomMenu(id)
{
new iLen, szMenu[256], iKeys;
iKeys = ( MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_8 | MENU_KEY_9 );

iLen = formatex(szMenu, sizeof(szMenu) - 1, "\y%L:^n^n", id, "MENU_CUSTOM");

iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r1. \w%L: \y%i^n", id, "RED", g_iCustomColour[id][0]);
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r2. \w%L: \y%i^n", id, "GREEN", g_iCustomColour[id][1]);
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r3. \w%L: \y%i^n^n", id, "BLUE", g_iCustomColour[id][2]);

iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r8. \y%L^n", id, "CUSTOM_SET");
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r9. \w%L^n", id, "BACK");
iLen += formatex(szMenu[iLen], sizeof(szMenu) - 1 - iLen, "\r0. \w%L", id, "EXIT");

show_menu(id, iKeys, szMenu, -1, "Custom Colour Menu");
return PLUGIN_HANDLED;
}

public CustomMenu_handler(id, key)
{
switch( key )
{
case 0, 1, 2:
{
g_iTemp[id] = key;

client_cmd(id, "messagemode colour_value");
client_print(id, print_chat, "[CC] %L", id, "CUSTOM_VALUE");
}

case 7:
{
CustomMenu(id);

client_cmd(id, "con_color ^"%i %i %i^"", g_iCustomColour[id][0], g_iCustomColour[id][1], g_iCustomColour[id][2]);
client_print(id, print_chat, "[CC] %L ^"%i %i %i^"", id, "COLOUR_SET", g_iCustomColour[id][0], g_iCustomColour[id][1], g_iCustomColour[id][2]);
}
case 8: ColourMenu(id, g_iMenuPage[id]);
case 9: g_iMenuPage[id] = 0;
}

return PLUGIN_HANDLED;
}

//////////////////////////////////////////////////////////////
// Tasks //
//////////////////////////////////////////////////////////////

public taskColours(id)
{
query_client_cvar(id, "con_color", "fwdConColour");
}

//////////////////////////////////////////////////////////////
// Miscellaneous Forwards //
//////////////////////////////////////////////////////////////

public fwdConColour(id, const cvar[], const value[])
{
new colour[12];
copy(colour, 11, value);

if( contain(colour, "+") != -1 )
{
replace_all(colour, 11, "+", " ");
}

new szData[3][4];
parse(colour, szData[0], 3, szData[1], 3, szData[2], 3);

g_iColour[id][0] = clamp(str_to_num(szData[0]), 0, 255);
g_iColour[id][1] = clamp(str_to_num(szData[1]), 0, 255);
g_iColour[id][2] = clamp(str_to_num(szData[2]), 0, 255);
}

//////////////////////////////////////////////////////////////
// File Data //
//////////////////////////////////////////////////////////////

// Load Colour File
LoadFile(const file[])
{
// Create a default file, if it doesn't exist
if( !file_exists(file) )
{
write_file(file, "; Colours Configuration file^n; Usage: <Colourname> <red> <green> <blue>^n^"CS Default^" 255 180 30");

ArrayPushString(g_aColourName, "CS Default");
ArrayPushArray(g_aColourSettings, { 255, 180, 30 });

g_iMaxColours = 1;

log_amx("%L", LANG_SERVER, "LOG_ERROR");
return;
}

new szLine[64], szData[3][4], szColourName[16], colours[3];

new File = fopen(file, "r");

while( !feof(File) )
{
fgets(File, szLine, 63);
trim(szLine);

if( !szLine[0] || szLine[0] == '^n' || szLine[0] == ';' )
{
continue;
}

parse(szLine, szColourName, 15, szData[0], 3, szData[1], 3, szData[2], 3);

colours[0] = clamp(str_to_num(szData[0]), 0, 255);
colours[1] = clamp(str_to_num(szData[1]), 0, 255);
colours[2] = clamp(str_to_num(szData[2]), 0, 255);

ArrayPushArray(g_aColourSettings, colours);
ArrayPushString(g_aColourName, szColourName);
}

fclose(File);

g_iMaxColours = ArraySize(g_aColourName);

log_amx("%L", LANG_SERVER, "LOG_LOADED", g_iMaxColours);
}
Решил использовать этот https://forums.alliedmods.net/showthread.php?p=956608 Единственная проблема то что он не полный текст пишет. Помогите исправить. Так понимаю это из за того что символы русские. Есть вообще возможность увеличить лимит на знаки?

Скриншот 08-09-2019 195813.pngСкриншот 08-09-2019 200136.png
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
333
Реакции
290
Помог
9 раз(а)
sas333,
C++:
- g_aColourName = ArrayCreate(16);
+ g_aColourName = ArrayCreate(32);
 
Сообщения
333
Реакции
290
Помог
9 раз(а)
sas333,
C++:
LoadFile(const file[])
{
    // Create a default file, if it doesn't exist
    if( !file_exists(file) )
    {
        write_file(file, "; Colours Configuration file^n; Usage: <Colourname> <red> <green> <blue>^n^"CS Default^" 255 180 30");
      
        ArrayPushString(g_aColourName, "CS Default");
        ArrayPushArray(g_aColourSettings, { 255, 180, 30 });
      
        g_iMaxColours = 1;
      
        log_amx("%L", LANG_SERVER, "LOG_ERROR");
        return;
    }
  
-   new szLine[64], szData[3][4], szColourName[16], colours[3];
+    new szLine[64], szData[3][4], szColourName[32], colours[3];
  
    new File = fopen(file, "r");
  
    while( !feof(File) )
    {
        fgets(File, szLine, 63);
        trim(szLine);
      
        if( !szLine[0] || szLine[0] == '^n' || szLine[0] == ';' )
        {
            continue;
        }
      
-        parse(szLine, szColourName, 15, szData[0], 3, szData[1], 3, szData[2], 3);
+        parse(szLine, szColourName, 31, szData[0], 3, szData[1], 3, szData[2], 3);
      
        colours[0] = clamp(str_to_num(szData[0]), 0, 255);
        colours[1] = clamp(str_to_num(szData[1]), 0, 255);
        colours[2] = clamp(str_to_num(szData[2]), 0, 255);
      
        ArrayPushArray(g_aColourSettings, colours);
        ArrayPushString(g_aColourName, szColourName);
    }
  
    fclose(File);
  
    g_iMaxColours = ArraySize(g_aColourName);
  
    log_amx("%L", LANG_SERVER, "LOG_LOADED", g_iMaxColours);
}
 
Сообщения
81
Реакции
24
zhorzh78, Работает. Единствнное что зелёный цвет почему то в меню не пишет. Точнее первый пункт на второй странице пустой и когда нажимаешь, он вроде как цвет меняет, но в чате тоже пишет не полностью. На скриншоте видно

Скриншот 09-09-2019 232439.pngСкриншот 09-09-2019 232522.png
 
Последнее редактирование:
Сообщения
81
Реакции
24
Можно закрывать. Нашёл ошибку. Для тех кому это интересно её можно увидеть на скриншоте. (Для внимательных) Не таких как я))

Скриншот 09-09-2019 232522.png
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу