|
发表于 2012-4-26 15:23:50
|
显示全部楼层
来自 中国–浙江–杭州
- /*
- --------------------------------------------------------------------------------
- Web URL: http: //t.qq.com/k1nader
- E-M@IL: mailto: jon.ray@qq.com
- --------------------------------------------------------------------------------
- amx_grenade_money <300> 购买一个手雷多少钱
- amx_grenade_access <p> 购买多个手雷需要什么权限
- amx_grenade_num <3> 总共可以买多少颗手雷
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fun>
- #define PLUGIN "New Plug-In"
- #define VERSION "1.0"
- #define AUTHOR "k1nader"
- #define LOADING "^n^t%s v%s, Copyright (C) 2012 by %s^n"
- new g_MsgidTextMsg, g_BuyNum, g_Buyaccess, g_Buymoney, Float:g_GameTime;
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- server_print(LOADING,PLUGIN,VERSION,AUTHOR);
-
- register_logevent("EventStartRound", 2, "0=World triggered", "1=Round_Start");
- register_event("HLTV", "EventStartRound", "a", "1=0", "2=0");
-
- register_menucmd(register_menuid("BuyItem", 1), 511, "menuItem");
- g_Buymoney = register_cvar("amx_grenade_money", "300");
- g_Buyaccess = register_cvar("amx_grenade_access", "p");
- g_BuyNum = register_cvar("amx_grenade_num", "3");
-
- g_MsgidTextMsg = get_user_msgid("TextMsg");
- }
- public EventStartRound()
- g_GameTime = get_gametime();
- public menuItem(id, key)
- {
- if(key == 3)
- {
- buy_hegren(id);
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- public client_command(id)
- {
- new arg[13];
- if(read_argv(0, arg, 12) > 11) return PLUGIN_CONTINUE;
-
- if(equali(arg, "hegren"))
- {
- buy_hegren(id);
- return PLUGIN_HANDLED;
- }
-
- return PLUGIN_CONTINUE;
- }
- public buy_hegren(id)
- {
- new Float:buytime, Float:timepassed, g_money, g_currentHE, CannotTime[5];
-
- timepassed = get_gametime() - g_GameTime;
-
- buytime = get_cvar_float("mp_buytime") * 60.0;
-
- if(!is_user_connected(id)) return PLUGIN_HANDLED;
-
- if(!cs_get_user_buyzone(id)) return PLUGIN_HANDLED;
-
- if(floatcmp(timepassed , buytime) == 1)
- {
- num_to_str(floatround(get_cvar_float("mp_buytime") * 60.0, floatround_round), CannotTime, charsmax(CannotTime));
-
- buy_message(id, "#Cant_buy", CannotTime);
- return PLUGIN_HANDLED;
- }
-
- g_money = cs_get_user_money(id);
-
- if(g_money < get_pcvar_num(g_Buymoney))
- {
- buy_message(id, "#Not_Enough_Money", "");
- return PLUGIN_HANDLED;
- }
-
- g_currentHE = cs_get_user_bpammo(id, CSW_HEGRENADE);
-
- if(g_currentHE == 0)
- {
- give_item(id, "weapon_hegrenade");
- cs_set_user_money(id, g_money - get_pcvar_num(g_Buymoney));
- }
- else
- {
- new accessbuy[24];
- get_pcvar_string(g_Buyaccess, accessbuy, charsmax(g_Buyaccess));
-
- if(get_user_flags(id) & read_flags(accessbuy) == 0)
- {
- buy_message(id, "#Cannot_Carry_Anymore", "");
- return PLUGIN_HANDLED;
- }
-
- if(g_currentHE <= (get_pcvar_num(g_BuyNum) - 1))
- {
- cs_set_user_bpammo(id, CSW_HEGRENADE, 0);
- give_item (id, "weapon_hegrenade");
- cs_set_user_bpammo(id, CSW_HEGRENADE, g_currentHE + 1);
- cs_set_user_money(id, g_money - get_pcvar_num(g_Buymoney));
- }
- else
- buy_message(id, "#Cannot_Carry_Anymore", "");
- }
- return PLUGIN_HANDLED;
- }
- public buy_message(id, message[], more[])
- {
- message_begin(MSG_ONE, g_MsgidTextMsg, _, id);
- write_byte(4);
- write_string(message);
- if(strlen(more) > 0)
- write_string(more);
- message_end();
- }
复制代码 买普通手雷的方法购买就行,只要有权限。
这个是最新的版本,基本上没BUG了。 |
|