|
发表于 2009-5-15 22:14:24
|
显示全部楼层
来自 中国–广东–广州–白云区
限制每队的awp数量插件
{:3_59:} 50点通币你点比我啊{:3_51:}- #include <amxmod>
- #define MAXAWPS 2 // number of awps a team can have
- #define WINSPREAD 3 // the difference when it starts restricting awps for winning team
- new plist[32] = { 0, ... } // 0 = no awp; 1 = carrying awp
- new awp_count[3] // 1 = T; 2 = CT
- new ctscore = 0
- new tscore = 0
- /* handles restricting the menu */
- public menu_awp(id,key) {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- new team = get_user_team(id)
-
- if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
- {
- engclient_cmd(id,"menuselect","10")
- client_print(id,print_center,"You are on the winning team and cannot use AWP's")
- return PLUGIN_HANDLED
- }
-
- if(awp_count[team] >= MAXAWPS)
- {
-
- engclient_cmd(id,"menuselect","10")
- client_print(id,print_center,"Too many people on your team have AWP's")
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- /* handles if they script the AWP buy*/
- public cmdawp(id)
- {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- new team = get_user_team(id)
-
- if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
- {
- client_print(id,print_center,"You are on the winning team and cannot use AWP's")
- return PLUGIN_HANDLED
- }
-
- if(awp_count[team] >= MAXAWPS)
- {
- client_print(id,print_center,"Too many people on your team have AWP's")
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- /* handles when a player drops their weapon */
- public handle_drop(id) {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- if (plist[id] == 1)
- {
- new tmp1,tmp2
- new curweapon = get_user_weapon(id,tmp1,tmp2)
- if (curweapon == 18)
- {
- plist[id] = 0
- new team = get_user_team(id)
- awp_count[team]--
- }
- }
- return PLUGIN_CONTINUE
- }
- /* handles when a player picks up an awp */
- public handle_pickup(id) {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- new team = get_user_team(id)
- if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
- {
- client_print(id,print_center,"You are on the winning team and cannot use AWP's")
- client_cmd(id,"weapon_awp;wait;wait;wait;drop")
- return PLUGIN_CONTINUE
- }
-
- if (awp_count[team] >= MAXAWPS)
- {
- client_print(id,print_center,"Too many people on your team have AWP's")
- client_cmd(id,"weapon_awp;wait;wait;wait;drop")
- return PLUGIN_CONTINUE
- }
- else
- {
- plist[id] = 1
- awp_count[team]++
- }
- return PLUGIN_CONTINUE
- }
- /* removes awp when player dies */
- public handle_death() {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- new idx = read_data(2)
- if(plist[idx] == 1)
- {
- new team = get_user_team(idx)
- awp_count[team]--
- plist[idx] = 0
- }
- return PLUGIN_CONTINUE
- }
- /* clear vars when player connects */
- public client_connect(id) {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- plist[id] = 0 // just to make sure
- return PLUGIN_CONTINUE
- }
- /* clear vars when player disconnects */
- public client_disconnect(id) {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- if (plist[id] == 1)
- {
- new team = get_user_team(id)
- awp_count[team]--
- }
- plist[id] = 0
- return PLUGIN_CONTINUE
- }
- public team_score()
- {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- new team[32]
- read_data(1,team,32)
- if (equal(team,"CT")){
- ctscore = read_data(2)
- }
- else if (equal(team,"TERRORIST")){
- tscore = read_data(2)
- }
- return PLUGIN_CONTINUE
- }
- public check_winning_team(id)
- {
- if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
- if (plist[id] == 1)
- {
- new team = get_user_team(id)
-
- if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
- {
- client_print(id,print_center,"You are on the winning team and cannot use AWP's")
- client_cmd(id,"weapon_awp;wait;wait;wait;drop")
- return PLUGIN_CONTINUE
- }
- }
- return PLUGIN_CONTINUE
- }
- public check_rebuy(id)
- {
- if (get_cvar_num("checkrebuy")!=1) return PLUGIN_CONTINUE
- client_print(id,print_center,"Sorry Rebuy command is blocked on this server")
- return PLUGIN_HANDLED
- }
-
- public plugin_init(){
- register_plugin("AWP Limit (Team/Win)","0.4","SuicideDog")
- register_menucmd(-31,1<<5,"menu_awp")
- register_clcmd("drop","handle_drop")
- register_clcmd("awp","cmdawp")
- register_clcmd("rebuy","check_rebuy")
- register_cvar("awplimit","1")
- register_cvar("checkrebuy","1")
- register_event("TeamScore", "team_score", "a")
- register_event("WeapPickup","handle_pickup","b","1=18")
- register_event("DeathMsg","handle_death","a")
- register_event("ResetHUD","check_winning_team","b")
- return PLUGIN_CONTINUE
- }
复制代码 5# 银闪闪 |
|