|
发表于 2010-12-23 21:10:48
|
显示全部楼层
来自 中国–广西–百色–那坡县
参考以下
#include <amxmodx>
#include <fakemeta>
new plist[33] = { 0, ... } // 0 = no awp; 1 = carrying awp
new plist2[33] = {0, ... } // 0 = no auto; 1 = carrying auto
new awp_count[3] // 1 = T; 2 = CT
new auto_count[3] // 1 = T; 2 = CT
new ctscore = 0
new tscore = 0
new pl_team[33]
/* PCvars */
new pv_awplimit
new pv_max_awps
new pv_winspread_awp
new pv_autolimit
new pv_max_autos
new pv_winspread_auto
new pv_checkrebuy
new pv_minplayers
/* handles restricting the menu */
public menu_awp(id,key)
{
if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
new winspread_awp = get_pcvar_num(pv_winspread_awp)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
return PLUGIN_HANDLED
}
if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
&& winspread_awp)
{
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] >= get_pcvar_num(pv_max_awps))
{
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 restricting the menu */
public menu_auto(id,key)
{
if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
new winspread_auto = get_pcvar_num(pv_winspread_auto)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
return PLUGIN_HANDLED
}
if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
&& winspread_auto)
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
return PLUGIN_HANDLED
}
if (auto_count[team] >= get_pcvar_num(pv_max_autos))
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"Too many people on your team have AUTO's")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
/* handles if they script the AWP buy*/
public cmdawp(id)
{
if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
if ((team < 1) || (team > 2)) return PLUGIN_CONTINUE
new winspread_awp = get_pcvar_num(pv_winspread_awp)
new name[32]
get_user_name(id,name,31)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
return PLUGIN_HANDLED
}
if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
&& winspread_awp)
{
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
return PLUGIN_HANDLED
}
if (awp_count[team] >= get_pcvar_num(pv_max_awps))
{
client_print(id,print_center,"Too many people on your team have AWP's")
// client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team %d - too many to buy.", awp_count[team], team)
// log_message("The player %s was about to buy an awp. There was %d awps in his team %d - too many to buy.", name, awp_count[team], team)
return PLUGIN_HANDLED
}
// client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team before You bought it.", awp_count[team])
// log_message("The player %s is about to buy an awp. There was %d awps in his team %d before he bought it.", name, awp_count[team], team)
return PLUGIN_CONTINUE
}
/* handles if they script the AUTO buy*/
public cmdauto(id)
{
if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
new winspread_auto = get_pcvar_num(pv_winspread_auto)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
engclient_cmd(id,"menuselect","10")
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
return PLUGIN_HANDLED
}
if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
&& winspread_auto)
{
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
return PLUGIN_HANDLED
}
if (auto_count[team] >= get_pcvar_num(pv_max_autos))
{
client_print(id,print_center,"Too many people on your team have AUTO's")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
/* handles when a player drops his weapon */
public handle_drop_weapon(id)
{
new tmp1,tmp2
new curweapon = get_user_weapon(id,tmp1,tmp2)
new team = get_user_team(id)
/* handles when a player drops their awp */
if (curweapon == CSW_AWP)
{
if (get_pcvar_num(pv_awplimit) != 1)
return PLUGIN_CONTINUE
if ((plist[id]==1) && (awp_count[team] > 0))
awp_count[team]--
plist[id] = 0
return PLUGIN_CONTINUE
}
/* handles when a player drops his auto */
else if ((curweapon == CSW_SG550) || (curweapon == CSW_G3SG1))
{
if (get_pcvar_num(pv_autolimit) != 1)
return PLUGIN_CONTINUE
if ((plist2[id]==1) && (auto_count[team] > 0))
auto_count[team]--
plist2[id] = 0
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
/* handles when a player picks up an awp */
public handle_pickup_awp(id)
{
if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
new winspread_awp = get_pcvar_num(pv_winspread_awp)
new name[32]
get_user_name(id,name,31)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
set_task(0.5, "drop_awp", id)
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
return PLUGIN_CONTINUE
}
if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
&& winspread_awp)
{
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
set_task(0.5, "drop_awp", id)
return PLUGIN_CONTINUE
}
if (awp_count[team] >= get_pcvar_num(pv_max_awps))
{
client_print(id,print_center,"Too many people on your team have AWP's")
// log_message("The player %s bought or picked-up an awp. There is %d awps in his %d team. He should drop it.", name, awp_count[team], team)
set_task(0.5, "drop_awp", id)
// engclient_cmd(id, "drop", "weapon_awp")
// client_cmd(id,"weapon_awp;wait;wait;wait;drop")
return PLUGIN_CONTINUE
}
else
{
plist[id] = 1
awp_count[team]++
// client_print(id,print_chat,"You have bought or picked-up an awp. There is %d awps in Your team.", awp_count[team])
// log_message("The player %s bought or picked-up an awp. There is %d awps in his team %d.", name, awp_count[team], team)
}
return PLUGIN_CONTINUE
}
public drop_awp(id)
{
new team
if (!is_user_connected(id)) return
engclient_cmd(id, "drop", "weapon_awp")
if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
{
team = get_user_team(id)
plist[id] = 0
if (awp_count[team] > 0)
awp_count[team]--
}
}
/* handles when a player picks up a g3sg1 */
public handle_pickup_g3sg1(id)
{
if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
new team = get_user_team(id)
new winspread_auto = get_pcvar_num(pv_winspread_auto)
new min_players = get_pcvar_num(pv_minplayers)
new team1_num, team2_num
new players[32]
get_players(players,team1_num,"e","TERRORIST")
get_players(players,team2_num,"e","CT")
if ((team1_num < min_players) || (team2_num < min_players))
{
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
set_task(0.5, "drop_g3sg1", id)
return PLUGIN_CONTINUE
}
if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
&& winspread_auto)
{
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
set_task(0.5, "drop_g3sg1", id)
return PLUGIN_CONTINUE
}
if (auto_count[team] >= get_pcvar_num(pv_max_autos))
{
client_print(id,print_center,"Too many people on your team have AUTO's")
set_task(0.5, "drop_g3sg1", id)
return PLUGIN_CONTINUE
}
else
{
plist2[id] = 1
auto_count[team]++
}
return PLUGIN_CONTINUE
} |
|