
/* AMX Mod script.
*
* [SN*INFO] Firstblood Plugin for AMX 0.5 by sonic (sonic@codet.de)
*
* (c) Copyright 2002, sonic
* This file is provided as is (no warranties).
*
*/

/*  put in server.cfg:
*
*   sn_fblood_mode < flags >
*   "a" - show firstblood msg in hud
*   "b" - show firstblood msg in chat
*	"c" - play firstblood sound
*   "d" - show attacker @ fistblood msg
*
*	set sn_fblood_mode "" to disable fistblood plugin
*
*   default sn_fblood_mode is "ac"
*/

#include <amxmod>

new firstblood = 0

public new_round() {
	new roundtime = floatround(get_cvar_float("mp_roundtime") * 60.0)
	if (roundtime == read_data(1)) {
		firstblood = 0
	}
	return PLUGIN_CONTINUE
}

public new_map() {
	firstblood = 0
	return PLUGIN_CONTINUE
}

public death_msg() {
   new kIndex = read_data(1)
   new vIndex = read_data(2)
   if (firstblood == 0 && kIndex && kIndex!=vIndex && get_user_team(kIndex)!=get_user_team(vIndex)) {
      firstblood = 1
      new fbmode[8]
      get_cvar_string("sn_fblood_mode",fbmode,8)
      new fbmode_bit = read_flags(fbmode)
      new msg[128]
      if (fbmode_bit & 8) {
         new kName[32]
         get_user_name(kIndex,kName,32)
         format(msg,128,"%s: First Blood!",kName)
	  } else {
		 format(msg,128,"First Blood!")
	  }
      if (fbmode_bit & 1) {
         set_hudmessage(220,80,0,-1.0,0.30,0, 6.0, 5.0, 1.0, 2.0, 2)
         show_hudmessage(0,msg)
      }
      if (fbmode_bit & 2) {
         client_print(0,print_chat,"[SN*INFO] %s",msg)
      }
      if (fbmode_bit & 4) {
         client_cmd(0,"spk misc/firstblood")
      }
   }
   return PLUGIN_CONTINUE
}

public plugin_init() {
	register_plugin("SN*Firstblood","0.53","Sonic (sonic@codet.de)")
	register_event("TextMsg","new_map","ac","2&#Game_C","2&#Game_w")
	register_event("RoundTime", "new_round", "bc")
	register_event("DeathMsg","death_msg","a")
	register_cvar("sn_fblood_mode","ac")
	return PLUGIN_CONTINUE
}

