|
发表于 2010-3-1 12:52:26
|
显示全部楼层
来自 中国–广东–东莞
- #include <amxmodx>
- #include <cstrike>
- new roundnum = 0
- new already[33]//已经换好
- new exchange//区分CT和T
- new YNteam
- new YNnum
- public plugin_init(){
- register_plugin("队伍平衡", "1", "3344")
- register_logevent("event_round_end", 2, "0=World triggered", "1=Round_End")
- register_event("TextMsg", "round_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in")
- register_cvar("sv_randomteams", "15")//多少局执行
- register_cvar("teamtype", "2")//1为队伍对换,2为队伍实力平衡
- register_cvar("teamdegree", "1")//执行多少次
- }
- public event_round_end(){
- if(YNteam)
- return
-
- roundnum++
- client_print(0, print_center, "%d",roundnum)
- if(roundnum >= get_cvar_num("sv_randomteams")){
- set_task(4.8, "event_round_end34", 546548, "", 1)
- roundnum = 0
- YNnum++
- if(YNnum >= get_cvar_num("teamdegree"))
- YNteam = true
- }
- }
- public round_restart(){
- YNteam = false
- roundnum = 0
- }
- public event_round_end34(){
- switch (get_cvar_num("teamtype"))
- {
- case 1:
- {
- new num, players[32]
- get_players(players,num)
- for(new i=0;i<num;i++){
- if(!is_user_connected(players[i])) continue
-
- if(cs_get_user_team(players[i])==CS_TEAM_CT)
- cs_set_user_team(players[i],CS_TEAM_T)
- else if(cs_get_user_team(players[i])!=CS_TEAM_SPECTATOR)
- cs_set_user_team(players[i],CS_TEAM_CT)
- }
- }
- case 2:
- {
- new Pnum=get_playersnum()
- for (new s=1;s<=Pnum;s++){
- new frag,id,worstfrag
- for (new i=1;i<=Pnum;i++){//找出分数高的人
- if (is_user_connected(i) && !already[i]){//排除已经换队的人
- frag = get_user_frags(i)
- if (frag>worstfrag){
- id=i
- worstfrag=frag
- }
- }
- }
- if(is_user_connected(id) && cs_get_user_team(id)!=CS_TEAM_SPECTATOR){
- already[id]=true//作记号
- if(exchange){
- cs_set_user_team(id,CS_TEAM_CT)
- exchange=false
- }
- else{
- cs_set_user_team(id,CS_TEAM_T)
- exchange=true
- }
- }
- }
- for (new r=1;r<=Pnum;r++)//清除记号
- already[r]=false
- }
- }
- }
复制代码 |
|