
/*
WORMS HEALTH BAR 1.00
Plugin author: Strider
Prigin ported by Servak.
This plugin draws two lines like in Worms, 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
*/
#include <amxmodx>
#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","1.0.0","Strider")
	 register_event("Damage","draw_bar","b","2!0","3=0","4!0")
	 register_event("RoundTime", "new_round", "bc")
	 return PLUGIN_CONTINUE
}
