Инфо из amxmodx.inc:
/* Registers function which will be called from client console.
* Set FlagManager to 1 to make FlagManager always include this command
* Set FlagManager to 0 to make FlagManager never include this command
* Returns the command ID.
*/
native register_clcmd(const client_cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
Синтаксис:
register_clcmd ( const client_cmd[],const function[],flags=-1, info[]="" )
register_clcmd("amx_mycommand","MyFunction",ADMIN_KICK,"Description of the command")
register_clcmd("amx_mycommand","MyFunction",ADMIN_KICK,"Description of the command")
Description of the command - Добавляет информацию к команде.
Пример:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Register client cmd"
#define VERSION "1.0"
#define AUTHOR "Admin"
new Handle:SQL_Tuple
new Handle:SQL_Connection // Открытие соединения с базой данных
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("testcmd","you_cmd")
register_clcmd("say /testcmd","you_cmd",_,"test command")
}
public you_cmd(id){
//Add you code
client_print(id,print_chat,"You first command")
}
Данный пример регистрирует 2 команды:
- say /testcmd - Можно выполнить как в консоле, так и в чате написать /testcmd
- testcmd - Выолняется только в консоле
Список админских флагов доступа:
#define ADMIN_ALL 0 //Everyone
#define ADMIN_IMMUNITY 1 //Flag "a", immunity
#define ADMIN_RESERVATION 2 //Flag "b", reservation
#define ADMIN_KICK 4 //Flag "c", kick
#define ADMIN_BAN 8 //Flag "d", ban
#define ADMIN_SLAY 16 //Flag "e", slay
#define ADMIN_MAP 32 //Flag "f", map change
#define ADMIN_CVAR 64 //Flag "g", cvar change
#define ADMIN_CFG 128 //Flag "h", config execution
#define ADMIN_CHAT 256 //Flag "i", chat
#define ADMIN_VOTE 512 //Flag "j", vote
#define ADMIN_PASSWORD 1024 //Flag "k", sv_password
#define ADMIN_RCON 2048 //Flag "l", rcon access
#define ADMIN_LEVEL_A 4096 //Flag "m", custom
#define ADMIN_LEVEL_B 8192 //Flag "n", custom
#define ADMIN_LEVEL_C 16384 //Flag "o", custom
#define ADMIN_LEVEL_D 32768 //Flag "p", custom
#define ADMIN_LEVEL_E 65536 //Flag "q", custom
#define ADMIN_LEVEL_F 131072 //Flag "r", custom
#define ADMIN_LEVEL_G 262144 //Flag "s", custom
#define ADMIN_LEVEL_H 524288 //Flag "t", custom
#define ADMIN_MENU 1048576 //Flag "u", menus
#define ADMIN_ADMIN 16777216 //Flag "y", default admin
#define ADMIN_USER 33554432 //Flag "z", default user
#define FLAG_KICK 1 //Auth flag "a", kick if no auth
#define FLAG_TAG 2 //Auth flag "b", auth by tag
#define FLAG_AUTHID 4 //Auth flag "c", auth by WON/Steam ID
#define FLAG_IP 8 //Auth flag "d", auth by IP address
#define FLAG_NOPASS 16 //Auth flag "e", don't require password
ADMIN_USER