
/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/

#include <amxmod>

new hos_owner
new pmoney[33]
new Float:lannounce
new Float:trespawn[33]

public show_msg(msg[]){
	set_hudmessage(200, 100, 0, 0.01, 0.91, 2, 0.02, 6.0, 0.01, 0.1, 1)
	show_hudmessage(0,msg)
}

public host_notres()
	set_task(0.1,"show_msg",0,"The T's prevented the CT's to rescue the hostages")

public host_allres(){
	set_task(0.1,"show_msg",0,"The CT's rescued all hostages")
	lannounce = get_gametime() + 0.25
}

public host_killed(id){
	new name[32], message[128]
	get_user_name(id,name,32)
	format(message,128,"God damned!! A hostage was killed by %s...",name)
	set_task(0.1,"show_msg",0,message)
}

public host_res(){
	if (lannounce < get_gametime()){
		new name[32], message[128]
		get_user_name(hos_owner,name,32)
		format(message,128,"Hostage rescued by %s...",name)
		set_task(0.1,"show_msg",0,message)
	}
}

public host_got(id){
	hos_owner = id
	new money = read_data(1)
	if ((money - pmoney[id] == 150) && (trespawn[id] < get_gametime()) ) {
		new name[32], message[128]
		get_user_name(id,name,32)
		format(message,128,"%s got the hostage!",name)
		set_task(0.1,"show_msg",0,message)
	}
	pmoney[id] = money
}

public user_respawn(id)
	trespawn[id] = get_gametime() + 15.0

public plugin_init() {
	register_plugin("Hostage Events","0.6","default")
	register_event("TextMsg","host_notres","a","2&#Hostages_N")
	register_event("TextMsg","host_allres","a","2&#All_Hostages_R")
	register_event("TextMsg","host_killed","b","2&#Killed_Hostage")
	register_event("SendAudio","host_res","a","2&%!MRAD_rescued")
	register_event("Money","host_got","b","2=1")
	register_event("ResetHUD","user_respawn","b")
	return PLUGIN_CONTINUE
}


