Spoiler
#include <amxmodx> #define AUTHOR "aSior - amxx.pl/user/60210-asiorr/" #define MAX_PLAYERS 32 #define ForArray(%1,%2) for(new %1 = 0; %1 < sizeof %2; %1++) new const messagemodeCommands[][][] = { { "Wpisz_rcon", "enterRconPassword" } }; new const menuCommands[][] = { "/menu" }; new const menuItems[][] = { "Kickuj gracza", "Banuj gracza" }; new userAccess[MAX_PLAYERS + 1]; public plugin_init() { register_plugin("x", "v0.1", AUTHOR); ForArray(i, messagemodeCommands) { register_clcmd(messagemodeCommands[i][0], messagemodeCommands[i][1]); } registerCommands(menuCommands, sizeof(menuCommands), "showMenu"); } public client_authorized(index) { userAccess[index] = false; } public enterRconPassword(index) { new enteredPassword[33], rconPassword[33]; read_argv(1, enteredPassword, charsmax(enteredPassword)); get_cvar_string("rcon_password", rconPassword, charsmax(rconPassword)); userAccess[index] = equal(enteredPassword, rconPassword); if(userAccess[index]) { showMenu(index); } return PLUGIN_HANDLED; } public showMenu(index) { if(!userAccess[index]) { enterPassword(index); return PLUGIN_HANDLED; } new menuIndex = menu_create("Menu:", "showMenu_handler"); ForArray(i, menuItems) { menu_additem(menuIndex, menuItems[i]); } menu_display(index, menuIndex); return PLUGIN_HANDLED; } public showMenu_handler(id, menu, item) { menu_destroy(menu); if(item == MENU_EXIT) { return PLUGIN_HANDLED; } /* Body */ return PLUGIN_HANDLED; } enterPassword(index) { client_cmd(index, "messagemode Wpisz_rcon"); } stock registerCommands(const array[][], arraySize, function[]) { #if !defined ForRange #define ForRange(%1,%2,%3) for(new %1 = %2; %1 <= %3; %1++) #endif new newCommand[33]; ForRange(i, 0, arraySize - 1) { ForRange(j, 0, 1) { formatex(newCommand, charsmax(newCommand), "%s %s", !j ? "say" : "say_team", array[i]); register_clcmd(newCommand, function); } } }