搜索
查看: 3189|回复: 4

求修改CsummzCN.sma分三贴发源码

[复制链接]
发表于 2010-8-13 01:48:49 | 显示全部楼层 |阅读模式 来自 中国–广东–佛山–南海区
本帖最后由 zlove84 于 2010-8-13 01:51 编辑

编译后发现,随便一个玩家也可以让自己穿衣服,求帮忙修改成只有管理员A权限才可以使用
  1.   #include <amxmodx>
  2.   #include <amxmisc>
  3.   #include <cstrike>

  4.   #define MENUTIME 30 // how long menus stay up

  5.   // Key Defines (for ease of use and readability)
  6.   #define KEY1 (1<<0)
  7.   #define KEY2 (1<<1)
  8.   #define KEY3 (1<<2)
  9.   #define KEY4 (1<<3)
  10.   #define KEY5 (1<<4)
  11.   #define KEY6 (1<<5)
  12.   #define KEY7 (1<<6)
  13.   #define KEY8 (1<<7)
  14.   #define KEY9 (1<<8)
  15.   #define KEY0 (1<<9)

  16.   // Temporary Menu Variables
  17.   new page[33] = { 1, ...}, choices[33][9][33], target[33][33];

  18.   // A user's assigned model
  19.   new setmodel[33][33];

  20.   // ------------------------------------------------------------------------------------------
  21.   // --MENU DISPLAYS--------------------------------------------------------------------------
  22.   // ------------------------------------------------------------------------------------------

  23.   // Here are all of our functions for displaying the menus themselves

  24.   // --MENU 1 DISPLAY--------------------------------------------------------------------------
  25.   public menu1Display(id) {

  26.     // choose who to perform actions on

  27.     new menubody[256];
  28.     format(menubody,255,"\y管理员为玩家更换服装菜单 :^n^n");
  29.     add(menubody,255,"\w1. 为所有恐怖份子^n");
  30.     add(menubody,255,"\w2. 为所有反恐精英^n");
  31.     add(menubody,255,"\w3. 为指定玩家^n");
  32.     add(menubody,255,"\w4. 为全部玩家^n");
  33.     add(menubody,255,"\w5. 为你自己^n");
  34.     add(menubody,255,"\w^n0. 退出");

  35.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY5|KEY0,menubody,MENUTIME,"menu1");

  36.     return PLUGIN_HANDLED;
  37.   }

  38.   // --MENU 2 DISPLAY--------------------------------------------------------------------------
  39.   public menu2Display(id) {

  40.     // our list of players

  41.     // clear choices
  42.     for(new n=0;n<9;n++) {
  43.       choices[id][n] = "";
  44.     }

  45.     new menubody[256];
  46.     format(menubody,255,"\y为玩家更换服装  (指定玩家, 第 %d 页):^n^n",page[id]);

  47.     // get players
  48.     new players[32], num;
  49.     get_players(players,num);

  50.     // if too many for one page
  51.     new loopamt = num-((page[id]-1)*8);
  52.     if(num-((page[id]-1)*8) > 8) {
  53.       loopamt = 8;
  54.     }

  55.     new offset = (page[id] * 8) - 8; // starting offset

  56.     // loop through players
  57.     for(new i=offset;i<loopamt+offset;i++) {

  58.       // get name
  59.       new username[33];
  60.       get_user_name(players,username,32);

  61.       // get user's team
  62.       new team[5];
  63.       if(get_user_team(players) == 1) { team = "T"; }
  64.       else if(get_user_team(players) == 2) { team = "CT"; }
  65.       else { team = "SPEC"; }

  66.       // our string to add
  67.       new string[256];
  68.       format(string,255,"\w%d. %s (%s%s)^n",i+1-offset,username,team,is_user_admin(players) ? ",@" : "");

  69.       // get string value of player's id
  70.       new idstr[33];
  71.       num_to_str(players,idstr,32);

  72.       // save player's id for easy access
  73.       choices[id][i-offset] = idstr;

  74.       // add it to menu
  75.       add(menubody,255,string);
  76.     }

  77.     // if another page
  78.     if(num-((page[id]-1)*8) > 8) {
  79.       choices[id][8] = "Next";
  80.       add(menubody,255,"\w^n9. 下一页");
  81.     }

  82.     add(menubody,255,"\w^n0. 返回");

  83.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY5|KEY6|KEY7|KEY8|KEY9|KEY0,menubody,MENUTIME,"menu2");

  84.     return PLUGIN_HANDLED;
  85.   }

  86.   // --MENU 3 DISPLAY--------------------------------------------------------------------------
  87.   public menu3Display(id) {

  88.     // choose what model category to browse in

  89.     new menubody[256];
  90.     format(menubody,255,"\y改变服装为 (请选择某一类型):^n^n");
  91.     add(menubody,255,"\w1. 匪徒服饰^n");
  92.     add(menubody,255,"\w2. 警察服饰^n");
  93.     add(menubody,255,"\w3. 全部服饰^n");
  94.     add(menubody,255,"\w4. 重新选择^n");
  95.     add(menubody,255,"\w^n0. 返回");

  96.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY0,menubody,MENUTIME,"menu3");

  97.     return PLUGIN_HANDLED;
  98.   }

  99.   // --MENU 4 DISPLAY--------------------------------------------------------------------------
  100.   public menu4Display(id) {

  101.     // terrorist model list

  102.     new menubody[256];
  103.     format(menubody,255,"\y改变服饰为 (匪徒服饰):^n^n");
  104.     add(menubody,255,"\w1. 凤凰城恐怖组织^n");
  105.     add(menubody,255,"\w2. 南美洲特别暗杀小组^n");
  106.     add(menubody,255,"\w3. 瑞典北极复仇者^n");
  107.     add(menubody,255,"\w4. 中东游击队^n");
  108.     add(menubody,255,"\w^n0. 返回");

  109.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY0,menubody,MENUTIME,"menu4");

  110.     return PLUGIN_HANDLED;
  111.   }

复制代码

本帖子中包含更多资源

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

×
 楼主| 发表于 2010-8-13 01:49:52 | 显示全部楼层 来自 中国–广东–佛山–南海区
  1.   // --MENU 5 DISPLAY--------------------------------------------------------------------------
  2.   public menu5Display(id) {

  3.     // counter-terrorist model list

  4.     new menubody[256];
  5.     format(menubody,255,"\y改变服饰为 (警察服饰):^n^n");
  6.     add(menubody,255,"\w1. 美国海豹突击队第六分队^n");
  7.     add(menubody,255,"\w2. 德国边防第九旅^n");
  8.     add(menubody,255,"\w3. 英国皇家特别空勤团^n");
  9.     add(menubody,255,"\w4. 法国宪兵干预队^n");
  10.     add(menubody,255,"\w5. VIP^n");
  11.     add(menubody,255,"\w^n0. 返回");

  12.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY5|KEY0,menubody,MENUTIME,"menu5");

  13.     return PLUGIN_HANDLED;
  14.   }

  15.   // --MENU 6 DISPLAY--------------------------------------------------------------------------
  16.   public menu6Display(id) {

  17.     // our list of custom models

  18.     // clear choices
  19.     for(new i=0;i<9;i++) {
  20.       choices[id][i] = "";
  21.     }

  22.     new menubody[256];
  23.     format(menubody,255,"\y改变服饰为 (指定的服饰, 第 %d 页):^n^n",page[id]);

  24.     // get custom models
  25.     new models[32][33], num;
  26.     num = get_models(models,32);

  27.     // if too many for one page
  28.     new loopamt = num-((page[id]-1)*8);
  29.     if(num-((page[id]-1)*8) > 8) {
  30.       loopamt = 8;
  31.     }

  32.     new offset = (page[id] * 8) - 8; // starting offset

  33.     // loop through players
  34.     for(new i=offset;i<loopamt+offset;i++) {

  35.       // our string to add
  36.       new string[256];
  37.       format(string,255,"\w%d. %s^n",i+1-offset,models[i]);

  38.       // save model's name for easy access
  39.       choices[id][i-offset] = models[i];

  40.       // add it to menu
  41.       add(menubody,255,string);
  42.     }

  43.     // if another page
  44.     if(num-((page[id]-1)*8) > 8) {
  45.       choices[id][8] = "Next";
  46.       add(menubody,255,"\w^n9. 下一页");
  47.     }

  48.     add(menubody,255,"\w^n0. 返回");

  49.     show_menu(id,KEY1|KEY2|KEY3|KEY4|KEY5|KEY6|KEY7|KEY8|KEY9|KEY0,menubody,MENUTIME,"menu6");

  50.     return PLUGIN_HANDLED;
  51.   }

  52.   // ------------------------------------------------------------------------------------------
  53.   // --MENU ACTIONS---------------------------------------------------------------------------
  54.   // ------------------------------------------------------------------------------------------

  55.   // This handles the actions of all of our menus

  56.   // --MENU 1 ACTION---------------------------------------------------------------------------
  57.   public menu1Action(id,key) {

  58.     // 1. Terrorist
  59.     if(key == 0) {
  60.       target[id] = "@T";
  61.       menu3Display(id);
  62.       return 1;
  63.     }

  64.     // 2. Counter-Terrorist
  65.     if(key == 1) {
  66.       target[id] = "@CT";
  67.       menu3Display(id);
  68.       return 1;
  69.     }

  70.     // 3. Specific Player
  71.     if(key == 2) {
  72.       menu2Display(id);
  73.       return 1;
  74.     }

  75.     // 4. All Players
  76.     if(key == 3) {
  77.       target[id] = "*";
  78.       menu3Display(id);
  79.       return 1;
  80.     }

  81.     // 5. Yourself
  82.     if(key == 4) {
  83.       new idstr[33];
  84.       num_to_str(id,idstr,32);
  85.       target[id] = idstr;
  86.       menu3Display(id);
  87.       return 1;
  88.     }

  89.     // 0. Exit
  90.     // Nothing happens and the menu closes

  91.     return 1;
  92.   }

  93.   // --MENU 2 ACTION---------------------------------------------------------------------------
  94.   public menu2Action(id,key) {

  95.     // 0. Back
  96.     if(key == 9 && page[id] == 1) {
  97.       menu1Display(id);
  98.       return 1;
  99.     }
  100.     else if(key == 9 && page[id] > 1) {
  101.       page[id] -=1 ;
  102.       menu2Display(id);
  103.       return 1;
  104.     }

  105.     // if choice is blank
  106.     if(equal(choices[id][key],"")) {
  107.       menu2Display(id); // reset menu
  108.       return 1;
  109.     }

  110.     // 1-8. Varies
  111.     if(key < 8) {
  112.       target[id] = choices[id][key];
  113.       menu3Display(id);
  114.       return 1;
  115.     }

  116.     // 9. Next
  117.     if(key == 8 && equal(choices[id][key],"Next")) {
  118.       page[id] += 1;
  119.       menu2Display(id);
  120.       return 1;
  121.     }  

  122.     return 1;
  123.   }

  124.   // --MENU 3 ACTION---------------------------------------------------------------------------
  125.   public menu3Action(id,key) {

  126.     // 1. T Models
  127.     if(key == 0) {
  128.       menu4Display(id);
  129.       return 1;
  130.     }

  131.     // 2. CT Models
  132.     if(key == 1) {
  133.       menu5Display(id);
  134.       return 1;
  135.     }

  136.     // 3. Custom Models
  137.     if(key == 2) {
  138.       menu6Display(id);
  139.       return 1;
  140.     }

  141.     // 4. Reset Models
  142.     if(key == 3) {
  143.       modelAction(id,target[id],".reset");
  144.       return 1;
  145.     }

  146.     // 0. Back
  147.     if(key == 9) {
  148.       menu1Display(id);
  149.       return 1;
  150.     }   

  151.     return 1;
  152.   }

  153.   // --MENU 4 ACTION---------------------------------------------------------------------------
  154.   public menu4Action(id,key) {

  155.     // 1. Phoenix Connexion
  156.     if(key == 0) {
  157.       modelAction(id,target[id],"terror");
  158.       return 1;
  159.     }

  160.     // 2. 1337 Krew
  161.     if(key == 1) {
  162.       modelAction(id,target[id],"leet");
  163.       return 1;
  164.     }

  165.     // 3. Arctic Avengers
  166.     if(key == 2) {
  167.       modelAction(id,target[id],"arctic");
  168.       return 1;
  169.     }

  170.     // 4. Guerilla Warfare
  171.     if(key == 3) {
  172.       modelAction(id,target[id],"guerilla");
  173.       return 1;
  174.     }

  175.     // 0. Back
  176.     if(key == 9) {
  177.       menu3Display(id);
  178.       return 1;
  179.     }

  180.     return 1;
  181.   }

  182.   
复制代码
回复

使用道具 举报

 楼主| 发表于 2010-8-13 01:50:56 | 显示全部楼层 来自 中国–广东–佛山–南海区
  1. // --MENU 5 ACTION---------------------------------------------------------------------------
  2.   public menu5Action(id,key) {

  3.     // 6. Choose Random
  4.     if(key == 5) {
  5.       key = random_num(0,4);
  6.     }

  7.     // 1. US Seal Team 6
  8.     if(key == 0) {
  9.       modelAction(id,target[id],"urban");
  10.       return 1;
  11.     }

  12.     // 2. German GSG-9
  13.     if(key == 1) {
  14.       modelAction(id,target[id],"gsg9");
  15.       return 1;
  16.     }

  17.     // 3. UK Special Air Service
  18.     if(key == 2) {
  19.       modelAction(id,target[id],"sas");
  20.       return 1;
  21.     }

  22.     // 4. French GIGN
  23.     if(key == 3) {
  24.       modelAction(id,target[id],"gign");
  25.       return 1;
  26.     }

  27.     // 5. VIP
  28.     if(key == 4) {
  29.       modelAction(id,target[id],"vip");
  30.       return 1;
  31.     }

  32.     // 0. Back
  33.     if(key == 9) {
  34.       menu3Display(id);
  35.       return 1;
  36.     }

  37.     return 1;
  38.   }

  39.   // --MENU 6 ACTION---------------------------------------------------------------------------
  40.   public menu6Action(id,key) {

  41.     // 0. Back
  42.     if(key == 9 && page[id] == 1) {
  43.       menu3Display(id);
  44.       return 1;
  45.     }
  46.     else if(key == 9 && page[id] > 1) {
  47.       page[id] -=1 ;
  48.       menu6Display(id);
  49.       return 1;
  50.     }

  51.     // if choice is blank
  52.     if(equal(choices[id][key],"")) {
  53.       menu6Display(id); // reset menu
  54.       return 1;
  55.     }

  56.     // 1-8. Varies
  57.     if(key < 8) {
  58.       modelAction(id,target[id],choices[id][key]);
  59.       return 1;
  60.     }

  61.     // 9. Next
  62.     if(key == 8 && equal(choices[id][key],"Next")) {
  63.       page[id] += 1;
  64.       menu6Display(id);
  65.       return 1;
  66.     }

  67.     return 1;
  68.   }

  69.   // ------------------------------------------------------------------------------------------
  70.   // --SET MODEL ACTION-----------------------------------------------------------------------
  71.   // ------------------------------------------------------------------------------------------
  72.   public modelAction(id,target[33],model[33]) {

  73.     new username[33], authid[33];
  74.     get_user_name(id,username,32);
  75.     get_user_authid(id,authid,32);

  76.     // if clearing models
  77.     if(equal(model,".reset")) {

  78.       // log the command
  79.       log_amx("Cmd: ^"%s<%d><%s><>^" reset model for %s%s",username,get_user_userid(id),authid,isdigit(target[0]) ? "#" : "",target);

  80.       // show activity
  81.       switch(get_cvar_num("amx_show_activity")) {
  82.         case 1: client_print(0,print_chat,"管理: 重新设定服饰为 %s%s",isdigit(target[0]) ? "#" : "",target);
  83.         case 2: client_print(0,print_chat,"管理 %s: 重新设定服饰为 %s%s",username,isdigit(target[0]) ? "#" : "",target);
  84.       }

  85.     }
  86.     else { // if setting models

  87.       // log the command
  88.       log_amx("Cmd: ^"%s<%d><%s><>^" set model %s on %s%s",username,get_user_userid(id),authid,model,isdigit(target[0]) ? "#" : "",target);

  89.       // show activity
  90.       switch(get_cvar_num("amx_show_activity")) {
  91.         case 1: client_print(0,print_chat,"管理: 设定 %s 为 %s%s的服饰",model,isdigit(target[0]) ? "#" : "",target);
  92.         case 2: client_print(0,print_chat,"管理 %s: 设定 %s 为 %s%s的服饰",username,model,isdigit(target[0]) ? "#" : "",target);
  93.       }

  94.     }

  95.     new flags[2], team[33];

  96.     if(equal(target,"@T")) { // All Terrorists
  97.       flags = "e"; // team
  98.       team = "TERRORIST";
  99.     }
  100.     else if(equal(target,"@CT")) { // All Counter-Terrorists
  101.       flags = "e"; // team
  102.       team = "CT";
  103.     }
  104.     else if(isdigit(target[0])) { // Specific Player or Yourself
  105.       flags = "f"; // name
  106.       get_user_name(str_to_num(target),team,32);
  107.     }

  108.     // Otherwise this leaves us with nothing, which is All Players

  109.     // get targets
  110.     new players[32], num;
  111.     get_players(players,num,flags,team);

  112.     // loop through
  113.     for(new i=0;i<num;i++) {
  114.       new player = players[i]; // our player

  115.       if(equal(model,".reset")) { // if reset
  116.         cs_reset_user_model(player);
  117.         setmodel[player] = "";
  118.       }
  119.       else {
  120.         cs_set_user_model(player,model);
  121.         setmodel[player] = model;
  122.       }
  123.     }

  124.     return 1;
  125.   }

  126.   // ------------------------------------------------------------------------------------------
  127.   // --CUSTOM MODEL LIST----------------------------------------------------------------------
  128.   // ------------------------------------------------------------------------------------------
  129.   public get_models(array[32][],len) {

  130.     // get a list of custom models

  131.     new dirpos, output[64], outlen, filledamt;

  132.     // go through custom models
  133.     while((dirpos = read_dir("models/player",dirpos,output,255,outlen)) != 0) {

  134.       if(containi(output,".") == -1) { // if not a file (but a directory)

  135.         // check if model is actually there
  136.         new modelfile[64];
  137.         format(modelfile,63,"models/player/%s/%s.mdl",output,output);

  138.         // if it exists
  139.         if(file_exists(modelfile)) {
  140.           format(array[filledamt],len,"%s",output);
  141.           filledamt += 1;
  142.         }

  143.         // if we are out of array space now
  144.         if(filledamt > 32) {
  145.           return filledamt;
  146.         }

  147.       }

  148.     }

  149.     return filledamt;
  150.   }

  151.   // ------------------------------------------------------------------------------------------
  152.   // --RESET MODEL ON RESPAWN-----------------------------------------------------------------
  153.   // ------------------------------------------------------------------------------------------
  154.   public event_resethud(id) {

  155.     if(!equal(setmodel[id],"")) {
  156.       cs_set_user_model(id,setmodel[id]);
  157.     }

  158.   }

  159.   // ------------------------------------------------------------------------------------------
  160.   // --CONNECTION AND DISCONNECTION-----------------------------------------------------------
  161.   // ------------------------------------------------------------------------------------------
  162.   public client_connect(id) {
  163.     page[id] = 1;
  164.     setmodel[id] = "";
  165.   }

  166.   public client_disconnect(id) {
  167.     page[id] = 1;
  168.     setmodel[id] = "";
  169.   }

  170.   // ------------------------------------------------------------------------------------------
  171.   // --PLUGIN PRECACHE------------------------------------------------------------------------
  172.   // ------------------------------------------------------------------------------------------
  173.   public plugin_precache() {

  174.     // get custom models
  175.     new models[32][33], num;
  176.     num = get_models(models,32);

  177.     // loop through them
  178.     for(new i=0;i<num;i++) {
  179.       new modelstring[64];
  180.       format(modelstring,63,"models/player/%s/%s.mdl",models[i],models[i]);
  181.       precache_model(modelstring);
  182.     }

  183.   }

  184.   public currmodel(id) {
  185.     new model[33];
  186.     cs_get_user_model(id,model,32);
  187.     client_print(id,print_chat,"* 你的服饰是 %s",model);
  188.     return PLUGIN_HANDLED;
  189.   }

  190.   // ------------------------------------------------------------------------------------------
  191.   // --PLUGIN ININITATION---------------------------------------------------------------------
  192.   // ------------------------------------------------------------------------------------------
  193.   public plugin_init() {
  194.     register_plugin("CS服饰管理系统CN","0.11","Avalanche AND btvsohu");
  195.     console_print(0,"* Loaded CS User Model Menuz 0.11 by Avalanche");

  196.     register_clcmd("amx_csummz","menu1Display",ADMIN_BAN,"- 管理服饰菜单");
  197.     register_event("ResetHUD","event_resethud","b");

  198.     register_clcmd("say /currmodel","currmodel",-1);

  199.     // Register Menu IDs
  200.     new menu1ID = register_menuid("menu1");
  201.     new menu2ID = register_menuid("menu2");
  202.     new menu3ID = register_menuid("menu3");
  203.     new menu4ID = register_menuid("menu4");
  204.     new menu5ID = register_menuid("menu5");
  205.     new menu6ID = register_menuid("menu6");

  206.     // Register Menu Commands
  207.     register_menucmd(menu1ID,1023,"menu1Action");
  208.     register_menucmd(menu2ID,1023,"menu2Action");
  209.     register_menucmd(menu3ID,1023,"menu3Action");
  210.     register_menucmd(menu4ID,1023,"menu4Action");
  211.     register_menucmd(menu5ID,1023,"menu5Action");
  212.     register_menucmd(menu6ID,1023,"menu6Action");
  213.   }
  214.   
  215. // hook amx_csummz to check permissions
  216.   public consoleCommand(id,level,cid) {

  217.     if(!cmd_access(id,level,cid,1)) {
  218.       return PLUGIN_HANDLED;
  219.     }

  220.     return menu1Display(id);
  221.   }
复制代码
回复

使用道具 举报

发表于 2011-1-19 00:30:04 | 显示全部楼层 来自 中国–江苏–连云港
看看学习下
回复

使用道具 举报

发表于 2011-1-19 10:56:00 | 显示全部楼层 来自 中国–四川–成都
好长的一段。。。。。。。。。。帮顶。。。
回复

使用道具 举报

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

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