|
楼主 |
发表于 2008-1-5 01:07:22
|
显示全部楼层
来自 智利
回复: [求助]如何制作只禁止盾牌插件?
谢谢7楼的提醒, 关于Warning那个问题解决了, 还有谢谢大家对我的关注, 我已经写出禁止盾牌的插件了.
此插件已经从购买菜单, 命令, 和自动购买中完全的禁止了盾牌的使用, 可能还有BUG, 希望大家提出来.
下面是代码, 欢迎测试和修改:- #include <amxmodx>
- #include <amxmisc>
- new autoBuy[512]
- 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, "The ^"Tactical Shield^" is not available to buy for your team.")
- }
- }
- public stripItems(inStr[512], outStr[512]) {
- format(outStr, 511, inStr)
- strtolower(outStr)
- while(containi(outStr, "shield") != -1) replace(outStr, 511, "shield", "")
- if(strlen(outStr) < strlen(inStr)) return true
- return false
- }
- public setABuy(id) {
- autoBuy[0] = '^0'
- new strippedBuy[512]
- new argCount = read_argc()
- new arg[128]
- new autoBuyLen = 0
- for (new i = 1; i < argCount; i++) {
- read_argv(i, arg, 127)
- autoBuyLen += format(autoBuy[autoBuyLen], 511 - autoBuyLen, "%s", arg)
- if(i + 1 < argCount) autoBuyLen += format(autoBuy[autoBuyLen], 511 - autoBuyLen, " ")
- }
- strtolower(autoBuy)
- if(!stripItems(autoBuy, strippedBuy)) return PLUGIN_CONTINUE
- engclient_cmd(id, "cl_setautobuy", strippedBuy)
- return PLUGIN_HANDLED
- }
- public aBuy(id) {
- new strippedBuy[512]
- if(!stripItems(autoBuy, strippedBuy)) return PLUGIN_CONTINUE
- engclient_cmd(id, "cl_setautobuy", strippedBuy)
- return PLUGIN_HANDLED
- }
- public client_command(id) {
- new arg[16]
- read_argv(0, arg, 15)
- if(equali("shield", arg)) {
- client_print(id, print_center, "The ^"Tactical Shield^" is not available to buy for your team.")
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- public plugin_init() {
- register_plugin("Restrict Shield", "1.0", "Codetrinis")
- register_clcmd("cl_setautobuy", "setABuy")
- register_clcmd("cl_autobuy", "aBuy")
- register_menucmd(register_menuid("BuyItem", 1), 511, "checkRest")
- }
复制代码 |
|