[Rezolvat] Modificare Plugin

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori

Post Reply
qPro
Membru, skill 0
Membru, skill 0
Posts: 68
Joined: 15 Jun 2014, 12:27
Detinator Steam: Da
SteamID: Private. :d
Fond eXtream: 0
Has thanked: 4 times

03 Jul 2014, 18:02

Salut , Am nevoie de o modificare la o arma CSO , modificarea vreau să conste în adăugarea unei comenzi , mai exact : amx_give_at4 adică să dau arma aceea la un player anume prin această comanda ( amx_give_at4 ).

Uitați aici sursa armei :
Sursa AT4 | Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "AT4"
#define VERSION "1.0"
#define AUTHOR "Aragon*"
#define AMMOWP_NULL (1<<0 | 1<<CSW_KNIFE | 1<<CSW_FLASHBANG | 1<<CSW_HEGRENADE | 1<<CSW_SMOKEGRENADE | 1<<CSW_C4)
#define DMG_HEGRENADE (1<<24)
new PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
new const WeaponsAmmo[][] = {
	{ -1, -1 },
	{ 13, 52 },
	{ -1, -1 },
	{ 10, 90 },
	{ -1, -1 },
	{ 7, 32 },
	{ -1, -1 },
	{ 30, 100 },
	{ 30, 90 },
	{ -1, -1 },
	{ 30, 120 },
	{ 20, 100 },
	{ 25, 100 },
	{ 30, 90 },
	{ 35, 90 },
	{ 25, 90 },
	{ 12, 100 },
	{ 20, 120 },
	{ 10, 30 },
	{ 30, 120 },
	{ 100, 200 },
	{ 8, 32 },
	{ 30, 90 },
	{ 30, 120 },
	{ 20, 90 },
	{ -1, -1 },
	{ 7, 35 },
	{ 30, 90 },
	{ 30, 90 },
	{ -1, -1 },
	{ 50, 100 }
}

#define AT4_WEAPONKEY		100
#define weapon_at4		"weapon_m249"
#define CSW_AT4			CSW_M249
#define AT4_CLASS		"at4ex_rocket"
#define AT4_CLASS_LASERDOT	"at4_laserdot"
#define at4_shotdelay		4.0 // Refire rate
new AT4Model_V[] = "models/furien30_weapons/Primary/v_at4.mdl";
new AT4Model_P[] = "models/furien30_weapons/Primary/p_at4.mdl";
new AT4Model_W[] = "models/furien30_weapons/Primary/w_at4.mdl";
new AT4Model_S[] = "models/furien30_weapons/Primary/s_at4rocket.mdl";
new AT4Model_LASER[] = "sprites/laserdot.spr";
new AT4_Sound[][] = {
	"weapons/at4_shoot1.wav",
	"weapons/at4_clipin1.wav",
	"weapons/at4_clipin2.wav",
	"weapons/at4_clipin3.wav",
	"weapons/at4_draw.wav"
};
new AT4_Generic[][] = {
	"sprites/furien30_at4.txt",
	"sprites/furien30_weapons/At4.spr",
	"sprites/furien30_weapons/640hud7x.spr"
};

new bool:HaveAT4[33], at4_clip[33], at4_reload[33], at4_detector[33], at4_event, at4_smoke, at4_trail, at4_explode;
new at4damage, at4radius, at4knockback, at4reloadtime;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_logevent("RoundStart", 2, "1=Round_Start");
	register_event("CurWeapon", "EVENT_CurWeapon", "be", "1=1")

	AT4_Init();
}
public EVENT_CurWeapon(id) {
	if(is_user_connected(id) && is_user_alive(id)) {
		static Weapon
		Weapon = read_data(2)
		
		if(!(AMMOWP_NULL &(1<<Weapon))) {		
			if(fm_get_user_bpammo(id, Weapon) < WeaponsAmmo[Weapon][1]) 
				fm_set_user_bpammo(id, Weapon, WeaponsAmmo[Weapon][1])
		}
	}
}

public plugin_precache() {
	AT4_Precache();
}
public plugin_natives() {
	AT4_Natives();
}
public RoundStart() {
	remove_entity_name(AT4_CLASS);
	remove_entity_name(AT4_CLASS_LASERDOT);
}
AT4_Init() {
	register_clcmd("furien30_at4", "Hook_AT4");
	
	register_event("CurWeapon", "AT4_ViewModel", "be", "1=1");
	register_event("WeapPickup","AT4_ViewModel","b","1=19");
	
	register_forward(FM_SetModel, "AT4_WorldModel", 1);
	register_forward(FM_UpdateClientData, "AT4_UpdateClientData_Post", 1);
	register_forward(FM_PlaybackEvent, "AT4_PlaybackEvent");
	register_forward(FM_PlayerPreThink, "AT4_PreThink");
	register_forward(FM_CmdStart, "AT4_CmdStart");	
	
	RegisterHam(Ham_Item_AddToPlayer, weapon_at4, "AT4_AddToPlayer");
	RegisterHam(Ham_Item_Deploy , weapon_at4, "AT4_Deploy_Post", 1);
	RegisterHam(Ham_Item_Holster , weapon_at4, "AT4_Holster");
	RegisterHam(Ham_Weapon_WeaponIdle, weapon_at4, "AT4_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_at4, "AT4_PrimaryAttack");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload_Post", 1);
	RegisterHam(Ham_Item_PostFrame, weapon_at4, "AT4_PostFrame");	
	
	register_think(AT4_CLASS, "AT4_Think");
	register_think(AT4_CLASS_LASERDOT, "AT4_LaserDot_Think");
	
	register_touch(AT4_CLASS, "*", "AT4_Touch");
	
	at4damage = register_cvar("furien30_at4_damage", "300.0");		//| AT4 Damage |//
	at4radius = register_cvar("furien30_at4_radius", "220.0");		//| AT4 Radius |//
	at4knockback = register_cvar("furien30_at4_knockback", "4.0");		//| At4 KnockBack |//
	at4reloadtime = register_cvar("furien30_at4_reload_time", "2.33");	//| AT4 Reload Time |//
}

AT4_Precache() {
	register_forward(FM_PrecacheEvent, "AT4_PrecacheEvent_Post", 1);

	at4_smoke = precache_model("sprites/effects/rainsplash.spr");
	at4_trail = precache_model("sprites/xbeam3.spr");
	at4_explode = precache_model("sprites/furien30_weapons/explode.spr");
	
	precache_model(AT4Model_V);
	precache_model(AT4Model_P);
	precache_model(AT4Model_W);
	precache_model(AT4Model_S);
	precache_model(AT4Model_LASER);
	
	for(new i = 0; i < sizeof(AT4_Sound); i++)
		engfunc(EngFunc_PrecacheSound, AT4_Sound);	
	for(new i = 0; i < sizeof(AT4_Generic); i++)
		engfunc(EngFunc_PrecacheGeneric, AT4_Generic);
}

AT4_Natives() {
	register_native("get_user_at4", "get_user_at4", 1);
	register_native("set_user_at4", "set_user_at4", 1);
}

public AT4_ViewModel(id) {
	if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
		set_pev(id, pev_viewmodel2, AT4Model_V);
		set_pev(id, pev_weaponmodel2, AT4Model_P);
		set_pdata_int(id, 361, get_pdata_int(id, 361) | (1<<6));
	}
}

public AT4_WorldModel(entity, model[]) {
	if(is_valid_ent(entity)) {
		static ClassName[33];
		entity_get_string(entity, EV_SZ_classname, ClassName, charsmax(ClassName));
		
		if(equal(ClassName, "weaponbox")) {
			new Owner = entity_get_edict(entity, EV_ENT_owner);	
			new _AT4 = find_ent_by_owner(-1, weapon_at4, entity);
			
			if(get_user_at4(Owner) && is_valid_ent(_AT4) && equal(model, "models/w_m249.mdl")) {
				entity_set_int(_AT4, EV_INT_impulse, AT4_WEAPONKEY);
				HaveAT4[Owner] = false;
				entity_set_model(entity, AT4Model_W);
				set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
				new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, Owner);
				if(is_valid_ent(Laser))
					remove_entity(Laser);
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_UpdateClientData_Post(id, sendweapons, cd_handle) {
	if(is_user_alive(id) && is_user_connected(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
		set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
	return FMRES_IGNORED;
}

public AT4_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) {
	if(is_user_connected(invoker) && eventid == at4_event)
		playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
	return FMRES_IGNORED;
}

public AT4_PrecacheEvent_Post(type, const name[]) {
	if (equal("events/m249.sc", name))
		at4_event = get_orig_retval();
	return FMRES_IGNORED;
}

public AT4_PreThink(id) {
	if(is_user_alive(id) && is_user_connected(id)) {
		if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && at4_detector[id]) {
			new Float: origin[3];
			fm_get_aim_origin(id,origin);
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			
			if(!is_valid_ent(Laser)) {
				new at4_laser = create_entity("info_target");	
				set_pev(at4_laser, pev_classname, AT4_CLASS_LASERDOT);
				set_pev(at4_laser, pev_owner, id);
				engfunc(EngFunc_SetModel, at4_laser, AT4Model_LASER);
				set_pev(at4_laser, pev_renderfx, kRenderFxNoDissipation);
				set_pev(at4_laser, pev_rendermode, kRenderGlow);
				set_pev(at4_laser, pev_renderamt, 255.0);
				set_pev(at4_laser, pev_light_level, 255.0);
				set_pev(at4_laser, pev_scale, 1.0);
				set_pev(at4_laser, pev_movetype, MOVETYPE_FLY);
				set_pev(at4_laser, pev_nextthink, halflife_time() + 0.001);
			}
		}
		else {
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			if(is_valid_ent(Laser))
				remove_entity(Laser);
		}
	}
}

public AT4_CmdStart(id, uc_handle, seed) {
	if(is_user_alive(id) && is_user_connected(id)) {
		static CurButton;
		CurButton = get_uc(uc_handle, UC_Buttons);
		new Float:NextAttack = get_pdata_float(id, 83, 5);
		
		static _AT4;
		_AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);	
		
		if(CurButton & IN_ATTACK) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
				if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
					set_weapon_anim(id, 1);
					emit_sound(id, CHAN_WEAPON, AT4_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM);
					AT4_Fire(id);
					new Float:PunchAngles[3];
					PunchAngles[0] = random_float(-7.0, -10.0), PunchAngles[1] = 0.0, PunchAngles[2] = 0.0;
					set_pev(id, pev_punchangle, PunchAngles);
					cs_set_weapon_ammo(_AT4, cs_get_weapon_ammo(_AT4) - 1);
					if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
						set_pdata_float(id, 83, at4_shotdelay, 5);
						set_pdata_float(_AT4, 48, 0.3, 4)
					}
				}
				CurButton &= ~IN_ATTACK;
				set_uc(uc_handle, UC_Buttons, CurButton);
			}
		}
		
		if(CurButton & IN_ATTACK2 && !(pev(id, pev_oldbuttons) & IN_ATTACK2)) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && NextAttack <= 0.0) {
				if(at4_detector[id])
					at4_detector[id] = false;
				else
					at4_detector[id] = true;
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_AddToPlayer(Weapon, id) {
	if(is_valid_ent(Weapon) && is_user_connected(id) && entity_get_int(Weapon, EV_INT_impulse) == AT4_WEAPONKEY) {
		HaveAT4[id] = true;
		WeaponList(id, AT4_WEAPONKEY)
		entity_set_int(Weapon, EV_INT_impulse, 0);
	}
	return HAM_IGNORED;
}

public AT4_Deploy_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {
			set_pev(Owner, pev_viewmodel2, AT4Model_V);
			set_pev(Owner, pev_weaponmodel2, AT4Model_P);
			set_weapon_anim(Owner, 4)
			
			set_pdata_float(Owner, 83, 1.2, 5);
			set_pdata_float(Weapon, 48, 1.2, 4)
			
			if(cs_get_weapon_ammo(Weapon) > 0)
				at4_reload[Owner] = 0;
		}
	}
	return HAM_IGNORED;
}

public AT4_Holster(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner))
			set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
	}
	return HAM_IGNORED;
}

public AT4_WeaponIdle(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_float(Weapon, 48, 4) <= 0.1)  {
			set_pdata_float(Weapon, 48, 4.0, 4)
			set_weapon_anim(Owner, 0)
		}
	}
	return HAM_IGNORED;
}

public AT4_PrimaryAttack(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		if(is_user_alive(Owner) && get_user_at4(Owner))
			return HAM_SUPERCEDE;
	}
	return HAM_IGNORED;
}

public AT4_Reload(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {		
			at4_clip[Owner] = -1;
			
			if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
				return HAM_SUPERCEDE;
			
			at4_clip[Owner] = get_pdata_int(Weapon, 51, 4);
			at4_reload[Owner] = true;
		}
	}
	return HAM_IGNORED;
}

public AT4_Reload_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && at4_clip[Owner] != -1) {			
			set_pdata_int(Weapon, 51, at4_clip[Owner], 4);
			set_pdata_float(Weapon, 48, get_pcvar_float(at4reloadtime), 4);
			set_pdata_float(Owner, 83, get_pcvar_float(at4reloadtime), 5);
			set_pdata_int(Weapon, 54, 1, 4);
			set_weapon_anim(Owner, 1)
		}
	}
	return HAM_IGNORED;
}

public AT4_PostFrame(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_int(Weapon, 54, 4) && get_pdata_float(Owner, 83, 5) <= 0.0) {
			new Temp = min(1 - get_pdata_int(Weapon, 51, 4), cs_get_user_bpammo(Owner, CSW_AT4));
			
			set_pdata_int(Weapon, 51, get_pdata_int(Weapon, 51, 4) + Temp, 4);
			cs_set_user_bpammo(Owner, CSW_AT4, cs_get_user_bpammo(Owner, CSW_AT4) - Temp);		
			set_pdata_int(Weapon, 54, 0, 4);
			
			at4_reload[Owner] = false;
		}
	}
	return HAM_IGNORED;
}

public AT4_Fire(id) {
	new Rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	
	if(pev_valid(Rocket)) {
		new Float:Origin[3], Float:Angles[3], Float:Velocity[3];
		engfunc(EngFunc_GetAttachment, id, 0, Origin, Angles);
		pev(id, pev_angles, Angles);
		
		set_pev(Rocket, pev_origin, Origin);
		set_pev(Rocket, pev_angles, Angles);
		set_pev(Rocket, pev_solid, SOLID_BBOX);
		set_pev(Rocket, pev_movetype, MOVETYPE_FLY);
		set_pev(Rocket, pev_classname, AT4_CLASS);
		
		if(at4_detector[id])
			set_pev(Rocket, pev_iuser3, 1);		
		else
			set_pev(Rocket, pev_iuser3, 0);		
		
		set_pev(Rocket, pev_owner, id);
		engfunc(EngFunc_SetModel, Rocket, AT4Model_S);
		
		set_pev(Rocket, pev_mins, {-3.0, -3.0, -3.0});
		set_pev(Rocket, pev_maxs, {3.0, 3.0, 3.0});
		
		velocity_by_aim(id, 2000, Velocity);
		set_pev(Rocket, pev_velocity, Velocity);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_BEAMFOLLOW); // TE id
		write_short(Rocket); // entity:attachment to follow
		write_short(at4_trail); // sprite index
		write_byte(3); // life in 0.1's
		write_byte(2); // line width in 0.1's
		write_byte(255); // r
		write_byte(255); // g
		write_byte(255); // b
		write_byte(200); // brightness
		message_end();
	}
	
	set_pev(Rocket, pev_iuser4, 0);		
	set_pev(Rocket, pev_nextthink, halflife_time() + 0.1);
}

public AT4_Think(Rocket) {
	if(is_valid_ent(Rocket)) {
		static Float:Origin[3];
		pev(Rocket, pev_origin, Origin);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_SPRITE);
		engfunc(EngFunc_WriteCoord, Origin[0]);
		engfunc(EngFunc_WriteCoord, Origin[1]);
		engfunc(EngFunc_WriteCoord, Origin[2]);
		write_short(at4_smoke);
		write_byte(2);
		write_byte(200);
		message_end();
		if(pev(Rocket, pev_iuser3) == 1) {
			if(pev(Rocket, pev_iuser4) == 0) {
				static Victim;
				Victim = FindClosesEnemy(Rocket);
				
				if(is_user_alive(Victim))
					set_pev(Rocket, pev_iuser4, Victim);
			}
			else {
				static Victim;
				Victim = pev(Rocket, pev_iuser4);
				
				if(is_user_alive(Victim)) {
					static Float:VicOrigin[3];
					pev(Victim, pev_origin, VicOrigin);
					
					hook_ent(Rocket, Victim, 2000.0);
				}
				else
					set_pev(Rocket, pev_iuser4, 0);
			} 
		}
		set_pev(Rocket, pev_nextthink, halflife_time() + 0.075);
	}
}

public AT4_LaserDot_Think(LaserDot) { 
	if(is_valid_ent(LaserDot)) {
		new Owner, Float:Origin[3];
		Owner = pev(LaserDot, pev_owner);
		pev(Owner, pev_origin, Origin);
		fm_get_aim_origin(Owner, Origin);
		
		set_pev(LaserDot, pev_origin, Origin);
		set_pev(LaserDot, pev_nextthink, halflife_time() + 0.001);
	}
}

public AT4_Touch(Rocket, touch) {
	if(is_valid_ent(Rocket)) {
		static Float:RocketOrigin[3];
		pev(Rocket, pev_origin, RocketOrigin);	
		new id = pev(Rocket, pev_owner);
		
		message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
		write_byte(TE_EXPLOSION);
		engfunc(EngFunc_WriteCoord, RocketOrigin[0]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[1]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[2]);
		write_short(at4_explode);	// sprite index
		write_byte(40);			// scale in 0.1's
		write_byte(30);			// framerate
		write_byte(0);			// flags
		message_end();
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		engfunc(EngFunc_WriteCoord, RocketOrigin[0])
		engfunc(EngFunc_WriteCoord, RocketOrigin[1])
		engfunc(EngFunc_WriteCoord, RocketOrigin[2])
		write_byte(random_num(46, 48))
		message_end()	
		
		static ClassName[32];
		pev(touch, pev_classname, ClassName, charsmax(ClassName));
		if(equal(ClassName, "player") && is_user_connected(touch) && is_user_alive(touch)) {
			if(!fm_get_user_godmode(touch) && get_user_team(touch) != get_user_team(id) && touch != id) {
				new Float:Damage
				pev(Rocket, pev_iuser3) == 1 ? (Damage = (get_pcvar_float(at4damage) / 2.0)) : (Damage = get_pcvar_float(at4damage))
				//make_blood(id, get_pcvar_num(at4damage))
				make_knockback(touch, RocketOrigin, get_pcvar_float(at4knockback) * Damage);	
				if(get_user_health(touch) > Damage)
					ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
				else		
					death_message(id, touch, "AT4");
			}	
		}
		else if(equal(ClassName, "func_breakable")) {		
			if(entity_get_float(touch, EV_FL_health) <= get_pcvar_num(at4damage))
				force_use(id, touch);
		}
		
		for(new Victim = 1; Victim < get_maxplayers(); Victim++) {
			if(is_user_connected(Victim) && is_user_alive(Victim) && !fm_get_user_godmode(Victim) && get_user_team(Victim) != get_user_team(id) && Victim != id && Victim != touch) {
				new Float:VictimOrigin[3], Float:Distance_F, Distance;
				pev(Victim, pev_origin, VictimOrigin);
				Distance_F = get_distance_f(RocketOrigin, VictimOrigin);
				Distance = floatround(Distance_F);
				if(Distance <= get_pcvar_float(at4radius)) {								
					new Float:DistanceRatio, Float:Damage;
					DistanceRatio = floatdiv(float(Distance), get_pcvar_float(at4radius));
					Damage = get_pcvar_float(at4damage) - floatround(floatmul(get_pcvar_float(at4damage), DistanceRatio));
					//make_blood(id, get_pcvar_num(at4damage))
					make_knockback(Victim, RocketOrigin, get_pcvar_float(at4knockback)*Damage);	
					if(get_user_health(touch) > Damage)
						ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
					else		
						death_message(id, touch, "AT4");
				}
			}
		}		
		engfunc(EngFunc_RemoveEntity, Rocket);
	}
}

public Hook_AT4(id) {
	engclient_cmd(id, weapon_at4);
	return PLUGIN_HANDLED
}

public get_user_at4(id)
	return HaveAT4[id];

public set_user_at4(id, at4) {
	if(at4) {
		if(!HaveAT4[id]) {
			drop_primary_weapons(id);
			HaveAT4[id] = true;
			at4_reload[id] = false;
			
			WeaponList(id, AT4_WEAPONKEY)
			fm_give_item(id, weapon_at4);
			
			new Clip = fm_get_user_weapon_entity(id, CSW_AT4);
			cs_set_weapon_ammo(Clip, 1);
		}
	}
	else {
		if(HaveAT4[id])
			HaveAT4[id] = false;
	}
}

stock FindClosesEnemy(entid) {
	new Float:Dist;
	new Float:maxdistance=300.0;
	new indexid=0;
	for(new i=1;i<=get_maxplayers();i++){
		if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i)
		&& pev(entid, pev_owner) != i && cs_get_user_team(pev(entid, pev_owner)) != cs_get_user_team(i)) {
			Dist = entity_range(entid, i);
			if(Dist <= maxdistance) {
				maxdistance=Dist;
				indexid=i;
				
				return indexid;
			}
		}	
	}	
	return 0;
}
stock bool:can_see_fm(entindex1, entindex2) {
	if(!entindex1 || !entindex2)
		return false;
	
	if(pev_valid(entindex1) && pev_valid(entindex1)) {
		new flags = pev(entindex1, pev_flags);
		if(flags & EF_NODRAW || flags & FL_NOTARGET) {
			return false;
		}
		
		new Float:lookerOrig[3];
		new Float:targetBaseOrig[3];
		new Float:targetOrig[3];
		new Float:temp[3];
		
		pev(entindex1, pev_origin, lookerOrig);
		pev(entindex1, pev_view_ofs, temp);
		lookerOrig[0] += temp[0];
		lookerOrig[1] += temp[1];
		lookerOrig[2] += temp[2];
		
		pev(entindex2, pev_origin, targetBaseOrig);
		pev(entindex2, pev_view_ofs, temp);
		targetOrig[0] = targetBaseOrig[0] + temp[0];
		targetOrig[1] = targetBaseOrig[1] + temp[1];
		targetOrig[2] = targetBaseOrig[2] + temp[2];
		
		engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the had of seen player
		if(get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) {
			return false;
		} 
		else {
			new Float:flFraction;
			get_tr2(0, TraceResult:TR_flFraction, flFraction);
			if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
				return true;
			}
			else {
				targetOrig[0] = targetBaseOrig[0];
				targetOrig[1] = targetBaseOrig[1];
				targetOrig[2] = targetBaseOrig[2];
				engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the body of seen player
				get_tr2(0, TraceResult:TR_flFraction, flFraction);
				if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
					return true;
				}
				else {
					targetOrig[0] = targetBaseOrig[0];
					targetOrig[1] = targetBaseOrig[1];
					targetOrig[2] = targetBaseOrig[2] - 17.0;
					engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the legs of seen player
					get_tr2(0, TraceResult:TR_flFraction, flFraction);
					if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
stock hook_ent(ent, victim, Float:speed) {
	static Float:fl_Velocity[3];
	static Float:VicOrigin[3], Float:EntOrigin[3];
	
	pev(ent, pev_origin, EntOrigin);
	pev(victim, pev_origin, VicOrigin);
	
	static Float:distance_f;
	distance_f = get_distance_f(EntOrigin, VicOrigin);
	
	if(distance_f > 10.0) {
		new Float:fl_Time = distance_f / speed;
		
		fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time;
		fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time;
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time;
	}
	else {
		fl_Velocity[0] = 0.0;
		fl_Velocity[1] = 0.0;
		fl_Velocity[2] = 0.0;
	}
	
	entity_set_vector(ent, EV_VEC_velocity, fl_Velocity);
}
public WeaponList(id, WEAPONKEY) {
	new Message_WeaponList = get_user_msgid("WeaponList")
	
	switch(WEAPONKEY) {
		case AT4_WEAPONKEY: {
			message_begin(MSG_ONE, Message_WeaponList, _, id);
			write_string(HaveAT4[id] ? "furien30_at4" : "weapon_m249");			// WeaponName
			write_byte(3);				// PrimaryAmmoID
			write_byte(200);			// PrimaryAmmoMaxAmount
			write_byte(-1);				// SecondaryAmmoID
			write_byte(-1);				// SecondaryAmmoMaxAmount
			write_byte(0);				// SlotID (0...N)
			write_byte(4);				// NumberInSlot (1...N)
			write_byte(CSW_AT4);			// WeaponID
			write_byte(0);				// Flags
			message_end();
		}
	}
}
	stock death_message(Killer, Victim, const Weapon[]) {
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET);
	ExecuteHamB(Ham_Killed, Victim, Killer, 2);
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT);
	
	make_deathmsg(Killer, Victim, 0, Weapon);
	cs_set_user_money(Killer, cs_get_user_money(Killer) + 300);
	
	if(is_user_connected(Killer)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Killer); // id
		write_short(pev(Killer, pev_frags)); // frags
		write_short(cs_get_user_deaths(Killer)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Killer)); // team
		message_end();
	}
	if(is_user_connected(Victim)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Victim); // id
		write_short(pev(Victim, pev_frags)); // frags
		write_short(cs_get_user_deaths(Victim)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Victim)); // team
		message_end();
	}
}

public make_knockback(Victim, Float:origin[3], Float:maxspeed) {
	new Float:fVelocity[3];
	kickback(Victim, origin, maxspeed, fVelocity);
	entity_set_vector(Victim, EV_VEC_velocity, fVelocity);
	
	return(1);
}

stock kickback(ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3]) {
	new Float:fEntOrigin[3];
	entity_get_vector(ent, EV_VEC_origin, fEntOrigin);
	
	new Float:fDistance[3];
	fDistance[0] = fEntOrigin[0] - fOrigin[0];
	fDistance[1] = fEntOrigin[1] - fOrigin[1];
	fDistance[2] = fEntOrigin[2] - fOrigin[2];
	new Float:fTime = (vector_distance(fEntOrigin,fOrigin) / fSpeed);
	fVelocity[0] = fDistance[0] / fTime;
	fVelocity[1] = fDistance[1] / fTime;
	fVelocity[2] = fDistance[2] / fTime;
	
	return(fVelocity[0] && fVelocity[1] && fVelocity[2]);
}

stock make_bullet(id, Float:Origin[3]) {
	// Find target
	new target, body;
	get_user_aiming(id, target, body, 999999);
	
	if(target > 0 && target <= get_maxplayers()) {
		new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3];
		pev(id, pev_origin, fStart);
		
		velocity_by_aim(id, 64, fVel);
		
		fStart[0] = Origin[0];
		fStart[1] = Origin[1];
		fStart[2] = Origin[2];
		fEnd[0] = fStart[0]+fVel[0];
		fEnd[1] = fStart[1]+fVel[1];
		fEnd[2] = fStart[2]+fVel[2];
		
		new res;
		engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res);
		get_tr2(res, TR_vecEndPos, fRes);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY) ;
		write_byte(TE_BLOODSPRITE);
		write_coord(floatround(fStart[0]));
		write_coord(floatround(fStart[1]));
		write_coord(floatround(fStart[2]));
		write_short(BloodSpray);
		write_short(BloodDrop);
		write_byte(70);
		write_byte(random_num(1,2));
		message_end();
		
		
	} 
	else {
		new decal = 41;
		
		if(target) {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_DECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			write_short(target);
			message_end();
		} 
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_WORLDDECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			message_end();
		}
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_GUNSHOTDECAL);
		write_coord(floatround(Origin[0]));
		write_coord(floatround(Origin[1]));
		write_coord(floatround(Origin[2]));
		write_short(id);
		write_byte(decal);
		message_end();
	}
}

stock set_weapon_anim(id, anim) {
	set_pev(id, pev_weaponanim, anim);
	if(is_user_connected(id)) {
		message_begin(MSG_ONE, SVC_WEAPONANIM, _, id);
		write_byte(anim);
		write_byte(pev(id, pev_body));
		message_end();
	}
}

stock get_damage_body(body, Float:damage) {
	switch(body) {
		case HIT_HEAD:
			damage *= 2.0;
		case HIT_STOMACH: 
			damage *= 1.0;
		case HIT_CHEST: 
			damage *= 1.5;
		case HIT_LEFTARM: 
			damage *= 0.75;
		case HIT_RIGHTARM: 
			damage *= 0.75;
		case HIT_LEFTLEG: 
			damage *= 0.75;
		case HIT_RIGHTLEG: 
			damage *= 0.75;
		default: 
		damage *= 1.0;
	}
	
	return floatround(damage);
}	

stock drop_primary_weapons(Player) {
	static weapons[32], num, i, weaponid;
	num = 0;
	get_user_weapons(Player, weapons, num);
	
	for(i = 0; i < num; i++) {
		weaponid = weapons ;
		
		if(((1<<weaponid) & PRIMARY_WEAPONS_BITSUM)) {
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock drop_secondary_weapons(Player) {
	// Get user weapons
	static weapons [32], num, i, weaponid;
	num = 0; // reset passed weapons count(bugfix)
	get_user_weapons(Player, weapons, num);
	
	// Loop through them and drop primaries
	for(i = 0; i < num; i++) {
		// Prevent re-indexing the array
		weaponid = weapons ;
		
		// We definetely are holding primary gun
		if(((1<<weaponid) & SECONDARY_WEAPONS_BITSUM)) {
			// Get weapon entity
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock fm_get_user_bpammo(index, weapon) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	return offset ? get_pdata_int(index, offset) : 0
}

stock fm_set_user_bpammo(index, weapon, amount) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	
	if(offset) 
		set_pdata_int(index, offset, amount)
	
	return 1
}

#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )

stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 0.01, Float:holdtime = 3.0, Float:fadeintime = 0.01, Float:fadeouttime = 0.01) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/


Dacă s-ar putea să mi-o faceți pe native , mulțumesc .

Native Cod | Afiseaza codul
native set_user_at4( id, at4)


AT4 = Bazooka CSO .

Dacă se poate să îmi dați plugin-ul modificat prin PM , că nu vreau să își ia altcineva plugin-ul , și de aceea să mi-l dați prin PM .

P.S. Nu dau la nimeni SURSA / PLUGIN-UL , mulțumesc.
Last edited by qPro on 04 Jul 2014, 12:12, edited 1 time in total.
IG-BOOST.org - Instagram Followers Best, Cheap, Reliable
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2155
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 33 times
Been thanked: 349 times
Contact:

03 Jul 2014, 23:07

| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "AT4"
#define VERSION "1.0"
#define AUTHOR "Aragon*"
#define AMMOWP_NULL (1<<0 | 1<<CSW_KNIFE | 1<<CSW_FLASHBANG | 1<<CSW_HEGRENADE | 1<<CSW_SMOKEGRENADE | 1<<CSW_C4)
#define DMG_HEGRENADE (1<<24)
new PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
new const WeaponsAmmo[][] = {
	{ -1, -1 },
	{ 13, 52 },
	{ -1, -1 },
	{ 10, 90 },
	{ -1, -1 },
	{ 7, 32 },
	{ -1, -1 },
	{ 30, 100 },
	{ 30, 90 },
	{ -1, -1 },
	{ 30, 120 },
	{ 20, 100 },
	{ 25, 100 },
	{ 30, 90 },
	{ 35, 90 },
	{ 25, 90 },
	{ 12, 100 },
	{ 20, 120 },
	{ 10, 30 },
	{ 30, 120 },
	{ 100, 200 },
	{ 8, 32 },
	{ 30, 90 },
	{ 30, 120 },
	{ 20, 90 },
	{ -1, -1 },
	{ 7, 35 },
	{ 30, 90 },
	{ 30, 90 },
	{ -1, -1 },
	{ 50, 100 }
}

#define AT4_WEAPONKEY		100
#define weapon_at4		"weapon_m249"
#define CSW_AT4			CSW_M249
#define AT4_CLASS		"at4ex_rocket"
#define AT4_CLASS_LASERDOT	"at4_laserdot"
#define at4_shotdelay		4.0 // Refire rate
new AT4Model_V[] = "models/furien30_weapons/Primary/v_at4.mdl";
new AT4Model_P[] = "models/furien30_weapons/Primary/p_at4.mdl";
new AT4Model_W[] = "models/furien30_weapons/Primary/w_at4.mdl";
new AT4Model_S[] = "models/furien30_weapons/Primary/s_at4rocket.mdl";
new AT4Model_LASER[] = "sprites/laserdot.spr";
new AT4_Sound[][] = {
	"weapons/at4_shoot1.wav",
	"weapons/at4_clipin1.wav",
	"weapons/at4_clipin2.wav",
	"weapons/at4_clipin3.wav",
	"weapons/at4_draw.wav"
};
new AT4_Generic[][] = {
	"sprites/furien30_at4.txt",
	"sprites/furien30_weapons/At4.spr",
	"sprites/furien30_weapons/640hud7x.spr"
};

new bool:HaveAT4[33], at4_clip[33], at4_reload[33], at4_detector[33], at4_event, at4_smoke, at4_trail, at4_explode;
new at4damage, at4radius, at4knockback, at4reloadtime;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_logevent("RoundStart", 2, "1=Round_Start");
	register_event("CurWeapon", "EVENT_CurWeapon", "be", "1=1")

	AT4_Init();
}
public EVENT_CurWeapon(id) {
	if(is_user_connected(id) && is_user_alive(id)) {
		static Weapon
		Weapon = read_data(2)
		
		if(!(AMMOWP_NULL &(1<<Weapon))) {		
			if(fm_get_user_bpammo(id, Weapon) < WeaponsAmmo[Weapon][1]) 
				fm_set_user_bpammo(id, Weapon, WeaponsAmmo[Weapon][1])
		}
	}
}

public plugin_precache() {
	AT4_Precache();
}
public plugin_natives() {
	AT4_Natives();
}
public RoundStart() {
	remove_entity_name(AT4_CLASS);
	remove_entity_name(AT4_CLASS_LASERDOT);
}
AT4_Init() {
	register_clcmd("furien30_at4", "Hook_AT4");
	
	register_event("CurWeapon", "AT4_ViewModel", "be", "1=1");
	register_event("WeapPickup","AT4_ViewModel","b","1=19");
	
	register_forward(FM_SetModel, "AT4_WorldModel", 1);
	register_forward(FM_UpdateClientData, "AT4_UpdateClientData_Post", 1);
	register_forward(FM_PlaybackEvent, "AT4_PlaybackEvent");
	register_forward(FM_PlayerPreThink, "AT4_PreThink");
	register_forward(FM_CmdStart, "AT4_CmdStart");	
	
	RegisterHam(Ham_Item_AddToPlayer, weapon_at4, "AT4_AddToPlayer");
	RegisterHam(Ham_Item_Deploy , weapon_at4, "AT4_Deploy_Post", 1);
	RegisterHam(Ham_Item_Holster , weapon_at4, "AT4_Holster");
	RegisterHam(Ham_Weapon_WeaponIdle, weapon_at4, "AT4_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_at4, "AT4_PrimaryAttack");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload_Post", 1);
	RegisterHam(Ham_Item_PostFrame, weapon_at4, "AT4_PostFrame");	
	
	register_think(AT4_CLASS, "AT4_Think");
	register_think(AT4_CLASS_LASERDOT, "AT4_LaserDot_Think");
	
	register_touch(AT4_CLASS, "*", "AT4_Touch");
	
	at4damage = register_cvar("furien30_at4_damage", "300.0");		//| AT4 Damage |//
	at4radius = register_cvar("furien30_at4_radius", "220.0");		//| AT4 Radius |//
	at4knockback = register_cvar("furien30_at4_knockback", "4.0");		//| At4 KnockBack |//
	at4reloadtime = register_cvar("furien30_at4_reload_time", "2.33");	//| AT4 Reload Time |//

	register_concmd ( "amx_give_at4", "ConCMDAt4", ADMIN_RCON, "< player >" );
}

AT4_Precache() {
	register_forward(FM_PrecacheEvent, "AT4_PrecacheEvent_Post", 1);

	at4_smoke = precache_model("sprites/effects/rainsplash.spr");
	at4_trail = precache_model("sprites/xbeam3.spr");
	at4_explode = precache_model("sprites/furien30_weapons/explode.spr");
	
	precache_model(AT4Model_V);
	precache_model(AT4Model_P);
	precache_model(AT4Model_W);
	precache_model(AT4Model_S);
	precache_model(AT4Model_LASER);
	
	for(new i = 0; i < sizeof(AT4_Sound); i++)
		engfunc(EngFunc_PrecacheSound, AT4_Sound);	
	for(new i = 0; i < sizeof(AT4_Generic); i++)
		engfunc(EngFunc_PrecacheGeneric, AT4_Generic);
}

public ConCMDAt4( id, level, cid )
{
	if( !cmd_access( id, level, cid, 2 ) )
        {
		return 1;
        }

	new szFirstArg[ 32 ];
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );

	if( equal( szFirstArg, "" ) )
	{
		client_cmd( id, "echo amx_give_at4 < nick >" );
		return 1;
	}

	new iPlayer = cmd_target( id, szFirstArg, ( CMDTARGET_NO_BOTS ) );

	if( !iPlayer )
	{
		client_cmd( id, "echo * Jucatorul specificat nu a fost gasit !" );
		return 1;
	}

	drop_primary_weapons( iPlayer );

	HaveAT4[ iPlayer ] = true;
	at4_reload[ iPlayer ] = false;

	WeaponList( iPlayer, AT4_WEAPONKEY )
	fm_give_item( iPlayer, weapon_at4 );

	new Clip = fm_get_user_weapon_entity( iPlayer, CSW_AT4 );
	cs_set_weapon_ammo( Clip, 1 );

	new szPlayerName[ 32 ], szAdminName[ 32 ];

	get_user_name( iPlayer, szPlayerName, 31 );
	get_user_name( id, szAdminName, 31 );

	ColorChat( 0, "!y[!gADM!N!y]!t %s!y: i-a dat un!g AT4!y jucatorului!t %s", szAdminName, szPlayerName );
	ColorChat( iPlayer, "!yFelicitari ! Tocmai ai primit un!g AT4!y de la ADMIN-ul!t %s", szAdminName );

	return 1;
}

AT4_Natives() {
	register_native("get_user_at4", "get_user_at4", 1);
	register_native("set_user_at4", "set_user_at4", 1);
}

public AT4_ViewModel(id) {
	if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
		set_pev(id, pev_viewmodel2, AT4Model_V);
		set_pev(id, pev_weaponmodel2, AT4Model_P);
		set_pdata_int(id, 361, get_pdata_int(id, 361) | (1<<6));
	}
}

public AT4_WorldModel(entity, model[]) {
	if(is_valid_ent(entity)) {
		static ClassName[33];
		entity_get_string(entity, EV_SZ_classname, ClassName, charsmax(ClassName));
		
		if(equal(ClassName, "weaponbox")) {
			new Owner = entity_get_edict(entity, EV_ENT_owner);	
			new _AT4 = find_ent_by_owner(-1, weapon_at4, entity);
			
			if(get_user_at4(Owner) && is_valid_ent(_AT4) && equal(model, "models/w_m249.mdl")) {
				entity_set_int(_AT4, EV_INT_impulse, AT4_WEAPONKEY);
				HaveAT4[Owner] = false;
				entity_set_model(entity, AT4Model_W);
				set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
				new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, Owner);
				if(is_valid_ent(Laser))
					remove_entity(Laser);
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_UpdateClientData_Post(id, sendweapons, cd_handle) {
	if(is_user_alive(id) && is_user_connected(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
		set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
	return FMRES_IGNORED;
}

public AT4_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) {
	if(is_user_connected(invoker) && eventid == at4_event)
		playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
	return FMRES_IGNORED;
}

public AT4_PrecacheEvent_Post(type, const name[]) {
	if (equal("events/m249.sc", name))
		at4_event = get_orig_retval();
	return FMRES_IGNORED;
}

public AT4_PreThink(id) {
	if(is_user_alive(id) && is_user_connected(id)) {
		if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && at4_detector[id]) {
			new Float: origin[3];
			fm_get_aim_origin(id,origin);
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			
			if(!is_valid_ent(Laser)) {
				new at4_laser = create_entity("info_target");	
				set_pev(at4_laser, pev_classname, AT4_CLASS_LASERDOT);
				set_pev(at4_laser, pev_owner, id);
				engfunc(EngFunc_SetModel, at4_laser, AT4Model_LASER);
				set_pev(at4_laser, pev_renderfx, kRenderFxNoDissipation);
				set_pev(at4_laser, pev_rendermode, kRenderGlow);
				set_pev(at4_laser, pev_renderamt, 255.0);
				set_pev(at4_laser, pev_light_level, 255.0);
				set_pev(at4_laser, pev_scale, 1.0);
				set_pev(at4_laser, pev_movetype, MOVETYPE_FLY);
				set_pev(at4_laser, pev_nextthink, halflife_time() + 0.001);
			}
		}
		else {
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			if(is_valid_ent(Laser))
				remove_entity(Laser);
		}
	}
}

public AT4_CmdStart(id, uc_handle, seed) {
	if(is_user_alive(id) && is_user_connected(id)) {
		static CurButton;
		CurButton = get_uc(uc_handle, UC_Buttons);
		new Float:NextAttack = get_pdata_float(id, 83, 5);
		
		static _AT4;
		_AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);	
		
		if(CurButton & IN_ATTACK) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
				if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
					set_weapon_anim(id, 1);
					emit_sound(id, CHAN_WEAPON, AT4_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM);
					AT4_Fire(id);
					new Float:PunchAngles[3];
					PunchAngles[0] = random_float(-7.0, -10.0), PunchAngles[1] = 0.0, PunchAngles[2] = 0.0;
					set_pev(id, pev_punchangle, PunchAngles);
					cs_set_weapon_ammo(_AT4, cs_get_weapon_ammo(_AT4) - 1);
					if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
						set_pdata_float(id, 83, at4_shotdelay, 5);
						set_pdata_float(_AT4, 48, 0.3, 4)
					}
				}
				CurButton &= ~IN_ATTACK;
				set_uc(uc_handle, UC_Buttons, CurButton);
			}
		}
		
		if(CurButton & IN_ATTACK2 && !(pev(id, pev_oldbuttons) & IN_ATTACK2)) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && NextAttack <= 0.0) {
				if(at4_detector[id])
					at4_detector[id] = false;
				else
					at4_detector[id] = true;
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_AddToPlayer(Weapon, id) {
	if(is_valid_ent(Weapon) && is_user_connected(id) && entity_get_int(Weapon, EV_INT_impulse) == AT4_WEAPONKEY) {
		HaveAT4[id] = true;
		WeaponList(id, AT4_WEAPONKEY)
		entity_set_int(Weapon, EV_INT_impulse, 0);
	}
	return HAM_IGNORED;
}

public AT4_Deploy_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {
			set_pev(Owner, pev_viewmodel2, AT4Model_V);
			set_pev(Owner, pev_weaponmodel2, AT4Model_P);
			set_weapon_anim(Owner, 4)
			
			set_pdata_float(Owner, 83, 1.2, 5);
			set_pdata_float(Weapon, 48, 1.2, 4)
			
			if(cs_get_weapon_ammo(Weapon) > 0)
				at4_reload[Owner] = 0;
		}
	}
	return HAM_IGNORED;
}

public AT4_Holster(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner))
			set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
	}
	return HAM_IGNORED;
}

public AT4_WeaponIdle(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_float(Weapon, 48, 4) <= 0.1)  {
			set_pdata_float(Weapon, 48, 4.0, 4)
			set_weapon_anim(Owner, 0)
		}
	}
	return HAM_IGNORED;
}

public AT4_PrimaryAttack(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		if(is_user_alive(Owner) && get_user_at4(Owner))
			return HAM_SUPERCEDE;
	}
	return HAM_IGNORED;
}

public AT4_Reload(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {		
			at4_clip[Owner] = -1;
			
			if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
				return HAM_SUPERCEDE;
			
			at4_clip[Owner] = get_pdata_int(Weapon, 51, 4);
			at4_reload[Owner] = true;
		}
	}
	return HAM_IGNORED;
}

public AT4_Reload_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && at4_clip[Owner] != -1) {			
			set_pdata_int(Weapon, 51, at4_clip[Owner], 4);
			set_pdata_float(Weapon, 48, get_pcvar_float(at4reloadtime), 4);
			set_pdata_float(Owner, 83, get_pcvar_float(at4reloadtime), 5);
			set_pdata_int(Weapon, 54, 1, 4);
			set_weapon_anim(Owner, 1)
		}
	}
	return HAM_IGNORED;
}

public AT4_PostFrame(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_int(Weapon, 54, 4) && get_pdata_float(Owner, 83, 5) <= 0.0) {
			new Temp = min(1 - get_pdata_int(Weapon, 51, 4), cs_get_user_bpammo(Owner, CSW_AT4));
			
			set_pdata_int(Weapon, 51, get_pdata_int(Weapon, 51, 4) + Temp, 4);
			cs_set_user_bpammo(Owner, CSW_AT4, cs_get_user_bpammo(Owner, CSW_AT4) - Temp);		
			set_pdata_int(Weapon, 54, 0, 4);
			
			at4_reload[Owner] = false;
		}
	}
	return HAM_IGNORED;
}

public AT4_Fire(id) {
	new Rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	
	if(pev_valid(Rocket)) {
		new Float:Origin[3], Float:Angles[3], Float:Velocity[3];
		engfunc(EngFunc_GetAttachment, id, 0, Origin, Angles);
		pev(id, pev_angles, Angles);
		
		set_pev(Rocket, pev_origin, Origin);
		set_pev(Rocket, pev_angles, Angles);
		set_pev(Rocket, pev_solid, SOLID_BBOX);
		set_pev(Rocket, pev_movetype, MOVETYPE_FLY);
		set_pev(Rocket, pev_classname, AT4_CLASS);
		
		if(at4_detector[id])
			set_pev(Rocket, pev_iuser3, 1);		
		else
			set_pev(Rocket, pev_iuser3, 0);		
		
		set_pev(Rocket, pev_owner, id);
		engfunc(EngFunc_SetModel, Rocket, AT4Model_S);
		
		set_pev(Rocket, pev_mins, {-3.0, -3.0, -3.0});
		set_pev(Rocket, pev_maxs, {3.0, 3.0, 3.0});
		
		velocity_by_aim(id, 2000, Velocity);
		set_pev(Rocket, pev_velocity, Velocity);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_BEAMFOLLOW); // TE id
		write_short(Rocket); // entity:attachment to follow
		write_short(at4_trail); // sprite index
		write_byte(3); // life in 0.1's
		write_byte(2); // line width in 0.1's
		write_byte(255); // r
		write_byte(255); // g
		write_byte(255); // b
		write_byte(200); // brightness
		message_end();
	}
	
	set_pev(Rocket, pev_iuser4, 0);		
	set_pev(Rocket, pev_nextthink, halflife_time() + 0.1);
}

public AT4_Think(Rocket) {
	if(is_valid_ent(Rocket)) {
		static Float:Origin[3];
		pev(Rocket, pev_origin, Origin);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_SPRITE);
		engfunc(EngFunc_WriteCoord, Origin[0]);
		engfunc(EngFunc_WriteCoord, Origin[1]);
		engfunc(EngFunc_WriteCoord, Origin[2]);
		write_short(at4_smoke);
		write_byte(2);
		write_byte(200);
		message_end();
		if(pev(Rocket, pev_iuser3) == 1) {
			if(pev(Rocket, pev_iuser4) == 0) {
				static Victim;
				Victim = FindClosesEnemy(Rocket);
				
				if(is_user_alive(Victim))
					set_pev(Rocket, pev_iuser4, Victim);
			}
			else {
				static Victim;
				Victim = pev(Rocket, pev_iuser4);
				
				if(is_user_alive(Victim)) {
					static Float:VicOrigin[3];
					pev(Victim, pev_origin, VicOrigin);
					
					hook_ent(Rocket, Victim, 2000.0);
				}
				else
					set_pev(Rocket, pev_iuser4, 0);
			} 
		}
		set_pev(Rocket, pev_nextthink, halflife_time() + 0.075);
	}
}

public AT4_LaserDot_Think(LaserDot) { 
	if(is_valid_ent(LaserDot)) {
		new Owner, Float:Origin[3];
		Owner = pev(LaserDot, pev_owner);
		pev(Owner, pev_origin, Origin);
		fm_get_aim_origin(Owner, Origin);
		
		set_pev(LaserDot, pev_origin, Origin);
		set_pev(LaserDot, pev_nextthink, halflife_time() + 0.001);
	}
}

public AT4_Touch(Rocket, touch) {
	if(is_valid_ent(Rocket)) {
		static Float:RocketOrigin[3];
		pev(Rocket, pev_origin, RocketOrigin);	
		new id = pev(Rocket, pev_owner);
		
		message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
		write_byte(TE_EXPLOSION);
		engfunc(EngFunc_WriteCoord, RocketOrigin[0]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[1]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[2]);
		write_short(at4_explode);	// sprite index
		write_byte(40);			// scale in 0.1's
		write_byte(30);			// framerate
		write_byte(0);			// flags
		message_end();
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		engfunc(EngFunc_WriteCoord, RocketOrigin[0])
		engfunc(EngFunc_WriteCoord, RocketOrigin[1])
		engfunc(EngFunc_WriteCoord, RocketOrigin[2])
		write_byte(random_num(46, 48))
		message_end()	
		
		static ClassName[32];
		pev(touch, pev_classname, ClassName, charsmax(ClassName));
		if(equal(ClassName, "player") && is_user_connected(touch) && is_user_alive(touch)) {
			if(!fm_get_user_godmode(touch) && get_user_team(touch) != get_user_team(id) && touch != id) {
				new Float:Damage
				pev(Rocket, pev_iuser3) == 1 ? (Damage = (get_pcvar_float(at4damage) / 2.0)) : (Damage = get_pcvar_float(at4damage))
				//make_blood(id, get_pcvar_num(at4damage))
				make_knockback(touch, RocketOrigin, get_pcvar_float(at4knockback) * Damage);	
				if(get_user_health(touch) > Damage)
					ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
				else		
					death_message(id, touch, "AT4");
			}	
		}
		else if(equal(ClassName, "func_breakable")) {		
			if(entity_get_float(touch, EV_FL_health) <= get_pcvar_num(at4damage))
				force_use(id, touch);
		}
		
		for(new Victim = 1; Victim < get_maxplayers(); Victim++) {
			if(is_user_connected(Victim) && is_user_alive(Victim) && !fm_get_user_godmode(Victim) && get_user_team(Victim) != get_user_team(id) && Victim != id && Victim != touch) {
				new Float:VictimOrigin[3], Float:Distance_F, Distance;
				pev(Victim, pev_origin, VictimOrigin);
				Distance_F = get_distance_f(RocketOrigin, VictimOrigin);
				Distance = floatround(Distance_F);
				if(Distance <= get_pcvar_float(at4radius)) {								
					new Float:DistanceRatio, Float:Damage;
					DistanceRatio = floatdiv(float(Distance), get_pcvar_float(at4radius));
					Damage = get_pcvar_float(at4damage) - floatround(floatmul(get_pcvar_float(at4damage), DistanceRatio));
					//make_blood(id, get_pcvar_num(at4damage))
					make_knockback(Victim, RocketOrigin, get_pcvar_float(at4knockback)*Damage);	
					if(get_user_health(touch) > Damage)
						ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
					else		
						death_message(id, touch, "AT4");
				}
			}
		}		
		engfunc(EngFunc_RemoveEntity, Rocket);
	}
}

public Hook_AT4(id) {
	engclient_cmd(id, weapon_at4);
	return PLUGIN_HANDLED
}

public get_user_at4(id)
	return HaveAT4[id];

public set_user_at4(id, at4) {
	if(at4) {
		if(!HaveAT4[id]) {
			drop_primary_weapons(id);
			HaveAT4[id] = true;
			at4_reload[id] = false;
			
			WeaponList(id, AT4_WEAPONKEY)
			fm_give_item(id, weapon_at4);
			
			new Clip = fm_get_user_weapon_entity(id, CSW_AT4);
			cs_set_weapon_ammo(Clip, 1);
		}
	}
	else {
		if(HaveAT4[id])
			HaveAT4[id] = false;
	}
}

stock FindClosesEnemy(entid) {
	new Float:Dist;
	new Float:maxdistance=300.0;
	new indexid=0;
	for(new i=1;i<=get_maxplayers();i++){
		if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i)
		&& pev(entid, pev_owner) != i && cs_get_user_team(pev(entid, pev_owner)) != cs_get_user_team(i)) {
			Dist = entity_range(entid, i);
			if(Dist <= maxdistance) {
				maxdistance=Dist;
				indexid=i;
				
				return indexid;
			}
		}	
	}	
	return 0;
}
stock bool:can_see_fm(entindex1, entindex2) {
	if(!entindex1 || !entindex2)
		return false;
	
	if(pev_valid(entindex1) && pev_valid(entindex1)) {
		new flags = pev(entindex1, pev_flags);
		if(flags & EF_NODRAW || flags & FL_NOTARGET) {
			return false;
		}
		
		new Float:lookerOrig[3];
		new Float:targetBaseOrig[3];
		new Float:targetOrig[3];
		new Float:temp[3];
		
		pev(entindex1, pev_origin, lookerOrig);
		pev(entindex1, pev_view_ofs, temp);
		lookerOrig[0] += temp[0];
		lookerOrig[1] += temp[1];
		lookerOrig[2] += temp[2];
		
		pev(entindex2, pev_origin, targetBaseOrig);
		pev(entindex2, pev_view_ofs, temp);
		targetOrig[0] = targetBaseOrig[0] + temp[0];
		targetOrig[1] = targetBaseOrig[1] + temp[1];
		targetOrig[2] = targetBaseOrig[2] + temp[2];
		
		engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the had of seen player
		if(get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) {
			return false;
		} 
		else {
			new Float:flFraction;
			get_tr2(0, TraceResult:TR_flFraction, flFraction);
			if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
				return true;
			}
			else {
				targetOrig[0] = targetBaseOrig[0];
				targetOrig[1] = targetBaseOrig[1];
				targetOrig[2] = targetBaseOrig[2];
				engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the body of seen player
				get_tr2(0, TraceResult:TR_flFraction, flFraction);
				if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
					return true;
				}
				else {
					targetOrig[0] = targetBaseOrig[0];
					targetOrig[1] = targetBaseOrig[1];
					targetOrig[2] = targetBaseOrig[2] - 17.0;
					engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the legs of seen player
					get_tr2(0, TraceResult:TR_flFraction, flFraction);
					if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
stock hook_ent(ent, victim, Float:speed) {
	static Float:fl_Velocity[3];
	static Float:VicOrigin[3], Float:EntOrigin[3];
	
	pev(ent, pev_origin, EntOrigin);
	pev(victim, pev_origin, VicOrigin);
	
	static Float:distance_f;
	distance_f = get_distance_f(EntOrigin, VicOrigin);
	
	if(distance_f > 10.0) {
		new Float:fl_Time = distance_f / speed;
		
		fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time;
		fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time;
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time;
	}
	else {
		fl_Velocity[0] = 0.0;
		fl_Velocity[1] = 0.0;
		fl_Velocity[2] = 0.0;
	}
	
	entity_set_vector(ent, EV_VEC_velocity, fl_Velocity);
}
public WeaponList(id, WEAPONKEY) {
	new Message_WeaponList = get_user_msgid("WeaponList")
	
	switch(WEAPONKEY) {
		case AT4_WEAPONKEY: {
			message_begin(MSG_ONE, Message_WeaponList, _, id);
			write_string(HaveAT4[id] ? "furien30_at4" : "weapon_m249");			// WeaponName
			write_byte(3);				// PrimaryAmmoID
			write_byte(200);			// PrimaryAmmoMaxAmount
			write_byte(-1);				// SecondaryAmmoID
			write_byte(-1);				// SecondaryAmmoMaxAmount
			write_byte(0);				// SlotID (0...N)
			write_byte(4);				// NumberInSlot (1...N)
			write_byte(CSW_AT4);			// WeaponID
			write_byte(0);				// Flags
			message_end();
		}
	}
}
	stock death_message(Killer, Victim, const Weapon[]) {
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET);
	ExecuteHamB(Ham_Killed, Victim, Killer, 2);
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT);
	
	make_deathmsg(Killer, Victim, 0, Weapon);
	cs_set_user_money(Killer, cs_get_user_money(Killer) + 300);
	
	if(is_user_connected(Killer)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Killer); // id
		write_short(pev(Killer, pev_frags)); // frags
		write_short(cs_get_user_deaths(Killer)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Killer)); // team
		message_end();
	}
	if(is_user_connected(Victim)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Victim); // id
		write_short(pev(Victim, pev_frags)); // frags
		write_short(cs_get_user_deaths(Victim)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Victim)); // team
		message_end();
	}
}

public make_knockback(Victim, Float:origin[3], Float:maxspeed) {
	new Float:fVelocity[3];
	kickback(Victim, origin, maxspeed, fVelocity);
	entity_set_vector(Victim, EV_VEC_velocity, fVelocity);
	
	return(1);
}

stock kickback(ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3]) {
	new Float:fEntOrigin[3];
	entity_get_vector(ent, EV_VEC_origin, fEntOrigin);
	
	new Float:fDistance[3];
	fDistance[0] = fEntOrigin[0] - fOrigin[0];
	fDistance[1] = fEntOrigin[1] - fOrigin[1];
	fDistance[2] = fEntOrigin[2] - fOrigin[2];
	new Float:fTime = (vector_distance(fEntOrigin,fOrigin) / fSpeed);
	fVelocity[0] = fDistance[0] / fTime;
	fVelocity[1] = fDistance[1] / fTime;
	fVelocity[2] = fDistance[2] / fTime;
	
	return(fVelocity[0] && fVelocity[1] && fVelocity[2]);
}

stock make_bullet(id, Float:Origin[3]) {
	// Find target
	new target, body;
	get_user_aiming(id, target, body, 999999);
	
	if(target > 0 && target <= get_maxplayers()) {
		new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3];
		pev(id, pev_origin, fStart);
		
		velocity_by_aim(id, 64, fVel);
		
		fStart[0] = Origin[0];
		fStart[1] = Origin[1];
		fStart[2] = Origin[2];
		fEnd[0] = fStart[0]+fVel[0];
		fEnd[1] = fStart[1]+fVel[1];
		fEnd[2] = fStart[2]+fVel[2];
		
		new res;
		engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res);
		get_tr2(res, TR_vecEndPos, fRes);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY) ;
		write_byte(TE_BLOODSPRITE);
		write_coord(floatround(fStart[0]));
		write_coord(floatround(fStart[1]));
		write_coord(floatround(fStart[2]));
		write_short(BloodSpray);
		write_short(BloodDrop);
		write_byte(70);
		write_byte(random_num(1,2));
		message_end();
		
		
	} 
	else {
		new decal = 41;
		
		if(target) {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_DECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			write_short(target);
			message_end();
		} 
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_WORLDDECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			message_end();
		}
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_GUNSHOTDECAL);
		write_coord(floatround(Origin[0]));
		write_coord(floatround(Origin[1]));
		write_coord(floatround(Origin[2]));
		write_short(id);
		write_byte(decal);
		message_end();
	}
}

stock set_weapon_anim(id, anim) {
	set_pev(id, pev_weaponanim, anim);
	if(is_user_connected(id)) {
		message_begin(MSG_ONE, SVC_WEAPONANIM, _, id);
		write_byte(anim);
		write_byte(pev(id, pev_body));
		message_end();
	}
}

stock get_damage_body(body, Float:damage) {
	switch(body) {
		case HIT_HEAD:
			damage *= 2.0;
		case HIT_STOMACH: 
			damage *= 1.0;
		case HIT_CHEST: 
			damage *= 1.5;
		case HIT_LEFTARM: 
			damage *= 0.75;
		case HIT_RIGHTARM: 
			damage *= 0.75;
		case HIT_LEFTLEG: 
			damage *= 0.75;
		case HIT_RIGHTLEG: 
			damage *= 0.75;
		default: 
		damage *= 1.0;
	}
	
	return floatround(damage);
}	

stock drop_primary_weapons(Player) {
	static weapons[32], num, i, weaponid;
	num = 0;
	get_user_weapons(Player, weapons, num);
	
	for(i = 0; i < num; i++) {
		weaponid = weapons ;
		
		if(((1<<weaponid) & PRIMARY_WEAPONS_BITSUM)) {
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock drop_secondary_weapons(Player) {
	// Get user weapons
	static weapons [32], num, i, weaponid;
	num = 0; // reset passed weapons count(bugfix)
	get_user_weapons(Player, weapons, num);
	
	// Loop through them and drop primaries
	for(i = 0; i < num; i++) {
		// Prevent re-indexing the array
		weaponid = weapons ;
		
		// We definetely are holding primary gun
		if(((1<<weaponid) & SECONDARY_WEAPONS_BITSUM)) {
			// Get weapon entity
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock fm_get_user_bpammo(index, weapon) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	return offset ? get_pdata_int(index, offset) : 0
}

stock fm_set_user_bpammo(index, weapon, amount) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	
	if(offset) 
		set_pdata_int(index, offset, amount)
	
	return 1
}

#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )

stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 0.01, Float:holdtime = 3.0, Float:fadeintime = 0.01, Float:fadeouttime = 0.01) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
* Inactiv momentan.
qPro
Membru, skill 0
Membru, skill 0
Posts: 68
Joined: 15 Jun 2014, 12:27
Detinator Steam: Da
SteamID: Private. :d
Fond eXtream: 0
Has thanked: 4 times

04 Jul 2014, 12:11

Adryyy wrote:
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "AT4"
#define VERSION "1.0"
#define AUTHOR "Aragon*"
#define AMMOWP_NULL (1<<0 | 1<<CSW_KNIFE | 1<<CSW_FLASHBANG | 1<<CSW_HEGRENADE | 1<<CSW_SMOKEGRENADE | 1<<CSW_C4)
#define DMG_HEGRENADE (1<<24)
new PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
new const WeaponsAmmo[][] = {
	{ -1, -1 },
	{ 13, 52 },
	{ -1, -1 },
	{ 10, 90 },
	{ -1, -1 },
	{ 7, 32 },
	{ -1, -1 },
	{ 30, 100 },
	{ 30, 90 },
	{ -1, -1 },
	{ 30, 120 },
	{ 20, 100 },
	{ 25, 100 },
	{ 30, 90 },
	{ 35, 90 },
	{ 25, 90 },
	{ 12, 100 },
	{ 20, 120 },
	{ 10, 30 },
	{ 30, 120 },
	{ 100, 200 },
	{ 8, 32 },
	{ 30, 90 },
	{ 30, 120 },
	{ 20, 90 },
	{ -1, -1 },
	{ 7, 35 },
	{ 30, 90 },
	{ 30, 90 },
	{ -1, -1 },
	{ 50, 100 }
}

#define AT4_WEAPONKEY		100
#define weapon_at4		"weapon_m249"
#define CSW_AT4			CSW_M249
#define AT4_CLASS		"at4ex_rocket"
#define AT4_CLASS_LASERDOT	"at4_laserdot"
#define at4_shotdelay		4.0 // Refire rate
new AT4Model_V[] = "models/furien30_weapons/Primary/v_at4.mdl";
new AT4Model_P[] = "models/furien30_weapons/Primary/p_at4.mdl";
new AT4Model_W[] = "models/furien30_weapons/Primary/w_at4.mdl";
new AT4Model_S[] = "models/furien30_weapons/Primary/s_at4rocket.mdl";
new AT4Model_LASER[] = "sprites/laserdot.spr";
new AT4_Sound[][] = {
	"weapons/at4_shoot1.wav",
	"weapons/at4_clipin1.wav",
	"weapons/at4_clipin2.wav",
	"weapons/at4_clipin3.wav",
	"weapons/at4_draw.wav"
};
new AT4_Generic[][] = {
	"sprites/furien30_at4.txt",
	"sprites/furien30_weapons/At4.spr",
	"sprites/furien30_weapons/640hud7x.spr"
};

new bool:HaveAT4[33], at4_clip[33], at4_reload[33], at4_detector[33], at4_event, at4_smoke, at4_trail, at4_explode;
new at4damage, at4radius, at4knockback, at4reloadtime;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_logevent("RoundStart", 2, "1=Round_Start");
	register_event("CurWeapon", "EVENT_CurWeapon", "be", "1=1")

	AT4_Init();
}
public EVENT_CurWeapon(id) {
	if(is_user_connected(id) && is_user_alive(id)) {
		static Weapon
		Weapon = read_data(2)
		
		if(!(AMMOWP_NULL &(1<<Weapon))) {		
			if(fm_get_user_bpammo(id, Weapon) < WeaponsAmmo[Weapon][1]) 
				fm_set_user_bpammo(id, Weapon, WeaponsAmmo[Weapon][1])
		}
	}
}

public plugin_precache() {
	AT4_Precache();
}
public plugin_natives() {
	AT4_Natives();
}
public RoundStart() {
	remove_entity_name(AT4_CLASS);
	remove_entity_name(AT4_CLASS_LASERDOT);
}
AT4_Init() {
	register_clcmd("furien30_at4", "Hook_AT4");
	
	register_event("CurWeapon", "AT4_ViewModel", "be", "1=1");
	register_event("WeapPickup","AT4_ViewModel","b","1=19");
	
	register_forward(FM_SetModel, "AT4_WorldModel", 1);
	register_forward(FM_UpdateClientData, "AT4_UpdateClientData_Post", 1);
	register_forward(FM_PlaybackEvent, "AT4_PlaybackEvent");
	register_forward(FM_PlayerPreThink, "AT4_PreThink");
	register_forward(FM_CmdStart, "AT4_CmdStart");	
	
	RegisterHam(Ham_Item_AddToPlayer, weapon_at4, "AT4_AddToPlayer");
	RegisterHam(Ham_Item_Deploy , weapon_at4, "AT4_Deploy_Post", 1);
	RegisterHam(Ham_Item_Holster , weapon_at4, "AT4_Holster");
	RegisterHam(Ham_Weapon_WeaponIdle, weapon_at4, "AT4_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_at4, "AT4_PrimaryAttack");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload");
	RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload_Post", 1);
	RegisterHam(Ham_Item_PostFrame, weapon_at4, "AT4_PostFrame");	
	
	register_think(AT4_CLASS, "AT4_Think");
	register_think(AT4_CLASS_LASERDOT, "AT4_LaserDot_Think");
	
	register_touch(AT4_CLASS, "*", "AT4_Touch");
	
	at4damage = register_cvar("furien30_at4_damage", "300.0");		//| AT4 Damage |//
	at4radius = register_cvar("furien30_at4_radius", "220.0");		//| AT4 Radius |//
	at4knockback = register_cvar("furien30_at4_knockback", "4.0");		//| At4 KnockBack |//
	at4reloadtime = register_cvar("furien30_at4_reload_time", "2.33");	//| AT4 Reload Time |//

	register_concmd ( "amx_give_at4", "ConCMDAt4", ADMIN_RCON, "< player >" );
}

AT4_Precache() {
	register_forward(FM_PrecacheEvent, "AT4_PrecacheEvent_Post", 1);

	at4_smoke = precache_model("sprites/effects/rainsplash.spr");
	at4_trail = precache_model("sprites/xbeam3.spr");
	at4_explode = precache_model("sprites/furien30_weapons/explode.spr");
	
	precache_model(AT4Model_V);
	precache_model(AT4Model_P);
	precache_model(AT4Model_W);
	precache_model(AT4Model_S);
	precache_model(AT4Model_LASER);
	
	for(new i = 0; i < sizeof(AT4_Sound); i++)
		engfunc(EngFunc_PrecacheSound, AT4_Sound);	
	for(new i = 0; i < sizeof(AT4_Generic); i++)
		engfunc(EngFunc_PrecacheGeneric, AT4_Generic);
}

public ConCMDAt4( id, level, cid )
{
	if( !cmd_access( id, level, cid, 2 ) )
        {
		return 1;
        }

	new szFirstArg[ 32 ];
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );

	if( equal( szFirstArg, "" ) )
	{
		client_cmd( id, "echo amx_give_at4 < nick >" );
		return 1;
	}

	new iPlayer = cmd_target( id, szFirstArg, ( CMDTARGET_NO_BOTS ) );

	if( !iPlayer )
	{
		client_cmd( id, "echo * Jucatorul specificat nu a fost gasit !" );
		return 1;
	}

	drop_primary_weapons( iPlayer );

	HaveAT4[ iPlayer ] = true;
	at4_reload[ iPlayer ] = false;

	WeaponList( iPlayer, AT4_WEAPONKEY )
	fm_give_item( iPlayer, weapon_at4 );

	new Clip = fm_get_user_weapon_entity( iPlayer, CSW_AT4 );
	cs_set_weapon_ammo( Clip, 1 );

	new szPlayerName[ 32 ], szAdminName[ 32 ];

	get_user_name( iPlayer, szPlayerName, 31 );
	get_user_name( id, szAdminName, 31 );

	ColorChat( 0, "!y[!gADM!N!y]!t %s!y: i-a dat un!g AT4!y jucatorului!t %s", szAdminName, szPlayerName );
	ColorChat( iPlayer, "!yFelicitari ! Tocmai ai primit un!g AT4!y de la ADMIN-ul!t %s", szAdminName );

	return 1;
}

AT4_Natives() {
	register_native("get_user_at4", "get_user_at4", 1);
	register_native("set_user_at4", "set_user_at4", 1);
}

public AT4_ViewModel(id) {
	if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
		set_pev(id, pev_viewmodel2, AT4Model_V);
		set_pev(id, pev_weaponmodel2, AT4Model_P);
		set_pdata_int(id, 361, get_pdata_int(id, 361) | (1<<6));
	}
}

public AT4_WorldModel(entity, model[]) {
	if(is_valid_ent(entity)) {
		static ClassName[33];
		entity_get_string(entity, EV_SZ_classname, ClassName, charsmax(ClassName));
		
		if(equal(ClassName, "weaponbox")) {
			new Owner = entity_get_edict(entity, EV_ENT_owner);	
			new _AT4 = find_ent_by_owner(-1, weapon_at4, entity);
			
			if(get_user_at4(Owner) && is_valid_ent(_AT4) && equal(model, "models/w_m249.mdl")) {
				entity_set_int(_AT4, EV_INT_impulse, AT4_WEAPONKEY);
				HaveAT4[Owner] = false;
				entity_set_model(entity, AT4Model_W);
				set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
				new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, Owner);
				if(is_valid_ent(Laser))
					remove_entity(Laser);
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_UpdateClientData_Post(id, sendweapons, cd_handle) {
	if(is_user_alive(id) && is_user_connected(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
		set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
	return FMRES_IGNORED;
}

public AT4_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) {
	if(is_user_connected(invoker) && eventid == at4_event)
		playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
	return FMRES_IGNORED;
}

public AT4_PrecacheEvent_Post(type, const name[]) {
	if (equal("events/m249.sc", name))
		at4_event = get_orig_retval();
	return FMRES_IGNORED;
}

public AT4_PreThink(id) {
	if(is_user_alive(id) && is_user_connected(id)) {
		if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && at4_detector[id]) {
			new Float: origin[3];
			fm_get_aim_origin(id,origin);
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			
			if(!is_valid_ent(Laser)) {
				new at4_laser = create_entity("info_target");	
				set_pev(at4_laser, pev_classname, AT4_CLASS_LASERDOT);
				set_pev(at4_laser, pev_owner, id);
				engfunc(EngFunc_SetModel, at4_laser, AT4Model_LASER);
				set_pev(at4_laser, pev_renderfx, kRenderFxNoDissipation);
				set_pev(at4_laser, pev_rendermode, kRenderGlow);
				set_pev(at4_laser, pev_renderamt, 255.0);
				set_pev(at4_laser, pev_light_level, 255.0);
				set_pev(at4_laser, pev_scale, 1.0);
				set_pev(at4_laser, pev_movetype, MOVETYPE_FLY);
				set_pev(at4_laser, pev_nextthink, halflife_time() + 0.001);
			}
		}
		else {
			new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
			if(is_valid_ent(Laser))
				remove_entity(Laser);
		}
	}
}

public AT4_CmdStart(id, uc_handle, seed) {
	if(is_user_alive(id) && is_user_connected(id)) {
		static CurButton;
		CurButton = get_uc(uc_handle, UC_Buttons);
		new Float:NextAttack = get_pdata_float(id, 83, 5);
		
		static _AT4;
		_AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);	
		
		if(CurButton & IN_ATTACK) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
				if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
					set_weapon_anim(id, 1);
					emit_sound(id, CHAN_WEAPON, AT4_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM);
					AT4_Fire(id);
					new Float:PunchAngles[3];
					PunchAngles[0] = random_float(-7.0, -10.0), PunchAngles[1] = 0.0, PunchAngles[2] = 0.0;
					set_pev(id, pev_punchangle, PunchAngles);
					cs_set_weapon_ammo(_AT4, cs_get_weapon_ammo(_AT4) - 1);
					if(cs_get_weapon_ammo(_AT4) > 0 && !at4_reload[id] && NextAttack <= 0.0) {
						set_pdata_float(id, 83, at4_shotdelay, 5);
						set_pdata_float(_AT4, 48, 0.3, 4)
					}
				}
				CurButton &= ~IN_ATTACK;
				set_uc(uc_handle, UC_Buttons, CurButton);
			}
		}
		
		if(CurButton & IN_ATTACK2 && !(pev(id, pev_oldbuttons) & IN_ATTACK2)) {
			if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id) && NextAttack <= 0.0) {
				if(at4_detector[id])
					at4_detector[id] = false;
				else
					at4_detector[id] = true;
			}
		}
	}
	return FMRES_IGNORED;
}

public AT4_AddToPlayer(Weapon, id) {
	if(is_valid_ent(Weapon) && is_user_connected(id) && entity_get_int(Weapon, EV_INT_impulse) == AT4_WEAPONKEY) {
		HaveAT4[id] = true;
		WeaponList(id, AT4_WEAPONKEY)
		entity_set_int(Weapon, EV_INT_impulse, 0);
	}
	return HAM_IGNORED;
}

public AT4_Deploy_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {
			set_pev(Owner, pev_viewmodel2, AT4Model_V);
			set_pev(Owner, pev_weaponmodel2, AT4Model_P);
			set_weapon_anim(Owner, 4)
			
			set_pdata_float(Owner, 83, 1.2, 5);
			set_pdata_float(Weapon, 48, 1.2, 4)
			
			if(cs_get_weapon_ammo(Weapon) > 0)
				at4_reload[Owner] = 0;
		}
	}
	return HAM_IGNORED;
}

public AT4_Holster(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner))
			set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
	}
	return HAM_IGNORED;
}

public AT4_WeaponIdle(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_float(Weapon, 48, 4) <= 0.1)  {
			set_pdata_float(Weapon, 48, 4.0, 4)
			set_weapon_anim(Owner, 0)
		}
	}
	return HAM_IGNORED;
}

public AT4_PrimaryAttack(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		if(is_user_alive(Owner) && get_user_at4(Owner))
			return HAM_SUPERCEDE;
	}
	return HAM_IGNORED;
}

public AT4_Reload(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner)) {		
			at4_clip[Owner] = -1;
			
			if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
				return HAM_SUPERCEDE;
			
			at4_clip[Owner] = get_pdata_int(Weapon, 51, 4);
			at4_reload[Owner] = true;
		}
	}
	return HAM_IGNORED;
}

public AT4_Reload_Post(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && at4_clip[Owner] != -1) {			
			set_pdata_int(Weapon, 51, at4_clip[Owner], 4);
			set_pdata_float(Weapon, 48, get_pcvar_float(at4reloadtime), 4);
			set_pdata_float(Owner, 83, get_pcvar_float(at4reloadtime), 5);
			set_pdata_int(Weapon, 54, 1, 4);
			set_weapon_anim(Owner, 1)
		}
	}
	return HAM_IGNORED;
}

public AT4_PostFrame(Weapon) {
	if(pev_valid(Weapon)) {
		new Owner = get_pdata_cbase(Weapon, 41, 4);
		
		if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_int(Weapon, 54, 4) && get_pdata_float(Owner, 83, 5) <= 0.0) {
			new Temp = min(1 - get_pdata_int(Weapon, 51, 4), cs_get_user_bpammo(Owner, CSW_AT4));
			
			set_pdata_int(Weapon, 51, get_pdata_int(Weapon, 51, 4) + Temp, 4);
			cs_set_user_bpammo(Owner, CSW_AT4, cs_get_user_bpammo(Owner, CSW_AT4) - Temp);		
			set_pdata_int(Weapon, 54, 0, 4);
			
			at4_reload[Owner] = false;
		}
	}
	return HAM_IGNORED;
}

public AT4_Fire(id) {
	new Rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	
	if(pev_valid(Rocket)) {
		new Float:Origin[3], Float:Angles[3], Float:Velocity[3];
		engfunc(EngFunc_GetAttachment, id, 0, Origin, Angles);
		pev(id, pev_angles, Angles);
		
		set_pev(Rocket, pev_origin, Origin);
		set_pev(Rocket, pev_angles, Angles);
		set_pev(Rocket, pev_solid, SOLID_BBOX);
		set_pev(Rocket, pev_movetype, MOVETYPE_FLY);
		set_pev(Rocket, pev_classname, AT4_CLASS);
		
		if(at4_detector[id])
			set_pev(Rocket, pev_iuser3, 1);		
		else
			set_pev(Rocket, pev_iuser3, 0);		
		
		set_pev(Rocket, pev_owner, id);
		engfunc(EngFunc_SetModel, Rocket, AT4Model_S);
		
		set_pev(Rocket, pev_mins, {-3.0, -3.0, -3.0});
		set_pev(Rocket, pev_maxs, {3.0, 3.0, 3.0});
		
		velocity_by_aim(id, 2000, Velocity);
		set_pev(Rocket, pev_velocity, Velocity);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_BEAMFOLLOW); // TE id
		write_short(Rocket); // entity:attachment to follow
		write_short(at4_trail); // sprite index
		write_byte(3); // life in 0.1's
		write_byte(2); // line width in 0.1's
		write_byte(255); // r
		write_byte(255); // g
		write_byte(255); // b
		write_byte(200); // brightness
		message_end();
	}
	
	set_pev(Rocket, pev_iuser4, 0);		
	set_pev(Rocket, pev_nextthink, halflife_time() + 0.1);
}

public AT4_Think(Rocket) {
	if(is_valid_ent(Rocket)) {
		static Float:Origin[3];
		pev(Rocket, pev_origin, Origin);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_SPRITE);
		engfunc(EngFunc_WriteCoord, Origin[0]);
		engfunc(EngFunc_WriteCoord, Origin[1]);
		engfunc(EngFunc_WriteCoord, Origin[2]);
		write_short(at4_smoke);
		write_byte(2);
		write_byte(200);
		message_end();
		if(pev(Rocket, pev_iuser3) == 1) {
			if(pev(Rocket, pev_iuser4) == 0) {
				static Victim;
				Victim = FindClosesEnemy(Rocket);
				
				if(is_user_alive(Victim))
					set_pev(Rocket, pev_iuser4, Victim);
			}
			else {
				static Victim;
				Victim = pev(Rocket, pev_iuser4);
				
				if(is_user_alive(Victim)) {
					static Float:VicOrigin[3];
					pev(Victim, pev_origin, VicOrigin);
					
					hook_ent(Rocket, Victim, 2000.0);
				}
				else
					set_pev(Rocket, pev_iuser4, 0);
			} 
		}
		set_pev(Rocket, pev_nextthink, halflife_time() + 0.075);
	}
}

public AT4_LaserDot_Think(LaserDot) { 
	if(is_valid_ent(LaserDot)) {
		new Owner, Float:Origin[3];
		Owner = pev(LaserDot, pev_owner);
		pev(Owner, pev_origin, Origin);
		fm_get_aim_origin(Owner, Origin);
		
		set_pev(LaserDot, pev_origin, Origin);
		set_pev(LaserDot, pev_nextthink, halflife_time() + 0.001);
	}
}

public AT4_Touch(Rocket, touch) {
	if(is_valid_ent(Rocket)) {
		static Float:RocketOrigin[3];
		pev(Rocket, pev_origin, RocketOrigin);	
		new id = pev(Rocket, pev_owner);
		
		message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
		write_byte(TE_EXPLOSION);
		engfunc(EngFunc_WriteCoord, RocketOrigin[0]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[1]);
		engfunc(EngFunc_WriteCoord, RocketOrigin[2]);
		write_short(at4_explode);	// sprite index
		write_byte(40);			// scale in 0.1's
		write_byte(30);			// framerate
		write_byte(0);			// flags
		message_end();
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		engfunc(EngFunc_WriteCoord, RocketOrigin[0])
		engfunc(EngFunc_WriteCoord, RocketOrigin[1])
		engfunc(EngFunc_WriteCoord, RocketOrigin[2])
		write_byte(random_num(46, 48))
		message_end()	
		
		static ClassName[32];
		pev(touch, pev_classname, ClassName, charsmax(ClassName));
		if(equal(ClassName, "player") && is_user_connected(touch) && is_user_alive(touch)) {
			if(!fm_get_user_godmode(touch) && get_user_team(touch) != get_user_team(id) && touch != id) {
				new Float:Damage
				pev(Rocket, pev_iuser3) == 1 ? (Damage = (get_pcvar_float(at4damage) / 2.0)) : (Damage = get_pcvar_float(at4damage))
				//make_blood(id, get_pcvar_num(at4damage))
				make_knockback(touch, RocketOrigin, get_pcvar_float(at4knockback) * Damage);	
				if(get_user_health(touch) > Damage)
					ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
				else		
					death_message(id, touch, "AT4");
			}	
		}
		else if(equal(ClassName, "func_breakable")) {		
			if(entity_get_float(touch, EV_FL_health) <= get_pcvar_num(at4damage))
				force_use(id, touch);
		}
		
		for(new Victim = 1; Victim < get_maxplayers(); Victim++) {
			if(is_user_connected(Victim) && is_user_alive(Victim) && !fm_get_user_godmode(Victim) && get_user_team(Victim) != get_user_team(id) && Victim != id && Victim != touch) {
				new Float:VictimOrigin[3], Float:Distance_F, Distance;
				pev(Victim, pev_origin, VictimOrigin);
				Distance_F = get_distance_f(RocketOrigin, VictimOrigin);
				Distance = floatround(Distance_F);
				if(Distance <= get_pcvar_float(at4radius)) {								
					new Float:DistanceRatio, Float:Damage;
					DistanceRatio = floatdiv(float(Distance), get_pcvar_float(at4radius));
					Damage = get_pcvar_float(at4damage) - floatround(floatmul(get_pcvar_float(at4damage), DistanceRatio));
					//make_blood(id, get_pcvar_num(at4damage))
					make_knockback(Victim, RocketOrigin, get_pcvar_float(at4knockback)*Damage);	
					if(get_user_health(touch) > Damage)
						ExecuteHam(Ham_TakeDamage, touch, id, id, Damage, DMG_BLAST);
					else		
						death_message(id, touch, "AT4");
				}
			}
		}		
		engfunc(EngFunc_RemoveEntity, Rocket);
	}
}

public Hook_AT4(id) {
	engclient_cmd(id, weapon_at4);
	return PLUGIN_HANDLED
}

public get_user_at4(id)
	return HaveAT4[id];

public set_user_at4(id, at4) {
	if(at4) {
		if(!HaveAT4[id]) {
			drop_primary_weapons(id);
			HaveAT4[id] = true;
			at4_reload[id] = false;
			
			WeaponList(id, AT4_WEAPONKEY)
			fm_give_item(id, weapon_at4);
			
			new Clip = fm_get_user_weapon_entity(id, CSW_AT4);
			cs_set_weapon_ammo(Clip, 1);
		}
	}
	else {
		if(HaveAT4[id])
			HaveAT4[id] = false;
	}
}

stock FindClosesEnemy(entid) {
	new Float:Dist;
	new Float:maxdistance=300.0;
	new indexid=0;
	for(new i=1;i<=get_maxplayers();i++){
		if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i)
		&& pev(entid, pev_owner) != i && cs_get_user_team(pev(entid, pev_owner)) != cs_get_user_team(i)) {
			Dist = entity_range(entid, i);
			if(Dist <= maxdistance) {
				maxdistance=Dist;
				indexid=i;
				
				return indexid;
			}
		}	
	}	
	return 0;
}
stock bool:can_see_fm(entindex1, entindex2) {
	if(!entindex1 || !entindex2)
		return false;
	
	if(pev_valid(entindex1) && pev_valid(entindex1)) {
		new flags = pev(entindex1, pev_flags);
		if(flags & EF_NODRAW || flags & FL_NOTARGET) {
			return false;
		}
		
		new Float:lookerOrig[3];
		new Float:targetBaseOrig[3];
		new Float:targetOrig[3];
		new Float:temp[3];
		
		pev(entindex1, pev_origin, lookerOrig);
		pev(entindex1, pev_view_ofs, temp);
		lookerOrig[0] += temp[0];
		lookerOrig[1] += temp[1];
		lookerOrig[2] += temp[2];
		
		pev(entindex2, pev_origin, targetBaseOrig);
		pev(entindex2, pev_view_ofs, temp);
		targetOrig[0] = targetBaseOrig[0] + temp[0];
		targetOrig[1] = targetBaseOrig[1] + temp[1];
		targetOrig[2] = targetBaseOrig[2] + temp[2];
		
		engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the had of seen player
		if(get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) {
			return false;
		} 
		else {
			new Float:flFraction;
			get_tr2(0, TraceResult:TR_flFraction, flFraction);
			if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
				return true;
			}
			else {
				targetOrig[0] = targetBaseOrig[0];
				targetOrig[1] = targetBaseOrig[1];
				targetOrig[2] = targetBaseOrig[2];
				engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the body of seen player
				get_tr2(0, TraceResult:TR_flFraction, flFraction);
				if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
					return true;
				}
				else {
					targetOrig[0] = targetBaseOrig[0];
					targetOrig[1] = targetBaseOrig[1];
					targetOrig[2] = targetBaseOrig[2] - 17.0;
					engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the legs of seen player
					get_tr2(0, TraceResult:TR_flFraction, flFraction);
					if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
stock hook_ent(ent, victim, Float:speed) {
	static Float:fl_Velocity[3];
	static Float:VicOrigin[3], Float:EntOrigin[3];
	
	pev(ent, pev_origin, EntOrigin);
	pev(victim, pev_origin, VicOrigin);
	
	static Float:distance_f;
	distance_f = get_distance_f(EntOrigin, VicOrigin);
	
	if(distance_f > 10.0) {
		new Float:fl_Time = distance_f / speed;
		
		fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time;
		fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time;
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time;
	}
	else {
		fl_Velocity[0] = 0.0;
		fl_Velocity[1] = 0.0;
		fl_Velocity[2] = 0.0;
	}
	
	entity_set_vector(ent, EV_VEC_velocity, fl_Velocity);
}
public WeaponList(id, WEAPONKEY) {
	new Message_WeaponList = get_user_msgid("WeaponList")
	
	switch(WEAPONKEY) {
		case AT4_WEAPONKEY: {
			message_begin(MSG_ONE, Message_WeaponList, _, id);
			write_string(HaveAT4[id] ? "furien30_at4" : "weapon_m249");			// WeaponName
			write_byte(3);				// PrimaryAmmoID
			write_byte(200);			// PrimaryAmmoMaxAmount
			write_byte(-1);				// SecondaryAmmoID
			write_byte(-1);				// SecondaryAmmoMaxAmount
			write_byte(0);				// SlotID (0...N)
			write_byte(4);				// NumberInSlot (1...N)
			write_byte(CSW_AT4);			// WeaponID
			write_byte(0);				// Flags
			message_end();
		}
	}
}
	stock death_message(Killer, Victim, const Weapon[]) {
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET);
	ExecuteHamB(Ham_Killed, Victim, Killer, 2);
	set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT);
	
	make_deathmsg(Killer, Victim, 0, Weapon);
	cs_set_user_money(Killer, cs_get_user_money(Killer) + 300);
	
	if(is_user_connected(Killer)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Killer); // id
		write_short(pev(Killer, pev_frags)); // frags
		write_short(cs_get_user_deaths(Killer)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Killer)); // team
		message_end();
	}
	if(is_user_connected(Victim)) {
		message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"));
		write_byte(Victim); // id
		write_short(pev(Victim, pev_frags)); // frags
		write_short(cs_get_user_deaths(Victim)); // deaths
		write_short(0); // class?
		write_short(get_user_team(Victim)); // team
		message_end();
	}
}

public make_knockback(Victim, Float:origin[3], Float:maxspeed) {
	new Float:fVelocity[3];
	kickback(Victim, origin, maxspeed, fVelocity);
	entity_set_vector(Victim, EV_VEC_velocity, fVelocity);
	
	return(1);
}

stock kickback(ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3]) {
	new Float:fEntOrigin[3];
	entity_get_vector(ent, EV_VEC_origin, fEntOrigin);
	
	new Float:fDistance[3];
	fDistance[0] = fEntOrigin[0] - fOrigin[0];
	fDistance[1] = fEntOrigin[1] - fOrigin[1];
	fDistance[2] = fEntOrigin[2] - fOrigin[2];
	new Float:fTime = (vector_distance(fEntOrigin,fOrigin) / fSpeed);
	fVelocity[0] = fDistance[0] / fTime;
	fVelocity[1] = fDistance[1] / fTime;
	fVelocity[2] = fDistance[2] / fTime;
	
	return(fVelocity[0] && fVelocity[1] && fVelocity[2]);
}

stock make_bullet(id, Float:Origin[3]) {
	// Find target
	new target, body;
	get_user_aiming(id, target, body, 999999);
	
	if(target > 0 && target <= get_maxplayers()) {
		new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3];
		pev(id, pev_origin, fStart);
		
		velocity_by_aim(id, 64, fVel);
		
		fStart[0] = Origin[0];
		fStart[1] = Origin[1];
		fStart[2] = Origin[2];
		fEnd[0] = fStart[0]+fVel[0];
		fEnd[1] = fStart[1]+fVel[1];
		fEnd[2] = fStart[2]+fVel[2];
		
		new res;
		engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res);
		get_tr2(res, TR_vecEndPos, fRes);
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY) ;
		write_byte(TE_BLOODSPRITE);
		write_coord(floatround(fStart[0]));
		write_coord(floatround(fStart[1]));
		write_coord(floatround(fStart[2]));
		write_short(BloodSpray);
		write_short(BloodDrop);
		write_byte(70);
		write_byte(random_num(1,2));
		message_end();
		
		
	} 
	else {
		new decal = 41;
		
		if(target) {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_DECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			write_short(target);
			message_end();
		} 
		else {
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
			write_byte(TE_WORLDDECAL);
			write_coord(floatround(Origin[0]));
			write_coord(floatround(Origin[1]));
			write_coord(floatround(Origin[2]));
			write_byte(decal);
			message_end();
		}
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_GUNSHOTDECAL);
		write_coord(floatround(Origin[0]));
		write_coord(floatround(Origin[1]));
		write_coord(floatround(Origin[2]));
		write_short(id);
		write_byte(decal);
		message_end();
	}
}

stock set_weapon_anim(id, anim) {
	set_pev(id, pev_weaponanim, anim);
	if(is_user_connected(id)) {
		message_begin(MSG_ONE, SVC_WEAPONANIM, _, id);
		write_byte(anim);
		write_byte(pev(id, pev_body));
		message_end();
	}
}

stock get_damage_body(body, Float:damage) {
	switch(body) {
		case HIT_HEAD:
			damage *= 2.0;
		case HIT_STOMACH: 
			damage *= 1.0;
		case HIT_CHEST: 
			damage *= 1.5;
		case HIT_LEFTARM: 
			damage *= 0.75;
		case HIT_RIGHTARM: 
			damage *= 0.75;
		case HIT_LEFTLEG: 
			damage *= 0.75;
		case HIT_RIGHTLEG: 
			damage *= 0.75;
		default: 
		damage *= 1.0;
	}
	
	return floatround(damage);
}	

stock drop_primary_weapons(Player) {
	static weapons[32], num, i, weaponid;
	num = 0;
	get_user_weapons(Player, weapons, num);
	
	for(i = 0; i < num; i++) {
		weaponid = weapons ;
		
		if(((1<<weaponid) & PRIMARY_WEAPONS_BITSUM)) {
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock drop_secondary_weapons(Player) {
	// Get user weapons
	static weapons [32], num, i, weaponid;
	num = 0; // reset passed weapons count(bugfix)
	get_user_weapons(Player, weapons, num);
	
	// Loop through them and drop primaries
	for(i = 0; i < num; i++) {
		// Prevent re-indexing the array
		weaponid = weapons ;
		
		// We definetely are holding primary gun
		if(((1<<weaponid) & SECONDARY_WEAPONS_BITSUM)) {
			// Get weapon entity
			static wname[32];
			get_weaponname(weaponid, wname, charsmax(wname));
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd(Player, "drop", wname);
		}
	}
}

stock fm_get_user_bpammo(index, weapon) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	return offset ? get_pdata_int(index, offset) : 0
}

stock fm_set_user_bpammo(index, weapon, amount) {
	static offset
	switch(weapon) {
		case CSW_AWP: offset = 377
			case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS, CSW_M4A1, CSW_AUG, 
			CSW_SG550, CSW_GALI, CSW_SG552: offset = 380
		case CSW_M3, CSW_XM1014: offset = 381
			case CSW_USP, CSW_UMP45, CSW_MAC10: offset = 382
			case CSW_FIVESEVEN, CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18, CSW_TMP, CSW_ELITE, 
			CSW_MP5NAVY: offset = 386
		default: offset = 0
	}
	
	if(offset) 
		set_pdata_int(index, offset, amount)
	
	return 1
}

#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )

stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 0.01, Float:holdtime = 3.0, Float:fadeintime = 0.01, Float:fadeouttime = 0.01) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Like a boss , merci mult de ajutor .
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests