
   /* AMX Mod script.
   *
   * (c) Copyright 2002, Prophets
   * This file is provided as is (no warranties).
   *
   * BETA 0.1
   *
   */
   #include <amxmod>
   #define B_BUF_LEN 64
   #define FREQUENCY 0.5 // frequency of refreshed displaying
   new  tplayers[32], ctplayers[32], ctplrname[32][32], tplrname[32][32],
   cthealth[32], thealth[32], plrs[32]
   new tnum, ctnum
   public action_main_menu(plr,key){
       client_cmd(plr,"wait;wait;wait;slot%d",key+1)
       return PLUGIN_CONTINUE
   }
   /* displaying */
   show_main_menu(plr){
       new menu_body[512]
       copy(menu_body,511,"\yAMX Team Health Status^n\w^n")
       new temp[B_BUF_LEN+1]
       if(get_user_team(plr)==2)
       {
           for(new a = 0; a < ctnum; ++a)
           {
               if (ctplayers[a]==plr)
                   continue

               new health[6]

               if (cthealth[a]>25)
                   format(health,5,"\y%d",cthealth[a])
               else
                   format(health,5,"\r%d",cthealth[a])

               format(temp,B_BUF_LEN,"^n %s\R%s^n\w",ctplrname[a],health)
               add(menu_body,511,temp)
           }
       }

       if(get_user_team(plr)==1)
       {
           for(new a = 0; a < tnum; ++a)
           {
               if (tplayers[a]==plr)
                   continue

               new health[6]

               if (thealth[a]>25)
                   format(health,5,"\y%d",thealth[a])
               else
                   format(health,5,"\r%d",thealth[a])

               format(temp,B_BUF_LEN,"^n %s\R%s^n\w",tplrname[a],health)
               add(menu_body,511,temp)
           }
       }
       show_menu(plr,1023,menu_body)
       return PLUGIN_CONTINUE
   }
   public get_health()
   {
       get_players(ctplayers,ctnum,"ae","CT")
       for(new i = 0; i < ctnum; ++i)
       {
           get_user_name(ctplayers[i],ctplrname[i],32)
           cthealth[i]=get_user_health(ctplayers[i])
       }
       get_players(tplayers,tnum,"ae","TERRORIST")
       for(new i = 0; i < tnum; ++i)
       {
           get_user_name(tplayers[i],tplrname[i],32)
           thealth[i]=get_user_health(tplayers[i])
       }
       return PLUGIN_CONTINUE
   }
   public player_health()
   {
       new a=0
       if (plrs[0])
       {
           get_health()
           do{
               show_main_menu(plrs[a])
               ++a
           }while(plrs[a])
       }
       return PLUGIN_CONTINUE
   }
   public team_health(id)
   {
       new a=0
       new b=0
       if (plrs[0])
       {
           do{
               if (plrs[a]==id)
               {
                   b=1
                   client_cmd(id,"slot10")
               }


               if (b)
               {
                   plrs[a]=plrs[a+1]
               }

               ++a
           }while(plrs[a])
       }
       if (!b)
       {
           plrs[a]=id
           show_main_menu(id)
       }
       return PLUGIN_CONTINUE
   }
   public client_disconnect(id)
   {
       new a=0
       new b=0
       if (plrs[0])
       {
           do{
               if (plrs[a]==id)
               b=1

               if (b)
               {
                   plrs[a]=plrs[a+1]
               }

               ++a
           }while(plrs[a])
       }
       return PLUGIN_CONTINUE
   }
   /* initialization */
   public plugin_init() {
       register_plugin("Team Health","0.7","Prophets")
       register_menucmd(register_menuid("AMX          Team         Health
   Status"),1023,"action_main_menu")
       register_clcmd("amx_team","team_health")
       set_task(FREQUENCY,"player_health",0,"",0,"b")
       return PLUGIN_CONTINUE
   }
