/* AMXPRO Team */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#tryinclude <biohazard>

#if !defined _biohazard_included
        #assert Biohazard functions file required!
#endif

#define PLUGIN "[BIO]respawn"
#define VERSION "0.1.4"
#define AUTHOR "MaHu"

new cost,durationgm

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("say /spawn","spawn_player")
	register_clcmd("say_team /spawn","spawn_player")
	register_event("DeathMsg","EventDeath","a")
	cost = register_cvar("bh_spawn_cost","2000")
	durationgm = register_cvar("bh_godmode_duration","5")
}

public EventDeath(){
	gmoff(read_data(2))
}

public spawn_player(id){
	if (cs_get_user_money(id)< get_pcvar_num(cost) || is_user_alive(id))
	return PLUGIN_HANDLED;
	else{
	cs_set_user_money(id,cs_get_user_money(id) - get_pcvar_num(cost))
	ExecuteHamB(Ham_CS_RoundRespawn,id)
	set_user_rendering(id,kRenderFxGlowShell, 100,255,255, kRenderNormal,16)
	set_user_godmode(id,1)
	set_task(get_pcvar_float(durationgm),"gmoff",1)
}
	return PLUGIN_HANDLED;
}

public gmoff(id){
	set_user_godmode(id,0)
	set_user_rendering(id,kRenderFxNone,0,0,0,kRenderNormal,25)
}
