
/*
This plugin draws two lines, which show the health status of the teams
Only  dead  player  see  these lines, so that alive players won't know
status of the enemy team
KNOWN PROBLEMS:
* it uses first channel to output data, but it is also used by StatsMe
or AMX Stats
in  AMX  Stats,  a  long  message,  which  shows by whom you have been
killed,  from  what  distance,  from what weapon and other stuff, uses
channel 1 too, so if you want to use my plugin, disable that option in
Stats, because it will be overidden anyway
on  round start  roundcounter from miscstats.sma also prints a message
on  layer  1,  but  you  can  switch him to layer 4 for example (stats
disappear on the new round anyway)
Still,  it  needs  a lot of updates, feel free to edit it, just let me
know about it, so I could see what you have done
TODO:
* add votings maybe(allow alive players to see these lines)
*  add  handling  of  jump/landing  events(Damage  event doesn't catch
events, when player falls from a height and damages himself)
My e-mail: Strider@newmail.ru
ICQ: 39902704
*/
#include <amxmod>
#include <amxmisc>
public draw_bar() {
	 new CT[32], CTnum
	 new T[32], Tnum, CThealth=0, Thealth=0, i, Tlength, CTlength
	 new buffer[2048]
	 new tmp
	 new Max
	 new pos=0
	 get_players(CT, CTnum, "e", "CT")
	 get_players(T, Tnum, "e", "TERRORIST")
	 if(CTnum > Tnum) Max = CTnum
	 else Max = Tnum
	 if(Max == 0) return PLUGIN_HANDLED
	 for(i=0 ; i<CTnum ; i++) {
			 tmp = get_user_health(CT[i])
			 if(tmp > 0)
			 CThealth += tmp
	 }
	 for(i=0 ; i<Tnum ; i++) {
			 tmp = get_user_health(T[i])
			 if(tmp > 0)
			 Thealth += tmp
	 }
	 Tlength = (Thealth*30)/(Max*100)
	 CTlength = (CThealth*30)/(Max*100)

	 format(buffer, 127, "CT Status^n");
	 pos = 10
	 for(i=0 ; i< CTlength ; i++) {
			 format(buffer[pos], 1, "|")
			 pos++
	 }
	 format(buffer[pos], 127 - pos, "^n");
	 pos++
	 for(i=0 ; i< Tlength ; i++) {
			 format(buffer[pos], 1, "|")
			 pos++
	 }
	 format(buffer[pos], 127 - pos, "^nT Status");
	 get_players(CT, CTnum, "b")
	 for(i=0 ; i<CTnum ; i++) {
			 if(is_user_alive(CT[i])) continue
			 set_hudmessage(200,  0,  0,  -2.0,  -1.0, 0, 0.0, 180.0, 0.05,0.05, 1)
			 show_hudmessage(CT[i],buffer)
	 }
	 return PLUGIN_HANDLED
}
public new_round() {
	 new roundtime = get_cvar_num("mp_roundtime") * 60
	 if (roundtime != read_data(1))
			 return PLUGIN_CONTINUE
	 draw_bar()
	 return PLUGIN_CONTINUE
}
public plugin_init() {
	 register_plugin("Worms Bar","0.9.6","Strider")
	 register_event("Damage","draw_bar","b","2!0","3=0","4!0")
	 register_event("RoundTime", "new_round", "bc")
	 return PLUGIN_CONTINUE
}
