1)Создаем файлы war3ft_cmd.h и war3ft_cmd.inl
2)Открываем .sma файл и подключаем их
Код
#include "war3ft/war3ft_cmd.h"
#include "war3ft/war3ft_cmd.inl"
3)Заходим .sma
изменяем
Код
register_clcmd( "shopmenu" , "CMD_Handler" , -1 );
register_clcmd( "shopmenu2" , "CMD_Handler" , -1 );
На
Код
register_clcmd( g_szCommand_Shop[CMD_SHOPMENU_1] , "CMD_Handler" , -1 );
register_clcmd( g_szCommand_Shop[CMD_SHOPMENU_2] , "CMD_Handler" , -1 );
4)Далее находим plugin_precache()
Ниже добавляем
Get_War3ft_Commands()
5)Идем в Clientcommands.inl и ищем shopmenu и shopmenu2
Заменяем shopmenu на g_szCommand_Shop[CMD_SHOPMENU_1]
Заменяем shopmenu2 на g_szCommand_Shop[CMD_SHOPMENU_2]
6)Открываем
и добавляем
Код
#define CMD_FILE "/addons/amxmodx/configs/war3ft/cmd_option.ini"
#define MAX_CMD 2
#define MAX_LENGTH 20
new g_szCommand_Shop[MAX_CMD][MAX_LENGTH]
#define CMD_SHOPMENU_1 0
#define CMD_SHOPMENU_2 1
7)Открываем war3ft_cmd.inl
и добавляем
Код
public Get_War3ft_Commands()
{
new path[64]
format(path, charsmax(path), "%s",CMD_FILE)
if (!file_exists(path))
{
new error[100]
formatex(error, charsmax(error), "Cannot load cmd file %s!", path)
set_fail_state(error)
return;
}
new linedata[1024], key[64], value[600], section
new file = fopen(path, "rt")
while (file && !feof(file))
{
fgets(file, linedata, 1023)
replace(linedata, 1023, "^n", "")
if (!linedata[0] || linedata[0] == ';') continue;
if (linedata[0] == '[')
{
section++
continue;
}
strtok(linedata, key, charsmax(key), value, 599, '=')
trim(key)
trim(value)
switch (section)
{
case 1:
{
if (equal(key, "SHOPMENU_1"))
format(g_szCommand_Shop[CMD_SHOPMENU_1],MAX_LENGTH-1,"%s",value)
else if (equal(key, "SHOPMENU_2"))
format(g_szCommand_Shop[CMD_SHOPMENU_2],MAX_LENGTH-1,"%s",value)
}
}
}
if (file) fclose(file)
}
8)Компилируем,заливаем.
9)Создаем cmd_option.ini(в соотв.директории)
Содержимое
Код
[Shopmenu Commands]
SHOPMENU_1 = shopmenu1
SHOPMENU_2 = shopmenu2
P.S Все вспоминаю,практика.