#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta_util>
#include <next21_DR_core>

#define PLUGIN "n21_Deathrun_Invisible"
#define VERSION "1.0"
#define AUTHOR "Psycrow"

new ModeId, was_invis

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	ModeId = n21_dr_mode_registration("Призрак", "", 4, 0, 255, 0, 2)
	
	register_logevent("NewRound", 2, "1=Round_Start")
	RegisterHam(Ham_Use,"func_button","UseButton",0)
}

public n21_dr_new_terr(id, mode)
{
	if(mode == ModeId)
	{
		was_invis = id
		fm_set_user_rendering(id,  kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,0)
		fm_set_user_health(id, 1)
	}
}
	
public NewRound()
{
	if(was_invis)
	{
		fm_set_user_rendering(was_invis)
		was_invis = 0
	}
}

public n21_dr_set_mode(id, mode)
{
	if(mode == ModeId)
	{
		fm_set_user_rendering(id,  kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,0)
		was_invis = id
		fm_set_user_health(id, 1)
	}
}

public UseButton(ent, id, idactivator, use_type, Float:value)
{
	if(!is_user_connected(id))
		return HAM_SUPERCEDE  
	
	if(was_invis == id)
		return HAM_SUPERCEDE  
		
	return HAM_IGNORED   
}
