搜索
查看: 2887|回复: 7

[求助]如何制作只禁止盾牌插件?

[复制链接]
发表于 2008-1-3 21:57:11 | 显示全部楼层 |阅读模式 来自 智利
我试着把restmenu.sma的代码读了一遍, 很晕着已经搞出无法按出B88或者O8了, 但是如果在控制台输入shield或者用autobuy绑定shield的话, 还是会购买, 如果有哪位高手可以把restmenu.sma文件给注释一遍, 我会感激不尽的.

另外一个问题就是, 如果是Terrorist方在控制台输入shield, 英文版会显示"The "Tactical Shield" is not available to buy for your team, 我当人家用目录购买盾牌的时候使用:
client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
来显示, 我想知道是否有办法直接读取人家的cstrike_xxx.txt (xxx自动根据人家的游戏语言设定)来调用显示.

本帖子中包含更多资源

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

×
 楼主| 发表于 2008-1-3 22:04:53 | 显示全部楼层 来自 智利

回复: [求助]如何制作只禁止盾牌插件?

这是代码:
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. public checkRest(id, key) {
  4.         new team = get_user_team(id)
  5.         new pos = key + team - 1
  6.         if(pos == 8) {
  7.                 engclient_cmd(id, "menuselect", "10")
  8.                 client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
  9.         }
  10. }
  11. public plugin_init() {
  12.         register_plugin("Restrict Shield", "1.0", "Codetrinis")
  13.         register_menucmd(register_menuid("BuyItem", 1), 511, "checkRest")
  14. }
复制代码
回复

使用道具 举报

发表于 2008-1-3 22:21:01 | 显示全部楼层 来自 广东中山

回复: [求助]如何制作只禁止盾牌插件?

我也感到困惑,那个禁止武器插件似乎对于autobuy是无效的。

你可以检测玩家输入的命令,如果输入shield就返回终止,照样用shield命令就买不到了。
回复

使用道具 举报

发表于 2008-1-3 22:23:06 | 显示全部楼层 来自 广东惠州

回复: [求助]如何制作只禁止盾牌插件?

你可以让他买,不给他用就行了,可以参考下刀战插件.
回复

使用道具 举报

 楼主| 发表于 2008-1-3 22:27:43 | 显示全部楼层 来自 智利

回复: [求助]如何制作只禁止盾牌插件?

刚刚查询了一下论坛, 谢谢楼上的代码, 我可以把我的代码更新了一下, 现在可以禁止输入shield购买了:
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. public checkRest(id, key) {
  4.         new team = get_user_team(id)
  5.         new pos = key + team - 1
  6.         if(pos == 8) {
  7.                 engclient_cmd(id, "menuselect", "10")
  8.                 client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
  9.         }
  10. }
  11. public client_command(id) {
  12.         new arg[16]
  13.         read_argv(0, arg, 15)
  14.         if(equali("shield", arg)) {
  15.                 client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
  16.                 return PLUGIN_HANDLED
  17.         }
  18. }
  19. public plugin_init() {
  20.         register_plugin("Restrict Shield", "1.0", "Codetrinis")
  21.         register_menucmd(register_menuid("BuyItem", 1), 511, "checkRest")
  22. }
复制代码
不过编译的时候出现了一个Warning, 说client_command有返回.
回复

使用道具 举报

发表于 2008-1-4 00:20:23 | 显示全部楼层 来自 广东广州

回复: [求助]如何制作只禁止盾牌插件?

这里
return PLUGIN_HANDLED
再加一行
return PLUGIN_CONTINUE
回复

使用道具 举报

发表于 2008-1-4 17:15:29 | 显示全部楼层 来自 甘肃兰州

回复: [求助]如何制作只禁止盾牌插件?

[PHP]#include <amxmodx>
#include <amxmisc>
public checkRest(id, key) {
new team = get_user_team(id)
new pos = key + team - 1
if(pos == 8) {
  engclient_cmd(id, "menuselect", "10")
  client_print(id, print_center, "本服务器禁止使用战术盾牌")
}
}
public client_command(id) {
new arg[16]
read_argv(0, arg, 15)
if(equali("shield", arg)) {
  client_print(id, print_center, "本服务器禁止使用战术盾牌")
  return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Restrict Shield", "1.0", "Codetrinis")
register_menucmd(register_menuid("BuyItem", 1), 511, "checkRest")
}  [/PHP]
太好了!这回终于可以完全地禁止使用战术盾牌了!
回复

使用道具 举报

 楼主| 发表于 2008-1-5 01:07:22 | 显示全部楼层 来自 智利

回复: [求助]如何制作只禁止盾牌插件?

谢谢7楼的提醒, 关于Warning那个问题解决了, 还有谢谢大家对我的关注, 我已经写出禁止盾牌的插件了.
此插件已经从购买菜单, 命令, 和自动购买中完全的禁止了盾牌的使用, 可能还有BUG, 希望大家提出来.
下面是代码, 欢迎测试和修改:
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. new autoBuy[512]
  4. public checkRest(id, key) {
  5.         new team = get_user_team(id)
  6.         new pos = key + team - 1
  7.         if(pos == 8) {
  8.                 engclient_cmd(id, "menuselect", "10")
  9.                 client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
  10.         }
  11. }
  12. public stripItems(inStr[512], outStr[512]) {
  13.         format(outStr, 511, inStr)
  14.         strtolower(outStr)
  15.         while(containi(outStr, "shield") != -1) replace(outStr, 511, "shield", "")
  16.         if(strlen(outStr) < strlen(inStr)) return true
  17.         return false
  18. }
  19. public setABuy(id) {
  20.         autoBuy[0] = '^0'
  21.         new strippedBuy[512]
  22.         new argCount = read_argc()
  23.         new arg[128]
  24.         new autoBuyLen = 0
  25.         for (new i = 1; i < argCount; i++) {
  26.                 read_argv(i, arg, 127)
  27.                 autoBuyLen += format(autoBuy[autoBuyLen], 511 - autoBuyLen, "%s", arg)
  28.                 if(i + 1 < argCount) autoBuyLen += format(autoBuy[autoBuyLen], 511 - autoBuyLen, " ")
  29.         }
  30.         strtolower(autoBuy)
  31.         if(!stripItems(autoBuy, strippedBuy)) return PLUGIN_CONTINUE
  32.         engclient_cmd(id, "cl_setautobuy", strippedBuy)
  33.         return PLUGIN_HANDLED
  34. }
  35. public aBuy(id) {
  36.         new strippedBuy[512]
  37.         if(!stripItems(autoBuy, strippedBuy)) return PLUGIN_CONTINUE
  38.         engclient_cmd(id, "cl_setautobuy", strippedBuy)
  39.         return PLUGIN_HANDLED
  40. }
  41. public client_command(id) {
  42.         new arg[16]
  43.         read_argv(0, arg, 15)
  44.         if(equali("shield", arg)) {
  45.                 client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
  46.                 return PLUGIN_HANDLED
  47.         }
  48.         return PLUGIN_CONTINUE
  49. }
  50. public plugin_init() {
  51.         register_plugin("Restrict Shield", "1.0", "Codetrinis")
  52.         register_clcmd("cl_setautobuy", "setABuy")
  53.         register_clcmd("cl_autobuy", "aBuy")
  54.         register_menucmd(register_menuid("BuyItem", 1), 511, "checkRest")
  55. }
复制代码
回复

使用道具 举报

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

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