Т.к. многие не знаю как делать бинды на различные стим\нон стим кс, то способ для вас
Ну приступим
Credist:
ConnorMcLeod
Используемые инклюды:
[pawn]
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fakemeta>
Для начала зарегистрируем две функции для Show и VGUI меню:
[pawn]
- register_message(get_user_msgid("ShowMenu"), "MessageShowMenu");
- register_message(get_user_msgid("VGUIMenu"), "MessageVGUIMenu");
Это есть, далее конечно же, сами паблики.
Вот такой код будет иметь паблик MessageShowMenu:
[pawn]
- public MessageShowMenu(iMsgID, iDest, id) {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- static iMenuCode[21];
- get_msg_arg_string(4, iMenuCode, charsmax(iMenuCode));
- switch(iMenuCode[1]) {
- case 'T': {
- set_pdata_int(id, 205, 0);
- return ClCmd_JoinMenu(id);
- }
- case 'I': {
- set_pdata_int(id, 205, 0);
- if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return ClCmd_JoinMenu(id);
- else
- return ClCmd_MainMenu(id);
- }
- }
- return PLUGIN_HANDLED;
- }
Расписывать каждую строчку не буду, объясню вкратце.
При заходе на сервер, вам покажет меню "Выбора команд", т.к. команда ваша будет UNASSIGNED, далее после выбора команды и нажатия на М, вы увидите "Игровое меню", т.к. ваша команде не UNASSIGNED и не SPECTATOR. Если же, вы зайдёте за SPECTATOR, то вы увидите не "Главное меню", а меню "Выбор команды".
Далее следует паблик VGUI меню:
[pawn]
- public MessageVGUIMenu(iMsgID, iDest, id) {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- switch(get_msg_arg_int(1)) {
- case 2: {
- if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return ClCmd_JoinMenu(id);
- else
- return ClCmd_MainMenu(id);
- }
- default: return PLUGIN_HANDLED;
- }
- return PLUGIN_HANDLED;
- }
Здесь аналогично. Расписывать нет смысла.
Далее идут сами паблики меню "Выбор команд" и "Игровое меню". Их тоже досконально расписывать не буду:
[pawn]
- public ClCmd_JoinMenu(id) {
- new iMenu[256], iLen;
- new iKeysMenu = MENU_KEY_5|MENU_KEY_0;
- iLen = formatex(iMenu, charsmax(iMenu), "\rВыберите команду:^n^n");
- if(cs_get_user_team(id) == CS_TEAM_T)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d1. Террорист [%d]^n", fnGetPlayerTeam(CS_TEAM_T));
- else {
- iKeysMenu |= MENU_KEY_1;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y1. \wТеррорист \d[%d]^n", fnGetPlayerTeam(CS_TEAM_T));
- }
- if(cs_get_user_team(id) == CS_TEAM_CT)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d2. Контр-Террорист [%d]^n^n", fnGetPlayerTeam(CS_TEAM_CT));
- else {
- iKeysMenu |= MENU_KEY_2;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y2. \wКонтр-Террорист \d[%d]^n^n", fnGetPlayerTeam(CS_TEAM_CT));
- }
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y5. \wАвто-Выбор^n");
- if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d6. Спектатор^n^n");
- else {
- iKeysMenu |= MENU_KEY_6;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y6. \wСпектатор^n^n");
- }
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y0. \wВыход");
- show_menu(id, iKeysMenu, iMenu, -1, "JoinMenu");
- return PLUGIN_HANDLED;
- }
Здесь "Выбор команд". Всё очень просто и понятно, для можористи добавил проверки на команду игрока, чтобы пункт был неактивным, и добавил в пункт меню кол-во игроков, в той или иной команде.
Далее идет паблик handled, обработчик нашего "Выбор команд" меню:
[pawn]
- public handled_JoinMenu(id, iKeys) {
- static iRestore, iVGUI, iMsgBlock;
- iRestore = get_pdata_int(id, 510);
- iVGUI = iRestore & (1<<0);
- if(iVGUI) set_pdata_int(id, 510, iRestore & ~(1<<0));
- switch(iKeys) {
- case 0, 1, 4: {
- if(iKeys <= 1 && (cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT))
- return PLUGIN_HANDLED;
- iMsgBlock = get_msg_block(get_user_msgid("ShowMenu"));
- set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
- engclient_cmd(id, "jointeam", (iKeys == 4 ? "5" : (iKeys == 0 ? "1" : "2")));
- engclient_cmd(id, "joinclass", "5");
- set_msg_block(get_user_msgid("ShowMenu"), iMsgBlock);
- }
- case 5: {
- if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return PLUGIN_HANDLED;
- iMsgBlock = get_msg_block(get_user_msgid("ShowMenu"));
- set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
- dllfunc(DLLFunc_ClientPutInServer, id);
- set_msg_block(get_user_msgid("ShowMenu"), iMsgBlock);
- set_pdata_int(id, 349, 1);
- engclient_cmd(id, "jointeam", "6");
- }
- }
- if(iVGUI) set_pdata_int(id, 510, iRestore);
- set_pdata_int(id, 125, get_pdata_int(id, 125, 5) & ~(1<<8), 5);
- return PLUGIN_HANDLED;
- }
Основная задача, блокировка Show\VGUI меню, добавил еще безлимитный переход между командами, если это не нужно, закоментируйте строку:
[pawn]
- set_pdata_int(id, 125, get_pdata_int(id, 125, 5) & ~(1<<8), 5);
Далее идёт "Игровое меню":
[pawn]
- public ClCmd_MainMenu(id) {
- new iMenu[256], iLen;
- static iKeysMenu = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_0;
- iLen = formatex(iMenu, charsmax(iMenu), "\rИгровое меню:^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y1. \wОбнулить счёт^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y2. \wКупить \rадминку^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y5. \wВыбор команды^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y0. \wВыход");
- show_menu(id, iKeysMenu, iMenu, -1, "MainMenu");
- return PLUGIN_HANDLED;
- }
И обработчик для него:
[pawn]
- public handled_MainMenu(id, iKeys) {
- switch(iKeys) {
- case 0: client_print(id, print_chat, "Вы обнулили счёт");
- case 1: client_print(id, print_chat, "Админка");
- case 4: return ClCmd_JoinMenu(id);
- }
- return PLUGIN_HANDLED;
- }
Так же не забываем зарегистрировать наши меню в plugin_init()
[pawn]
- register_menu("JoinMenu", 563, "handled_JoinMenu");
- register_menu("MainMenu", 531, "handled_MainMenu");
На счёт битов (563 или 531) читайте Вы должны зарегистрироваться, чтобы видеть ссылки.
Ну и сам сток, подсчёта игроков:
[pawn]
- stock fnGetPlayerTeam(CsTeams: iTeam) {
- static iPlayers[32], iNum;
- get_players(iPlayers, iNum, "e", (iTeam == CS_TEAM_T ? "TERRORIST" : "CT"));
- return iNum;
- }
В принципе всё предельно ясно Код рабочий, только что проверял, на обоих меню, всё ок.
Вот финальный код:
[pawn]
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fakemeta>
- #pragma semicolon 1
- #define PLUGIN_NAME "[TUT] Server Menu"
- #define PLUGIN_VERS "1.0"
- #define PLUGIN_AUTH "NIXON"
- public plugin_init() {
- register_plugin(PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH);
- register_message(get_user_msgid("ShowMenu"), "MessageShowMenu");
- register_message(get_user_msgid("VGUIMenu"), "MessageVGUIMenu");
- register_menu("JoinMenu", 563, "handled_JoinMenu");
- register_menu("MainMenu", 531, "handled_MainMenu");
- }
- public MessageShowMenu(iMsgID, iDest, id) {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- static iMenuCode[21];
- get_msg_arg_string(4, iMenuCode, charsmax(iMenuCode));
- switch(iMenuCode[1]) {
- case 'T': {
- set_pdata_int(id, 205, 0);
- return ClCmd_JoinMenu(id);
- }
- case 'I': {
- set_pdata_int(id, 205, 0);
- if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return ClCmd_JoinMenu(id);
- else
- return ClCmd_MainMenu(id);
- }
- }
- return PLUGIN_HANDLED;
- }
- public MessageVGUIMenu(iMsgID, iDest, id) {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- switch(get_msg_arg_int(1)) {
- case 2: {
- if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return ClCmd_JoinMenu(id);
- else
- return ClCmd_MainMenu(id);
- }
- default: return PLUGIN_HANDLED;
- }
- return PLUGIN_HANDLED;
- }
- public ClCmd_JoinMenu(id) {
- new iMenu[256], iLen;
- new iKeysMenu = MENU_KEY_5|MENU_KEY_0;
- iLen = formatex(iMenu, charsmax(iMenu), "\rВыберите команду:^n^n");
- if(cs_get_user_team(id) == CS_TEAM_T)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d1. Террорист [%d]^n", fnGetPlayerTeam(CS_TEAM_T));
- else {
- iKeysMenu |= MENU_KEY_1;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y1. \wТеррорист \d[%d]^n", fnGetPlayerTeam(CS_TEAM_T));
- }
- if(cs_get_user_team(id) == CS_TEAM_CT)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d2. Контр-Террорист [%d]^n^n", fnGetPlayerTeam(CS_TEAM_CT));
- else {
- iKeysMenu |= MENU_KEY_2;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y2. \wКонтр-Террорист \d[%d]^n^n", fnGetPlayerTeam(CS_TEAM_CT));
- }
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y5. \wАвто-Выбор^n");
- if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\d6. Спектатор^n^n");
- else {
- iKeysMenu |= MENU_KEY_6;
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y6. \wСпектатор^n^n");
- }
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y0. \wВыход");
- show_menu(id, iKeysMenu, iMenu, -1, "JoinMenu");
- return PLUGIN_HANDLED;
- }
- public handled_JoinMenu(id, iKeys) {
- static iRestore, iVGUI, iMsgBlock;
- iRestore = get_pdata_int(id, 510);
- iVGUI = iRestore & (1<<0);
- if(iVGUI) set_pdata_int(id, 510, iRestore & ~(1<<0));
- switch(iKeys) {
- case 0, 1, 4: {
- if(iKeys <= 1 && (cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT))
- return PLUGIN_HANDLED;
- iMsgBlock = get_msg_block(get_user_msgid("ShowMenu"));
- set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
- engclient_cmd(id, "jointeam", (iKeys == 4 ? "5" : (iKeys == 0 ? "1" : "2")));
- engclient_cmd(id, "joinclass", "5");
- set_msg_block(get_user_msgid("ShowMenu"), iMsgBlock);
- }
- case 5: {
- if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- return PLUGIN_HANDLED;
- iMsgBlock = get_msg_block(get_user_msgid("ShowMenu"));
- set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
- dllfunc(DLLFunc_ClientPutInServer, id);
- set_msg_block(get_user_msgid("ShowMenu"), iMsgBlock);
- set_pdata_int(id, 349, 1);
- engclient_cmd(id, "jointeam", "6");
- }
- }
- if(iVGUI) set_pdata_int(id, 510, iRestore);
- set_pdata_int(id, 125, get_pdata_int(id, 125, 5) & ~(1<<8), 5);
- return PLUGIN_HANDLED;
- }
- public ClCmd_MainMenu(id) {
- new iMenu[256], iLen;
- static iKeysMenu = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_0;
- iLen = formatex(iMenu, charsmax(iMenu), "\rИгровое меню:^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y1. \wОбнулить счёт^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y2. \wКупить \rадминку^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y5. \wВыбор команды^n^n");
- iLen += formatex(iMenu[iLen], charsmax(iMenu) - iLen, "\y0. \wВыход");
- show_menu(id, iKeysMenu, iMenu, -1, "MainMenu");
- return PLUGIN_HANDLED;
- }
- public handled_MainMenu(id, iKeys) {
- switch(iKeys) {
- case 0: client_print(id, print_chat, "Вы обнулили счёт");
- case 1: client_print(id, print_chat, "Админка");
- case 4: return ClCmd_JoinMenu(id);
- }
- return PLUGIN_HANDLED;
- }
- stock fnGetPlayerTeam(CsTeams: iTeam) {
- static iPlayers[32], iNum;
- get_players(iPlayers, iNum, "e", (iTeam == CS_TEAM_T ? "TERRORIST" : "CT"));
- return iNum;
- }
PS. Может кому-то да пригодится, т.к. много таких тем и пр.
Код не гуру, но зато рабочий
Картиночки:
[spoiler]http://f-picture.net/lfp/s018.radikal.ru/i513/1409/54/25e72cd767c2.jpg/htm
Вы должны зарегистрироваться, чтобы видеть ссылки. ... bb.jpg/htm[/spoiler]