自动绑定键值
#include <amxmodx>#define autobindMenuKeys (1<<0)|(1<<1)|(1<<2)
#define PLUGIN "Autobinds"
#define VERSION "1.2"
#define AUTHOR "CLLlAgOB"
#define MAX_STRING_LEN 256
#define MAX_LINES 64
new help_dir,bind_ver
new key_set
new key_command
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR)
register_menucmd(register_menuid("自动绑定菜单"), autobindMenuKeys, "autobindmenu")
help_dir = register_cvar("auto_helpdir","/addons/amxmodx/configs/keyhelp.txt")
bind_ver = register_cvar("auto_ver","v1.1")
//这个参数要在你改变键值绑定时 改变,否则 不会改变上次已经绑定好的客户端的键值
load_settings("addons/amxmodx/configs/keys.ini")
register_event("TeamInfo", "task_premenu", "b")
}
public task_premenu(id)
set_task(10.0,"task_autobindmenu",id)
public task_autobindmenu(id) {
new crate,ver
get_user_info(id,"autobind",crate,32)
get_cvar_string("auto_ver",ver,31)
if(!equali(crate, ver)){
show_menu(id, autobindMenuKeys, "\r自动绑定菜单^n\w^n1. 自动绑定我!^n2. 帮助 (关于键值)^n3. 不要自动绑定^n", -1, "");
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
load_settings(szFilename[]) {
if (!file_exists(szFilename))
return 0
new num = 0
new szText, setbuttn, setcommand
new a, pos = 0
while (num < MAX_LINES && read_file(szFilename, pos++, szText, sizeof(szText), a)) {
if (szText == ';' || szText == '#')
continue
if (parse(szText,setbuttn,sizeof(setbuttn),setcommand,sizeof(setcommand)) < 2)
continue
copy(key_set, MAX_STRING_LEN - 1, setbuttn)
copy(key_command, MAX_STRING_LEN - 1, setcommand)
num++
}
return 1
}
public autobindmenu(id, key) {
switch (key) {
case 0: func_autobind(id);
case 1: {
autobind_help(id);
task_autobindmenu(id);
}
case 2: return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
///---------------
public autobind_help(id)
{
new dir
get_pcvar_string(help_dir,dir,128)
show_motd(id, dir,"键值帮助")
}
//------------------------------
public func_autobind(id)
{
for (new i = 0; i <= (MAX_LINES-1); i++) {
if(key_set){
client_cmd(id,"bind%s ^"%s^"",key_set,key_command)
}
}
new ver
get_pcvar_string(bind_ver,ver,128)
client_cmd(id," setinfo autobind %s",ver)
console_print(id,"键值默认已经绑定. 欢迎加入玩得愉快!")
return PLUGIN_HANDLED
} 另一套,合用更加
帮顶一下也下来看看 这个 是自动说命令还是什么?????????
页:
[1]