Thread: [Solved] c4 experience
View Single Post
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 12-31-2019 , 15:34   Re: c4 experience
Reply With Quote #4

Quote:
Originally Posted by DJEarthQuake View Post
ident or indent?
The code is indented to 4. Post what you think is indented with the same code please. Indentation can be whatever you want. Complaints about it really need examples furnished.
Sorry, typo, I meant indent of course: tabs and spaces and empty line to keep it readable.

IDENTIFY should be ran even if there is no bomb on the map (outside of the check), to keep the plugin list organized.
COLOR is not used.
Why do search for vehicles in precache if you don't do anything with the value returned by the search?

Code:
	#include amxmodx
	#include amxmisc
	#include engine
	#include fakemeta
	#define COLOR random_num(0,255)  // Not used
	///C4 time is adjusted based on defuser's experience. # frags.
	#define IDENTIFY register_plugin("c4 Experience","1.0","SPiNX")
	
	static Float:g_fProtected_VIP = 300.0;
	static Float:g_fNormal_Armor = 100.0;
	static Float:g_fExperience_offset = 1.03;
	static Float:g_fUninhibited_Walk = 272.0;
	new g_iC4_base_time, g_szName[33], g_sprite;
	
	public plugin_init()
	{
		IDENTIFY; // We need to keep the plugin list readable
		if(engfunc(EngFunc_FindEntityByString, -1, "classname","func_bomb_target") || engfunc(EngFunc_FindEntityByString, -1, "classname","info_bomb_target"))
		{
			register_logevent("fnReset_C4",2,"1=Round_Start");
			register_event("Money","fnReset_C4", "b")
			register_event("BarTime", "fnDefusal", "be", "1=5", "1=10");
			g_iC4_base_time = get_cvar_num("mp_c4timer");
		}
		else
		{
			pause( "a" );
		}
	}
	
	public plugin_precache()
	{
		find_ent_by_class(-1,"func_vehicle"); // Why do you get a value if not used?
		g_sprite = precache_model("sprites/smoke.spr");
	}
	
	public fnReset_C4(id)
	{
		set_cvar_num("mp_c4timer",g_iC4_base_time);
		if( (get_user_armor(id)) > g_fNormal_Armor)
		{
			entity_set_float(id, EV_FL_armorvalue, g_fNormal_Armor );
		}
	}
	
	public fnDefusal(id)
	{
		new Float:fC4_factor = get_user_frags(id)*g_fExperience_offset;
		new iSatchel_timer = floatround(g_iC4_base_time+fC4_factor);
		new iCar = find_ent_by_tname( -1, "func_vehicle");
		
		fn_iC4_proximity(id,iCar);
		entity_set_float(id, EV_FL_maxspeed, g_fUninhibited_Walk);
		set_cvar_num("mp_c4timer",iSatchel_timer);
		get_user_name(id,g_szName,charsmax (g_szName));
		client_print(0, print_chat, "C4 timer is now %i seconds due to the expertise of %s.", iSatchel_timer,g_szName);
	}
	
	public fn_iC4_proximity(id, iCar)
	{
		if(entity_range(id, iCar) <= 2000)
		{
			entity_set_float(id, EV_FL_armorvalue, g_fProtected_VIP);
			message_begin(0,23);
			write_byte(TE_BEAMRING)
			write_short(id)
			write_short(iCar)
			write_short(g_sprite)
			write_byte(10)  //starting frame
			write_byte(1) //frame rate in 0.1's
			write_byte(50) //life in 0.1's
			write_byte(200) //line width in 0.1's
			write_byte(random_num(1,12)) //noise amplitude in 0.01's
			write_byte(255)  //Red
			write_byte(100) //Green
			write_byte(25) //blue
			write_byte(300) //brightness
			write_byte(1) //scroll speed in 0.1's
			message_end();
		}
	}
	
	///NOTES:::
	//const m_bIsDefusing = 949;
	//set_pdata_bool(id, m_bIsDefusing, false)

Yes, the idea is good and unique, but most of the players are go by their head even if you tell them to do by objectives

Last edited by RaZ_HU; 12-31-2019 at 15:35.
RaZ_HU is offline