搜索
查看: 3053|回复: 3

[AMXX 带源码] 自动绑定键值

[复制链接]
发表于 2013-2-4 09:26:29 | 显示全部楼层 |阅读模式 来自 中国–山东–淄博
  1. #include <amxmodx>

  2. #define autobindMenuKeys (1<<0)|(1<<1)|(1<<2)
  3. #define PLUGIN "Autobinds"
  4. #define VERSION "1.2"
  5. #define AUTHOR "CLLlAgOB"
  6. #define MAX_STRING_LEN 256
  7. #define MAX_LINES 64

  8. new help_dir,bind_ver
  9. new key_set[MAX_LINES][MAX_STRING_LEN]
  10. new key_command[MAX_LINES][MAX_STRING_LEN]

  11. public plugin_init(){
  12.         register_plugin(PLUGIN, VERSION, AUTHOR)
  13.         register_menucmd(register_menuid("自动绑定菜单"), autobindMenuKeys, "autobindmenu")
  14.         help_dir = register_cvar("auto_helpdir","/addons/amxmodx/configs/keyhelp.txt")
  15.         bind_ver = register_cvar("auto_ver","v1.1")
  16.         //这个参数要在你改变键值绑定时 改变,否则 不会改变上次已经绑定好的客户端的键值
  17.         load_settings("addons/amxmodx/configs/keys.ini")
  18.         register_event("TeamInfo", "task_premenu", "b")
  19. }

  20. public task_premenu(id)
  21.         set_task(10.0,"task_autobindmenu",id)

  22. public task_autobindmenu(id) {
  23.         new crate[33],ver[33]  
  24.         get_user_info(id,"autobind",crate,32)
  25.         get_cvar_string("auto_ver",ver,31)
  26.         if(!equali(crate, ver)){
  27.                 show_menu(id, autobindMenuKeys, "\r自动绑定菜单^n\w^n1. 自动绑定我!^n2. 帮助 (关于键值)  ^n3. 不要自动绑定^n", -1, "");
  28.                 return PLUGIN_HANDLED;
  29.         }
  30.         return PLUGIN_HANDLED;
  31. }


  32. load_settings(szFilename[]) {
  33.         if (!file_exists(szFilename))
  34.                 return 0
  35.         new num = 0
  36.         new szText[MAX_STRING_LEN], setbuttn[MAX_STRING_LEN], setcommand[MAX_STRING_LEN]
  37.         new a, pos = 0
  38.         while (num < MAX_LINES && read_file(szFilename, pos++, szText, sizeof(szText), a)) {         
  39.                 if (szText[0] == ';' || szText[0] == '#')
  40.                         continue
  41.                 if (parse(szText,setbuttn,sizeof(setbuttn),setcommand,sizeof(setcommand)) < 2)
  42.                         continue

  43.                 copy(key_set[num], MAX_STRING_LEN - 1, setbuttn)
  44.                 copy(key_command[num], MAX_STRING_LEN - 1, setcommand)
  45.                 num++
  46.         }
  47.         return 1
  48. }
  49. public autobindmenu(id, key) {
  50.         switch (key) {
  51.                 case 0: func_autobind(id);
  52.                 case 1: {
  53.                         autobind_help(id);
  54.                         task_autobindmenu(id);
  55.                         }
  56.                 case 2: return PLUGIN_HANDLED;
  57.         }
  58.         return PLUGIN_HANDLED;
  59. }
  60. ///---------------[Help]
  61. public autobind_help(id)
  62. {
  63.         new dir[129]
  64.         get_pcvar_string(help_dir,dir,128)
  65.         show_motd(id, dir,"键值帮助")
  66. }

  67. //---------------[AUTO BIND SYSTEM]---------------

  68. public func_autobind(id)
  69. {
  70.         for (new i = 0; i <= (MAX_LINES-1); i++) {
  71.                 if(key_set[i][0]){
  72.                         client_cmd(id,"bind  %s ^"%s^"",key_set[i],key_command[i])
  73.                         }
  74.         }
  75.         new ver[129]
  76.         get_pcvar_string(bind_ver,ver,128)
  77.         client_cmd(id," setinfo autobind %s",ver)
  78.         console_print(id,"键值默认已经绑定. 欢迎加入玩得愉快!")
  79.         return PLUGIN_HANDLED
  80. }
复制代码
 楼主| 发表于 2013-2-4 10:07:19 | 显示全部楼层 来自 中国–山东–淄博
另一套,合用更加


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

发表于 2013-2-7 13:39:49 | 显示全部楼层 来自 中国–山东
帮顶一下也下来看看
回复

使用道具 举报

发表于 2013-12-1 21:18:42 | 显示全部楼层 来自 中国–辽宁–鞍山
这个 是自动说命令还是什么?????????
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表