delete knockback

Unpaid Requests, Public Plugins
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 439
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

delete knockback

#1

Post by czirimbolo » 2 Months Ago

Hello, this gun can pushing back zombies in freezetime and even I can push back humans! Can someone block this? I want knockback only after zombie release time and of course it must push back only zombies, not humans.

Code: Select all

#include <zombie_escape>
#include <engine>
#include <fakemeta_util>
#include <cstrike>
#include <xs>

#define PLUGIN "[ZP] AK47 Palladin Bloodmoon"
#define VERSION "1.0"
#define AUTHOR "AUTHOR"

// CONFIGURATION WEAPON
#define system_name		"bak47p"
#define system_base		"ak47"

#define DRAW_TIME		0.66
#define RELOAD_TIME		2.1

#define CSW_BAK47P		CSW_AK47
#define WEAPON_KEY 		110918273

#define OLD_MODEL		"models/w_ak47.mdl"
#define ANIMEXT			"carbine"

/*
Support For Human And Survivor
Not Supported For Zombie || Madafaka!!
- ZP_TEAM HUMAN = HUMAN
- ZP_TEAM_SURVIVOR = SURVIVOR
*/

// ALL MACRO
#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define TASK_MUZZLEFLASH	102291

#define USE_STOPPED 		0
#define OFFSET_LINUX_WEAPONS 	4
#define OFFSET_LINUX 		5
#define OFFSET_WEAPONOWNER 	41
#define OFFSET_ACTIVE_ITEM 	373

#define m_fKnown		44
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_iClip			51
#define m_fInReload		54
#define m_flNextAttack		83
#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

// ALL ANIM
#define ANIM_RELOAD		1
#define ANIM_DRAW		2
#define ANIM_SHOOT1		3
#define ANIM_SHOOT2		4
#define ANIM_SHOOT3		5

#define MODE_A			0
#define MODE_B			1

// All Models Of The Weapon
new V_MODEL[64] = "models/v_bak47p.mdl"
new W_MODEL[64] = "models/w_bak47p.mdl"
new P_MODEL[64] = "models/p_bak47p.mdl"
new S_MODEL[64] = "sprites/bak47p/ef_buffak_hit.spr"

new const WeaponResources[][] =
{
	"sprites/bak47p/bak47p.spr",
	"sprites/bak47p/bak47p.spr"
}

new const MuzzleFlash[][] =
{
	"sprites/bak47p/muzzleflash60.spr",
	"sprites/bak47p/muzzleflash65.spr",
	"sprites/bak47p/muzzleflash70.spr"
}

// You Can Add Fire Sound Here
new const Fire_Sounds[][] = { "weapons/bak47p-1.wav", "weapons/bak47p-2.wav" }

// All Vars Here
new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
new cvar_dmg, cvar_recoil, cvar_clip, cvar_spd, cvar_ammo, cvar_radius, cvar_dmg_2, cvar_trace_color
new g_MaxPlayers, g_orig_event, g_IsInPrimaryAttack, g_attack_type[33], Float:cl_pushangle[33][3]
new g_had_bak47p[33], g_clip_ammo[33], g_weapon_TmpClip[33], oldweap[33], sBuffakHit
new g_Muzzleflash_Ent[2], g_Muzzleflash[33][2], g_Mode[33], g_list_variables[10]

// Macros Again :v
new weapon_name_buffer[512]
new weapon_base_buffer[512]
		
const PRIMARY_WEAPONS_BIT_SUM = 
(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 WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
			"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
			"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
			"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
			"weapon_ak47", "weapon_knife", "weapon_p90" }

// START TO CREATE PLUGINS || AMXMODX FORWARD
public plugin_init()
{
	formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s_asep", system_name)
	formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Event And Message
	register_event("CurWeapon", "Forward_CurrentWeapon", "be", "1=1")
	register_message(get_user_msgid("DeathMsg"), "Forward_DeathMsg")
	register_message(get_user_msgid("WeaponList"), "Forward_MessageWeapList")
	
	// Ham Forward (Entity) || Ham_Use
	RegisterHam(Ham_Use, "func_tank", "Forward_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "Forward_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "Forward_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "Forward_UseStationary_Post", 1)
	
	// Ham Forward (Entity) || Ham_TraceAttack
	RegisterHam(Ham_TraceAttack, "player", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "Forward_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "Forward_TraceAttack", 1)
	
	// Ham Forward (Weapon)
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, weapon_base_buffer, "Weapon_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload")
	RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, weapon_base_buffer, "Weapon_AddToPlayer")
	
	for(new i = 1; i < sizeof WEAPONENTNAMES; i++)
		if(WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "Weapon_Deploy_Post", 1)
		
	// Ham Forward (Player)
	RegisterHam(Ham_Killed, "player", "Forward_PlayerKilled")
	
	// Fakemeta Forward
	register_forward(FM_SetModel, "Forward_SetModel")
	register_forward(FM_PlaybackEvent, "Forward_PlaybackEvent")
	register_forward(FM_UpdateClientData, "Forward_UpdateClientData_Post", 1)
	register_forward(FM_AddToFullPack, "Forward_AddToFullPack", 1)
	register_forward(FM_CheckVisibility, "Forward_CheckVisibility")
	
	// All Some Cvar
	cvar_clip = register_cvar("bak47p_clip", "50")
	cvar_spd = register_cvar("bak47p_speed", "1.15")
	cvar_ammo = register_cvar("bak47p_ammo", "240")
	cvar_dmg = register_cvar("bak47p_damage", "2.1")
	cvar_recoil = register_cvar("bak47p_recoil", "0.62")
	cvar_dmg_2 = register_cvar("bak47p_buff_damage", "350")
	cvar_radius = register_cvar("bak47p_buff_radius", "75")
	cvar_trace_color = register_cvar("bak47p_trace_color", "7")
	
	g_MaxPlayers = get_maxplayers()	
}

public plugin_precache()
{
	formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s", system_name)
	formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
	
	precache_model(V_MODEL)
	precache_model(P_MODEL)
	precache_model(W_MODEL)
	sBuffakHit = precache_model(S_MODEL)
	
	new Buffer[512]
	formatex(Buffer, sizeof(Buffer), "sprites/%s.txt", weapon_name_buffer)
	precache_generic(Buffer) // EG: Output "sprites/weapon_bak47p.txt"
	
	for(new i = 0; i < sizeof Fire_Sounds; i++)
		precache_sound(Fire_Sounds[i])
	for(new i = 0; i < sizeof MuzzleFlash; i++)
		precache_model(MuzzleFlash[i])
	for(new i = 0; i < sizeof WeaponResources; i++)
		precache_model(WeaponResources[i])
		
	precache_viewmodel_sound(V_MODEL)
	formatex(Buffer, sizeof(Buffer), "test_%s", system_name)
	
	register_clcmd(Buffer, "get_bak47p") // EG: Output "test_bak47p"
	register_clcmd(weapon_name_buffer, "weapon_hook")
	register_forward(FM_PrecacheEvent, "Forward_PrecacheEvent_Post", 1)
	
	g_Muzzleflash_Ent[0] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[0], MuzzleFlash[0])
	set_pev(g_Muzzleflash_Ent[0], pev_scale, 0.08)
	set_pev(g_Muzzleflash_Ent[0], pev_rendermode, kRenderTransTexture)
	set_pev(g_Muzzleflash_Ent[0], pev_renderamt, 0.0)

	g_Muzzleflash_Ent[1] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[1], MuzzleFlash[1])
	set_pev(g_Muzzleflash_Ent[1], pev_scale, 0.07)
	set_pev(g_Muzzleflash_Ent[1], pev_rendermode, kRenderTransTexture)
	set_pev(g_Muzzleflash_Ent[1], pev_renderamt, 0.0)
}

public plugin_natives()
{
	register_native("get_bak47p", "native_get_bak47p", 1)
}

public native_get_bak47p(id)
{
	get_bak47p(id)
}

// Reset Bitvar (Fix Bug) If You Connect Or Disconnect Server
public client_connect(id) remove_bak47p(id)
public client_disconnected(id) remove_bak47p(id)
public ze_user_infected(id, iInfector) remove_bak47p(id)
public ze_user_humanized(id) remove_bak47p(id)
/* ========= START OF REGISTER HAM TO SUPPORT BOTS FUNC ========= */
new g_HamBot
public client_putinserver(id)
{
	if(!g_HamBot && is_user_bot(id))
	{
		g_HamBot = 1
		set_task(0.1, "Do_RegisterHam", id)
	}
}

public Do_RegisterHam(id)
{
	RegisterHamFromEntity(Ham_Killed, id, "Forward_PlayerKilled")
	RegisterHamFromEntity(Ham_TraceAttack, id, "Forward_TraceAttack", 1)
}

/* ======== END OF REGISTER HAM TO SUPPORT BOTS FUNC ============= */
/* ============ START OF ALL FORWARD (FAKEMETA) ================== */
public Forward_AddToFullPack(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
{
	if(iEnt == g_Muzzleflash_Ent[0])
	{
		if(g_Muzzleflash[iHost][0] == 3)
		{
			set_es(esState, ES_RenderMode, kRenderTransAdd)
			set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
			set_es(esState, ES_Scale, random_float(0.06, 0.1))
			
			g_Muzzleflash[iHost][0] = 2
		}
		else if(g_Muzzleflash[iHost][0] == 2)
		{
			set_es(esState, ES_RenderMode, kRenderTransAdd)
			set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
			set_es(esState, ES_Scale, random_float(0.06, 0.1))
			
			g_Muzzleflash[iHost][0] = 1
			g_Muzzleflash[iHost][1] = 1
		}
		else if(g_Muzzleflash[iHost][0] == 1)
		{
			set_es(esState, ES_RenderMode, kRenderTransAdd)
			set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
			set_es(esState, ES_Scale, random_float(0.06, 0.1))
			
			g_Muzzleflash[iHost][0] = 0
		}
			
		set_es(esState, ES_Skin, iHost)
		set_es(esState, ES_Body, 1)
		set_es(esState, ES_AimEnt, iHost)
		set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
	}
	else if(iEnt == g_Muzzleflash_Ent[1])
	{
		if(g_Muzzleflash[iHost][1])
		{
			set_es(esState, ES_RenderMode, kRenderTransAdd)
			set_es(esState, ES_RenderAmt, 240.0)
			
			g_Muzzleflash[iHost][1] = 0
		}
			
		set_es(esState, ES_Skin, iHost)
		set_es(esState, ES_Body, 1)
		set_es(esState, ES_AimEnt, iHost)
		set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
	}

}

public Forward_CheckVisibility(iEntity, pSet)
{
	if(iEntity == g_Muzzleflash_Ent[0] || iEntity == g_Muzzleflash_Ent[1])
	{
		forward_return(FMV_CELL, 1)
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public Forward_PrecacheEvent_Post(type, const name[])
{
	new Buffer[512]
	formatex(Buffer, sizeof(Buffer), "events/%s.sc", system_base)
	if(equal(Buffer, name, 0))
	{
		g_orig_event = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public Forward_SetModel(entity, model[])
{
	if(!is_valid_ent(entity))
		return FMRES_IGNORED
	
	static szClassName[33]
	entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
		
	if(!equal(szClassName, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	iOwner = entity_get_edict(entity, EV_ENT_owner)
	
	if(equal(model, OLD_MODEL))
	{
		static iStoredAugID
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, entity)
			
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED

		if(g_had_bak47p[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, WEAPON_KEY)
			g_had_bak47p[iOwner] = 0
			entity_set_model(entity, W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public Forward_UseStationary_Post(entity, caller, activator, use_type)
{
	if(use_type == USE_STOPPED && is_user_connected(caller))
		replace_weapon_models(caller, get_user_weapon(caller))
}

public Forward_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
{
	if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_BAK47P || !g_had_bak47p[Player]))
		return FMRES_IGNORED
	
	set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
	return FMRES_HANDLED
}

public Forward_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if((eventid != g_orig_event) || !g_IsInPrimaryAttack)
		return FMRES_IGNORED
	if(!(1 <= invoker <= g_MaxPlayers))
		return FMRES_IGNORED

	playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	return FMRES_SUPERCEDE
}

/* ================= END OF ALL FAKEMETA FORWARD ================= */
/* ================= START OF ALL MESSAGE FORWARD ================ */
public Forward_DeathMsg(msg_id, msg_dest, id)
{
	static szTruncatedWeapon[33], iAttacker, iVictim
	
	get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
	
	iAttacker = get_msg_arg_int(1)
	iVictim = get_msg_arg_int(2)
	
	if(!is_user_connected(iAttacker) || iAttacker == iVictim)
		return PLUGIN_CONTINUE
	
	if(equal(szTruncatedWeapon, system_base) && get_user_weapon(iAttacker) == CSW_BAK47P)
	{
		if(g_had_bak47p[iAttacker])
			set_msg_arg_string(4, system_name)
	}
	return PLUGIN_CONTINUE
}
/* ================== END OF ALL MESSAGE FORWARD ================ */
/* ================== START OF ALL EVENT FORWARD ================ */
public Forward_MessageWeapList(msg_id, msg_dest, id)
{
	if(get_msg_arg_int(8) != CSW_BAK47P)
		return
     
	g_list_variables[2] = get_msg_arg_int(2)
	g_list_variables[3] = get_msg_arg_int(3)
	g_list_variables[4] = get_msg_arg_int(4)
	g_list_variables[5] = get_msg_arg_int(5)
	g_list_variables[6] = get_msg_arg_int(6)
	g_list_variables[7] = get_msg_arg_int(7)
	g_list_variables[8] = get_msg_arg_int(8)
	g_list_variables[9] = get_msg_arg_int(9)
}

public Forward_CurrentWeapon(id)
{
	replace_weapon_models(id, read_data(2))
     
	if(!is_user_alive(id))
		return
	if(read_data(2) != CSW_BAK47P || !g_had_bak47p[id])
		return
     
	static Float:Speed
	if(g_had_bak47p[id])
		Speed = get_pcvar_float(cvar_spd)
	
	static weapon[32], Ent
	get_weaponname(read_data(2), weapon, 31)
	Ent = find_ent_by_owner(-1, weapon, id)
	if(pev_valid(Ent))
	{
		static Float:Delay
		Delay = get_pdata_float(Ent, 46, 4) * Speed
		if(Delay > 0.0) set_pdata_float(Ent, 46, Delay, 4)
	}
}
/* ================== END OF ALL EVENT FORWARD =================== */
/* ================== START OF ALL HAM FORWARD ============== */
public Forward_PlayerKilled(id) remove_bak47p(id)
public Forward_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
	if(!is_user_alive(iAttacker) || !is_user_connected(iAttacker))
		return
	if(get_user_weapon(iAttacker) != CSW_BAK47P || !g_had_bak47p[iAttacker])
		return

	static Float:flEnd[3], Float:WallVector[3], trace_color
	get_tr2(ptr, TR_vecEndPos, flEnd)
	get_tr2(ptr, TR_vecPlaneNormal, WallVector)
	
	if(iEnt)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_DECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		write_short(iEnt)
		message_end()
	}
	else
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		message_end()
	}
	
	if(g_Mode[iAttacker] == MODE_A)
	{
		if(!is_user_alive(iEnt)) trace_color = get_pcvar_num(cvar_trace_color)
		else if(is_user_alive(iEnt)) trace_color = 2000 // NO STREAK COLOR or Disabled
		ExecuteHamB(Ham_TakeDamage, iEnt, iAttacker, iAttacker, flDamage * get_pcvar_float(cvar_dmg), DMG_BULLET)
	}
	
	if(pev(iEnt, pev_takedamage) != DAMAGE_NO)
	{
		set_hudmessage(255, 0, 0, -1.0, 0.46, 0, 0.2, 0.2)
		show_hudmessage(iAttacker, "\         /^n+^n/         \")
	}
	
	if(trace_color < 2000)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_STREAK_SPLASH)
		engfunc(EngFunc_WriteCoord, flEnd[0])
		engfunc(EngFunc_WriteCoord, flEnd[1])
		engfunc(EngFunc_WriteCoord, flEnd[2])
		engfunc(EngFunc_WriteCoord, WallVector[0] * random_float(25.0,30.0))
		engfunc(EngFunc_WriteCoord, WallVector[1] * random_float(25.0,30.0))
		engfunc(EngFunc_WriteCoord, WallVector[2] * random_float(25.0,30.0))
		write_byte(trace_color)
		write_short(50)
		write_short(3)
		write_short(90)	
		message_end()
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_short(iAttacker)
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		message_end()
	}
}

public Weapon_Deploy_Post(weapon_entity)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_entity)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_entity)
	
	replace_weapon_models(owner, weaponid)
}

public Weapon_AddToPlayer(weapon_entity, id)
{
	if(!is_valid_ent(weapon_entity) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == WEAPON_KEY)
	{
		g_had_bak47p[id] = true
		entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
		set_weapon_list(id, weapon_name_buffer)
		
		return HAM_HANDLED
	}
	else
	{
		set_weapon_list(id, weapon_base_buffer)
	}
	
	return HAM_IGNORED
}

public Weapon_PrimaryAttack(weapon_entity)
{
	new Player = get_pdata_cbase(weapon_entity, 41, 4)
	
	if(!g_had_bak47p[Player])
		return
	
	g_IsInPrimaryAttack = 1
	pev(Player,pev_punchangle,cl_pushangle[Player])
	
	g_clip_ammo[Player] = cs_get_weapon_ammo(weapon_entity)
}

public Weapon_PrimaryAttack_Post(weapon_entity)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(weapon_entity, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return
		
	if(g_had_bak47p[Player])
	{
		if(!g_clip_ammo[Player])
		{
			ExecuteHam(Ham_Weapon_PlayEmptySound, weapon_entity)
			return
		}
		
		new Float:push[3]
		pev(Player,pev_punchangle,push)
		xs_vec_sub(push,cl_pushangle[Player],push)
		xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		set_weapon_shoot_anim(Player)
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", Player+TASK_MUZZLEFLASH)
	}
}

public Weapon_ItemPostFrame(weapon_entity) 
{
	new id = pev(weapon_entity, pev_owner)
	if(!is_user_connected(id))
		return HAM_IGNORED
	if(!g_had_bak47p[id])
		return HAM_IGNORED

	static iClipExtra
	iClipExtra = get_pcvar_num(cvar_clip)
	new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX)

	new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
	new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)

	new fInReload = get_pdata_int(weapon_entity, m_fInReload, OFFSET_LINUX_WEAPONS) 
	if(fInReload && flNextAttack <= 0.0)
	{
		new j = min(iClipExtra - iClip, iBpAmmo)
	
		set_pdata_int(weapon_entity, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS)
		cs_set_user_bpammo(id, CSW_BAK47P, iBpAmmo-j)
		
		set_pdata_int(weapon_entity, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		fInReload = 0
	}
	else if(!fInReload && !get_pdata_int(weapon_entity, 74, 4))
	{
		if(!iClip)
			return HAM_IGNORED
			
		if(get_pdata_float(id, 83, 5) <= 0.0 && get_pdata_float(weapon_entity, 46, 4) <= 0.0 ||
		get_pdata_float(weapon_entity, 47, 4) <= 0.0 || get_pdata_float(weapon_entity, 48, 4) <= 0.0)
		{
			if(pev(id, pev_button) & IN_ATTACK)
			{
				if(g_Mode[id] == MODE_B)
					Shoot_Special(id)
			}
			else if(pev(id, pev_button) & IN_ATTACK2)
			{
				set_buffak_zoom(id, 0)
				set_weapons_timeidle(id, CSW_BAK47P, 0.4)
				set_player_nextattackx(id, 0.4)
			}
		}
	}
	
	return HAM_IGNORED
}

public Weapon_Reload(weapon_entity) 
{
	new id = pev(weapon_entity, pev_owner)
	if(!is_user_connected(id))
		return HAM_IGNORED
	if(!g_had_bak47p[id])
		return HAM_IGNORED
	static iClipExtra
	if(g_had_bak47p[id])
		iClipExtra = get_pcvar_num(cvar_clip)

	g_weapon_TmpClip[id] = -1

	new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
	new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)

	if(iBpAmmo <= 0)
		return HAM_SUPERCEDE

	if(iClip >= iClipExtra)
		return HAM_SUPERCEDE

	g_weapon_TmpClip[id] = iClip

	return HAM_IGNORED
}

public Weapon_Reload_Post(weapon_entity) 
{
	new id = pev(weapon_entity, pev_owner)
	if (!is_user_connected(id))
		return HAM_IGNORED

	if(!g_had_bak47p[id])
		return HAM_IGNORED
	if(g_weapon_TmpClip[id] == -1)
		return HAM_IGNORED
	
	set_pdata_int(weapon_entity, m_iClip, g_weapon_TmpClip[id], OFFSET_LINUX_WEAPONS)
	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, RELOAD_TIME, OFFSET_LINUX_WEAPONS)
	set_pdata_float(id, m_flNextAttack, RELOAD_TIME, OFFSET_LINUX)
	set_pdata_int(weapon_entity, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
	
	set_weapon_anim(id, ANIM_RELOAD)
	set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
	set_buffak_zoom(id, 1)
	
	return HAM_IGNORED
}

/* ===================== END OF ALL HAM FORWARD ====================== */
/* ================= START OF OTHER PUBLIC FUNCTION  ================= */
public get_bak47p(id)
{
	drop_weapons(id, 1)
	new iWeapon = fm_give_item(id, weapon_base_buffer)
	if(iWeapon > 0)
	{
		cs_set_weapon_ammo(iWeapon, get_pcvar_num(cvar_clip))
		cs_set_user_bpammo(id, CSW_BAK47P, get_pcvar_num(cvar_ammo))
		emit_sound(id, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM,0,PITCH_NORM)
		
		set_weapon_anim(id, ANIM_DRAW)
		set_pdata_float(id, m_flNextAttack, DRAW_TIME, OFFSET_LINUX)
		
		set_weapon_list(id, weapon_name_buffer)
		set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
		set_pdata_int(iWeapon, 74, MODE_A)
	}
	
	g_had_bak47p[id] = true
	g_Mode[id] = MODE_A
	remove_bitvar(id)
}

public remove_bak47p(id)
{
	g_had_bak47p[id] = false
	g_Mode[id] = MODE_A
	remove_bitvar(id)
}

public remove_bitvar(id)
{
	g_attack_type[id] = 0
	g_Muzzleflash[id][0] = 0
	g_Muzzleflash[id][1] = 0
}

public weapon_hook(id)
{
	engclient_cmd(id, weapon_base_buffer)
	return PLUGIN_HANDLED
}

public replace_weapon_models(id, weaponid)
{
	if(weaponid != CSW_BAK47P)
	{
		if(g_had_bak47p[id])
		{
			remove_bitvar(id)
			set_buffak_zoom(id, 1)
		}
	}
	
	switch(weaponid)
	{
		case CSW_BAK47P:
		{
			if(g_had_bak47p[id])
			{
				set_pev(id, pev_viewmodel2, V_MODEL)
				set_pev(id, pev_weaponmodel2, P_MODEL)
				
				if(oldweap[id] != CSW_BAK47P) 
				{
					set_weapon_anim(id, ANIM_DRAW)
					set_player_nextattackx(id, DRAW_TIME)
					set_weapons_timeidle(id, CSW_BAK47P, DRAW_TIME)
					set_weapon_list(id, weapon_name_buffer)
					set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
				}
			}
		}
	}
	
	oldweap[id] = weaponid
}

public Shoot_Special(id)
{
	if(!is_user_alive(id) || !is_user_connected(id))
		return
		
	new szClip, szWeapId
	szWeapId = get_user_weapon(id, szClip)
	if(szWeapId != CSW_BAK47P || !g_had_bak47p[id] || !szClip)
		return
	
	g_Muzzleflash[id][0] = 3
	set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", id+TASK_MUZZLEFLASH)
	
	static Float:PunchAngles[3]
	PunchAngles[0] = -5.0
	PunchAngles[1] = -2.5
	PunchAngles[2] = -2.5
	set_pev(id, pev_punchangle, PunchAngles)
	
	set_weapon_shoot_anim(id)
	emit_sound(id, CHAN_WEAPON, Fire_Sounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	new Float:fStart[3], Float:originF[3]
	new target, body
	
	fm_get_aim_origin(id, originF)
	get_user_aiming(id, target, body)
	
	pev(id, pev_origin, fStart)
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fStart, 0)
	write_byte(TE_SPRITE)
	engfunc(EngFunc_WriteCoord, originF[0])
	engfunc(EngFunc_WriteCoord, originF[1])
	engfunc(EngFunc_WriteCoord, originF[2] + 20.0)
	write_short(sBuffakHit)
	write_byte(10)
	write_byte(240)
	message_end()
	
	new a = FM_NULLENT
	while((a = find_ent_in_sphere(a, originF, float(get_pcvar_num(cvar_radius)))) != 0)
	{
		if(id == a)
			continue
	
		if(pev(a, pev_takedamage) != DAMAGE_NO)
			ExecuteHamB(Ham_TakeDamage, a, 0, id, float(get_pcvar_num(cvar_dmg_2)), DMG_BULLET)
	}
	
	if(!is_user_alive(target))
	{
		static Classname[32]
		pev(target, pev_classname, Classname, sizeof(Classname))
		
		if(equal(Classname, "func_breakable"))
			ExecuteHamB(Ham_TakeDamage, target, 0, 0, float(get_pcvar_num(cvar_dmg_2)), DMG_GENERIC)
	}
	else if(is_user_alive(target) && is_user_connected(target))
	{
		static Float:MyOrigin[3]
		pev(id, pev_origin, MyOrigin)
		hook_ent2(target, MyOrigin, 400.0, 2)
		ExecuteHamB(Ham_TakeDamage, target, 0, id, float(get_pcvar_num(cvar_dmg_2))*0.75, DMG_BULLET)
	}
	
	static entity_weapon
	entity_weapon = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, id)
	
	if(!pev_valid(entity_weapon))
		return
	
	cs_set_weapon_ammo(entity_weapon, szClip - 1)
	set_player_nextattackx(id, 0.7)
	set_weapons_timeidle(id, CSW_BAK47P, 0.7)
}

public set_weapon_shoot_anim(id)
{
	if(!g_attack_type[id])
	{
		set_weapon_anim(id, ANIM_SHOOT1)
		g_attack_type[id] = 1
	}
	else if(g_attack_type[id] == 1)
	{
		set_weapon_anim(id, ANIM_SHOOT2)
		g_attack_type[id] = 2
	}
	else if(g_attack_type[id] == 2)
	{
		set_weapon_anim(id, ANIM_SHOOT3)
		g_attack_type[id] = 0
	}
}

public Re_MuzzleFlash(id)
{
	id -= TASK_MUZZLEFLASH

	if(!is_user_alive(id) || !is_user_connected(id))
		return
	if(get_user_weapon(id) != CSW_BAK47P || !g_had_bak47p[id])
		return
	
	if(g_Mode[id] == MODE_A) g_Muzzleflash[id][0] = true
	else if(g_Mode[id] == MODE_B) g_Muzzleflash[id][1] = true
}

/* ============= END OF OTHER PUBLIC FUNCTION (Weapon) ============= */
/* ================= START OF ALL STOCK TO MACROS ================== */
stock set_buffak_zoom(id, const reset = 0)
{
	if(reset == 1)
	{
		set_fov(id)
		g_Mode[id] = MODE_A
	}
	else if(reset == 0)
	{
		if(g_Mode[id] == MODE_A)
		{
			set_fov(id, 80)
			g_Mode[id] = MODE_B
		}
		else if(g_Mode[id] == MODE_B)
		{
			set_fov(id)
			g_Mode[id] = MODE_A
		}
	}
}

stock set_fov(id, fov = 90)
{
	message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id)
	write_byte(fov)
	message_end()
}

stock set_weapon_list(id, const weapon_name[])
{
	message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
	write_string(weapon_name)
	write_byte(g_list_variables[2])
	write_byte(g_list_variables[3])
	write_byte(g_list_variables[4])
	write_byte(g_list_variables[5])
	write_byte(g_list_variables[6])
	write_byte(g_list_variables[7])
	write_byte(g_list_variables[8])
	write_byte(g_list_variables[9])
	message_end()
}

stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
{
	static Float:fl_Velocity[3]
	static Float:EntOrigin[3]
	
	pev(ent, pev_origin, EntOrigin)
	static Float:distance_f
	distance_f = 100.0
	
	new Float:fl_Time = distance_f / speed
	if(type == 1)
	{
		fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time		
	}
	else if(type == 2)
	{
		fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
	}
	
	entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}

stock drop_weapons(id, dropwhat)
{
	static weapons[32], num = 0, i, weaponid
	get_user_weapons(id, weapons, num)
     
	for (i = 0; i < num; i++)
	{
		weaponid = weapons[i]
          
		if(dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
		{
			static wname[32]
			get_weaponname(weaponid, wname, sizeof wname - 1)
			engclient_cmd(id, "drop", wname)
		}
	}
}

stock set_player_nextattackx(id, Float:nexttime)
{
	if(!is_user_alive(id))
		return
		
	set_pdata_float(id, m_flNextAttack, nexttime, 5)
}

stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
{
	if(!is_user_alive(id))
		return
		
	static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
	if(!pev_valid(entwpn)) 
		return
		
	set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
	set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
	set_pdata_float(entwpn, 48, TimeIdle + 1.0, OFFSET_LINUX_WEAPONS)
}

stock set_weapons_timeidlex(id, Float:TimeIdle, Float:Idle)
{
	new entwpn = fm_get_user_weapon_entity(id, CSW_BASE)
	if(!pev_valid(entwpn)) 
		return
	
	set_pdata_float(entwpn, 46, TimeIdle, 4)
	set_pdata_float(entwpn, 47, TimeIdle, 4)
	set_pdata_float(entwpn, 48, Idle, 4)
}

stock set_weapon_anim(const Player, const Sequence)
{
	set_pev(Player, pev_weaponanim, Sequence)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
	write_byte(Sequence)
	write_byte(pev(Player, pev_body))
	message_end()
}

stock precache_viewmodel_sound(const model[]) // I Get This From BTE
{
	new file, i, k
	if((file = fopen(model, "rt")))
	{
		new szsoundpath[64], NumSeq, SeqID, Event, NumEvents, EventID
		fseek(file, 164, SEEK_SET)
		fread(file, NumSeq, BLOCK_INT)
		fread(file, SeqID, BLOCK_INT)
		
		for(i = 0; i < NumSeq; i++)
		{
			fseek(file, SeqID + 48 + 176 * i, SEEK_SET)
			fread(file, NumEvents, BLOCK_INT)
			fread(file, EventID, BLOCK_INT)
			fseek(file, EventID + 176 * i, SEEK_SET)
			
			// The Output Is All Sound To Precache In ViewModels (GREAT :V)
			for(k = 0; k < NumEvents; k++)
			{
				fseek(file, EventID + 4 + 76 * k, SEEK_SET)
				fread(file, Event, BLOCK_INT)
				fseek(file, 4, SEEK_CUR)
				
				if(Event != 5004)
					continue
				
				fread_blocks(file, szsoundpath, 64, BLOCK_CHAR)
				
				if(strlen(szsoundpath))
				{
					strtolower(szsoundpath)
					engfunc(EngFunc_PrecacheSound, szsoundpath)
				}
			}
		}
	}
	fclose(file)
}

stock fm_cs_get_weapon_ent_owner(ent)
{
	return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
}

/* ================= END OF ALL STOCK AND PLUGINS CREATED ================== */
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1057\\ f0\\ fs16 \n\\ par }
*/
Image


czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 439
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#3

Post by czirimbolo » 2 Months Ago

I use this plugin and its not working in that case. It doesnt take damage in freeze time but its pushing back. Its strange because I can push back humans too
Image

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 512
Joined: 1 Year Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 42 times
Age: 18
Contact:

#4

Post by Jack GamePlay » 2 Months Ago

Try:

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <xs>
  6.  
  7. #define PLUGIN "[ZP] AK47 Palladin Bloodmoon"
  8. #define VERSION "1.0"
  9. #define AUTHOR "AUTHOR"
  10.  
  11. // CONFIGURATION WEAPON
  12. #define system_name     "bak47p"
  13. #define system_base     "ak47"
  14.  
  15. #define DRAW_TIME       0.66
  16. #define RELOAD_TIME     2.1
  17.  
  18. #define CSW_BAK47P      CSW_AK47
  19. #define WEAPON_KEY      110918273
  20.  
  21. #define OLD_MODEL       "models/w_ak47.mdl"
  22. #define ANIMEXT         "carbine"
  23.  
  24. /*
  25. Support For Human And Survivor
  26. Not Supported For Zombie || Madafaka!!
  27. - ZP_TEAM HUMAN = HUMAN
  28. - ZP_TEAM_SURVIVOR = SURVIVOR
  29. */
  30.  
  31. // ALL MACRO
  32. #define ENG_NULLENT     -1
  33. #define EV_INT_WEAPONKEY    EV_INT_impulse
  34. #define TASK_MUZZLEFLASH    102291
  35.  
  36. #define USE_STOPPED         0
  37. #define OFFSET_LINUX_WEAPONS    4
  38. #define OFFSET_LINUX        5
  39. #define OFFSET_WEAPONOWNER  41
  40. #define OFFSET_ACTIVE_ITEM  373
  41.  
  42. #define m_fKnown        44
  43. #define m_flNextPrimaryAttack   46
  44. #define m_flTimeWeaponIdle  48
  45. #define m_iClip         51
  46. #define m_fInReload     54
  47. #define m_flNextAttack      83
  48. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  49.  
  50. // ALL ANIM
  51. #define ANIM_RELOAD     1
  52. #define ANIM_DRAW       2
  53. #define ANIM_SHOOT1     3
  54. #define ANIM_SHOOT2     4
  55. #define ANIM_SHOOT3     5
  56.  
  57. #define MODE_A          0
  58. #define MODE_B          1
  59.  
  60. // All Models Of The Weapon
  61. new V_MODEL[64] = "models/v_bak47p.mdl"
  62. new W_MODEL[64] = "models/w_bak47p.mdl"
  63. new P_MODEL[64] = "models/p_bak47p.mdl"
  64. new S_MODEL[64] = "sprites/bak47p/ef_buffak_hit.spr"
  65.  
  66. new const WeaponResources[][] =
  67. {
  68.     "sprites/bak47p/bak47p.spr",
  69.     "sprites/bak47p/bak47p.spr"
  70. }
  71.  
  72. new const MuzzleFlash[][] =
  73. {
  74.     "sprites/bak47p/muzzleflash60.spr",
  75.     "sprites/bak47p/muzzleflash65.spr",
  76.     "sprites/bak47p/muzzleflash70.spr"
  77. }
  78.  
  79. // You Can Add Fire Sound Here
  80. new const Fire_Sounds[][] = { "weapons/bak47p-1.wav", "weapons/bak47p-2.wav" }
  81.  
  82. // All Vars Here
  83. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  84. new cvar_dmg, cvar_recoil, cvar_clip, cvar_spd, cvar_ammo, cvar_radius, cvar_dmg_2, cvar_trace_color
  85. new g_MaxPlayers, g_orig_event, g_IsInPrimaryAttack, g_attack_type[33], Float:cl_pushangle[33][3]
  86. new g_had_bak47p[33], g_clip_ammo[33], g_weapon_TmpClip[33], oldweap[33], sBuffakHit
  87. new g_Muzzleflash_Ent[2], g_Muzzleflash[33][2], g_Mode[33], g_list_variables[10], bool:g_bCanDamage
  88.  
  89. // Macros Again :v
  90. new weapon_name_buffer[512]
  91. new weapon_base_buffer[512]
  92.        
  93. const PRIMARY_WEAPONS_BIT_SUM =
  94. (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<<
  95. 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)
  96. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  97.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  98.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  99.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  100.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  101.  
  102. // START TO CREATE PLUGINS || AMXMODX FORWARD
  103. public plugin_init()
  104. {
  105.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s_asep", system_name)
  106.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  107.    
  108.     register_plugin(PLUGIN, VERSION, AUTHOR)
  109.    
  110.     // Event And Message
  111.     register_event("CurWeapon", "Forward_CurrentWeapon", "be", "1=1")
  112.     register_message(get_user_msgid("DeathMsg"), "Forward_DeathMsg")
  113.     register_message(get_user_msgid("WeaponList"), "Forward_MessageWeapList")
  114.    
  115.     // Ham Forward (Entity) || Ham_Use
  116.     RegisterHam(Ham_Use, "func_tank", "Forward_UseStationary_Post", 1)
  117.     RegisterHam(Ham_Use, "func_tankmortar", "Forward_UseStationary_Post", 1)
  118.     RegisterHam(Ham_Use, "func_tankrocket", "Forward_UseStationary_Post", 1)
  119.     RegisterHam(Ham_Use, "func_tanklaser", "Forward_UseStationary_Post", 1)
  120.    
  121.     // Ham Forward (Entity) || Ham_TraceAttack
  122.     RegisterHam(Ham_TraceAttack, "player", "Forward_TraceAttack", 1)
  123.     RegisterHam(Ham_TraceAttack, "worldspawn", "Forward_TraceAttack", 1)
  124.     RegisterHam(Ham_TraceAttack, "func_wall", "Forward_TraceAttack", 1)
  125.     RegisterHam(Ham_TraceAttack, "func_breakable", "Forward_TraceAttack", 1)
  126.     RegisterHam(Ham_TraceAttack, "func_door", "Forward_TraceAttack", 1)
  127.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "Forward_TraceAttack", 1)
  128.     RegisterHam(Ham_TraceAttack, "func_rotating", "Forward_TraceAttack", 1)
  129.     RegisterHam(Ham_TraceAttack, "func_plat", "Forward_TraceAttack", 1)
  130.    
  131.     // Ham Forward (Weapon)
  132.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack")
  133.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack_Post", 1)
  134.     RegisterHam(Ham_Item_PostFrame, weapon_base_buffer, "Weapon_ItemPostFrame")
  135.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload")
  136.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload_Post", 1)
  137.     RegisterHam(Ham_Item_AddToPlayer, weapon_base_buffer, "Weapon_AddToPlayer")
  138.    
  139.     for(new i = 1; i < sizeof WEAPONENTNAMES; i++)
  140.         if(WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "Weapon_Deploy_Post", 1)
  141.        
  142.     // Ham Forward (Player)
  143.     RegisterHam(Ham_Killed, "player", "Forward_PlayerKilled")
  144.    
  145.     // Fakemeta Forward
  146.     register_forward(FM_SetModel, "Forward_SetModel")
  147.     register_forward(FM_PlaybackEvent, "Forward_PlaybackEvent")
  148.     register_forward(FM_UpdateClientData, "Forward_UpdateClientData_Post", 1)
  149.     register_forward(FM_AddToFullPack, "Forward_AddToFullPack", 1)
  150.     register_forward(FM_CheckVisibility, "Forward_CheckVisibility")
  151.    
  152.     // All Some Cvar
  153.     cvar_clip = register_cvar("bak47p_clip", "50")
  154.     cvar_spd = register_cvar("bak47p_speed", "1.15")
  155.     cvar_ammo = register_cvar("bak47p_ammo", "240")
  156.     cvar_dmg = register_cvar("bak47p_damage", "2.1")
  157.     cvar_recoil = register_cvar("bak47p_recoil", "0.62")
  158.     cvar_dmg_2 = register_cvar("bak47p_buff_damage", "350")
  159.     cvar_radius = register_cvar("bak47p_buff_radius", "75")
  160.     cvar_trace_color = register_cvar("bak47p_trace_color", "7")
  161.    
  162.     g_MaxPlayers = get_maxplayers()
  163. }
  164.  
  165. public ze_zombie_appear()
  166. {
  167.     g_bCanDamage = false
  168. }
  169.  
  170. public ze_zombie_release()
  171. {
  172.     g_bCanDamage = true
  173. }
  174.  
  175. public plugin_precache()
  176. {
  177.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s", system_name)
  178.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  179.    
  180.     precache_model(V_MODEL)
  181.     precache_model(P_MODEL)
  182.     precache_model(W_MODEL)
  183.     sBuffakHit = precache_model(S_MODEL)
  184.    
  185.     new Buffer[512]
  186.     formatex(Buffer, sizeof(Buffer), "sprites/%s.txt", weapon_name_buffer)
  187.     precache_generic(Buffer) // EG: Output "sprites/weapon_bak47p.txt"
  188.    
  189.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  190.         precache_sound(Fire_Sounds[i])
  191.     for(new i = 0; i < sizeof MuzzleFlash; i++)
  192.         precache_model(MuzzleFlash[i])
  193.     for(new i = 0; i < sizeof WeaponResources; i++)
  194.         precache_model(WeaponResources[i])
  195.        
  196.     precache_viewmodel_sound(V_MODEL)
  197.     formatex(Buffer, sizeof(Buffer), "test_%s", system_name)
  198.    
  199.     register_clcmd(Buffer, "get_bak47p") // EG: Output "test_bak47p"
  200.     register_clcmd(weapon_name_buffer, "weapon_hook")
  201.     register_forward(FM_PrecacheEvent, "Forward_PrecacheEvent_Post", 1)
  202.    
  203.     g_Muzzleflash_Ent[0] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  204.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[0], MuzzleFlash[0])
  205.     set_pev(g_Muzzleflash_Ent[0], pev_scale, 0.08)
  206.     set_pev(g_Muzzleflash_Ent[0], pev_rendermode, kRenderTransTexture)
  207.     set_pev(g_Muzzleflash_Ent[0], pev_renderamt, 0.0)
  208.  
  209.     g_Muzzleflash_Ent[1] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  210.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[1], MuzzleFlash[1])
  211.     set_pev(g_Muzzleflash_Ent[1], pev_scale, 0.07)
  212.     set_pev(g_Muzzleflash_Ent[1], pev_rendermode, kRenderTransTexture)
  213.     set_pev(g_Muzzleflash_Ent[1], pev_renderamt, 0.0)
  214. }
  215.  
  216. public plugin_natives()
  217. {
  218.     register_native("get_bak47p", "native_get_bak47p", 1)
  219. }
  220.  
  221. public native_get_bak47p(id)
  222. {
  223.     get_bak47p(id)
  224. }
  225.  
  226. // Reset Bitvar (Fix Bug) If You Connect Or Disconnect Server
  227. public client_connect(id) remove_bak47p(id)
  228. public client_disconnected(id) remove_bak47p(id)
  229. public ze_user_infected(id, iInfector) remove_bak47p(id)
  230. public ze_user_humanized(id) remove_bak47p(id)
  231. /* ========= START OF REGISTER HAM TO SUPPORT BOTS FUNC ========= */
  232. new g_HamBot
  233. public client_putinserver(id)
  234. {
  235.     if(!g_HamBot && is_user_bot(id))
  236.     {
  237.         g_HamBot = 1
  238.         set_task(0.1, "Do_RegisterHam", id)
  239.     }
  240. }
  241.  
  242. public Do_RegisterHam(id)
  243. {
  244.     RegisterHamFromEntity(Ham_Killed, id, "Forward_PlayerKilled")
  245.     RegisterHamFromEntity(Ham_TraceAttack, id, "Forward_TraceAttack", 1)
  246. }
  247.  
  248. /* ======== END OF REGISTER HAM TO SUPPORT BOTS FUNC ============= */
  249. /* ============ START OF ALL FORWARD (FAKEMETA) ================== */
  250. public Forward_AddToFullPack(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
  251. {
  252.     if(iEnt == g_Muzzleflash_Ent[0])
  253.     {
  254.         if(g_Muzzleflash[iHost][0] == 3)
  255.         {
  256.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  257.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  258.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  259.            
  260.             g_Muzzleflash[iHost][0] = 2
  261.         }
  262.         else if(g_Muzzleflash[iHost][0] == 2)
  263.         {
  264.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  265.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  266.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  267.            
  268.             g_Muzzleflash[iHost][0] = 1
  269.             g_Muzzleflash[iHost][1] = 1
  270.         }
  271.         else if(g_Muzzleflash[iHost][0] == 1)
  272.         {
  273.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  274.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  275.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  276.            
  277.             g_Muzzleflash[iHost][0] = 0
  278.         }
  279.            
  280.         set_es(esState, ES_Skin, iHost)
  281.         set_es(esState, ES_Body, 1)
  282.         set_es(esState, ES_AimEnt, iHost)
  283.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
  284.     }
  285.     else if(iEnt == g_Muzzleflash_Ent[1])
  286.     {
  287.         if(g_Muzzleflash[iHost][1])
  288.         {
  289.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  290.             set_es(esState, ES_RenderAmt, 240.0)
  291.            
  292.             g_Muzzleflash[iHost][1] = 0
  293.         }
  294.            
  295.         set_es(esState, ES_Skin, iHost)
  296.         set_es(esState, ES_Body, 1)
  297.         set_es(esState, ES_AimEnt, iHost)
  298.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
  299.     }
  300.  
  301. }
  302.  
  303. public Forward_CheckVisibility(iEntity, pSet)
  304. {
  305.     if(iEntity == g_Muzzleflash_Ent[0] || iEntity == g_Muzzleflash_Ent[1])
  306.     {
  307.         forward_return(FMV_CELL, 1)
  308.         return FMRES_SUPERCEDE
  309.     }
  310.    
  311.     return FMRES_IGNORED
  312. }
  313.  
  314. public Forward_PrecacheEvent_Post(type, const name[])
  315. {
  316.     new Buffer[512]
  317.     formatex(Buffer, sizeof(Buffer), "events/%s.sc", system_base)
  318.     if(equal(Buffer, name, 0))
  319.     {
  320.         g_orig_event = get_orig_retval()
  321.         return FMRES_HANDLED
  322.     }
  323.     return FMRES_IGNORED
  324. }
  325.  
  326. public Forward_SetModel(entity, model[])
  327. {
  328.     if(!is_valid_ent(entity))
  329.         return FMRES_IGNORED
  330.    
  331.     static szClassName[33]
  332.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  333.        
  334.     if(!equal(szClassName, "weaponbox"))
  335.         return FMRES_IGNORED
  336.    
  337.     static iOwner
  338.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  339.    
  340.     if(equal(model, OLD_MODEL))
  341.     {
  342.         static iStoredAugID
  343.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, entity)
  344.            
  345.         if(!is_valid_ent(iStoredAugID))
  346.             return FMRES_IGNORED
  347.  
  348.         if(g_had_bak47p[iOwner])
  349.         {
  350.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, WEAPON_KEY)
  351.             g_had_bak47p[iOwner] = 0
  352.             entity_set_model(entity, W_MODEL)
  353.            
  354.             return FMRES_SUPERCEDE
  355.         }
  356.     }
  357.     return FMRES_IGNORED
  358. }
  359.  
  360. public Forward_UseStationary_Post(entity, caller, activator, use_type)
  361. {
  362.     if(use_type == USE_STOPPED && is_user_connected(caller))
  363.         replace_weapon_models(caller, get_user_weapon(caller))
  364. }
  365.  
  366. public Forward_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  367. {
  368.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_BAK47P || !g_had_bak47p[Player]))
  369.         return FMRES_IGNORED
  370.    
  371.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  372.     return FMRES_HANDLED
  373. }
  374.  
  375. public Forward_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  376. {
  377.     if((eventid != g_orig_event) || !g_IsInPrimaryAttack)
  378.         return FMRES_IGNORED
  379.     if(!(1 <= invoker <= g_MaxPlayers))
  380.         return FMRES_IGNORED
  381.  
  382.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  383.     return FMRES_SUPERCEDE
  384. }
  385.  
  386. /* ================= END OF ALL FAKEMETA FORWARD ================= */
  387. /* ================= START OF ALL MESSAGE FORWARD ================ */
  388. public Forward_DeathMsg(msg_id, msg_dest, id)
  389. {
  390.     static szTruncatedWeapon[33], iAttacker, iVictim
  391.    
  392.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  393.    
  394.     iAttacker = get_msg_arg_int(1)
  395.     iVictim = get_msg_arg_int(2)
  396.    
  397.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  398.         return PLUGIN_CONTINUE
  399.    
  400.     if(equal(szTruncatedWeapon, system_base) && get_user_weapon(iAttacker) == CSW_BAK47P)
  401.     {
  402.         if(g_had_bak47p[iAttacker])
  403.             set_msg_arg_string(4, system_name)
  404.     }
  405.     return PLUGIN_CONTINUE
  406. }
  407. /* ================== END OF ALL MESSAGE FORWARD ================ */
  408. /* ================== START OF ALL EVENT FORWARD ================ */
  409. public Forward_MessageWeapList(msg_id, msg_dest, id)
  410. {
  411.     if(get_msg_arg_int(8) != CSW_BAK47P)
  412.         return
  413.      
  414.     g_list_variables[2] = get_msg_arg_int(2)
  415.     g_list_variables[3] = get_msg_arg_int(3)
  416.     g_list_variables[4] = get_msg_arg_int(4)
  417.     g_list_variables[5] = get_msg_arg_int(5)
  418.     g_list_variables[6] = get_msg_arg_int(6)
  419.     g_list_variables[7] = get_msg_arg_int(7)
  420.     g_list_variables[8] = get_msg_arg_int(8)
  421.     g_list_variables[9] = get_msg_arg_int(9)
  422. }
  423.  
  424. public Forward_CurrentWeapon(id)
  425. {
  426.     replace_weapon_models(id, read_data(2))
  427.      
  428.     if(!is_user_alive(id))
  429.         return
  430.     if(read_data(2) != CSW_BAK47P || !g_had_bak47p[id])
  431.         return
  432.      
  433.     static Float:Speed
  434.     if(g_had_bak47p[id])
  435.         Speed = get_pcvar_float(cvar_spd)
  436.    
  437.     static weapon[32], Ent
  438.     get_weaponname(read_data(2), weapon, 31)
  439.     Ent = find_ent_by_owner(-1, weapon, id)
  440.     if(pev_valid(Ent))
  441.     {
  442.         static Float:Delay
  443.         Delay = get_pdata_float(Ent, 46, 4) * Speed
  444.         if(Delay > 0.0) set_pdata_float(Ent, 46, Delay, 4)
  445.     }
  446. }
  447. /* ================== END OF ALL EVENT FORWARD =================== */
  448. /* ================== START OF ALL HAM FORWARD ============== */
  449. public Forward_PlayerKilled(id) remove_bak47p(id)
  450. public Forward_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  451. {
  452.     if(!is_user_alive(iAttacker) || !is_user_connected(iAttacker))
  453.         return
  454.     if(get_user_weapon(iAttacker) != CSW_BAK47P || !g_had_bak47p[iAttacker])
  455.         return
  456.  
  457.     static Float:flEnd[3], Float:WallVector[3], trace_color
  458.     get_tr2(ptr, TR_vecEndPos, flEnd)
  459.     get_tr2(ptr, TR_vecPlaneNormal, WallVector)
  460.    
  461.     if(iEnt)
  462.     {
  463.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  464.         write_byte(TE_DECAL)
  465.         write_coord_f(flEnd[0])
  466.         write_coord_f(flEnd[1])
  467.         write_coord_f(flEnd[2])
  468.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  469.         write_short(iEnt)
  470.         message_end()
  471.     }
  472.     else
  473.     {
  474.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  475.         write_byte(TE_WORLDDECAL)
  476.         write_coord_f(flEnd[0])
  477.         write_coord_f(flEnd[1])
  478.         write_coord_f(flEnd[2])
  479.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  480.         message_end()
  481.     }
  482.    
  483.     if(g_Mode[iAttacker] == MODE_A)
  484.     {
  485.         if(!is_user_alive(iEnt)) trace_color = get_pcvar_num(cvar_trace_color)
  486.         else if(is_user_alive(iEnt)) trace_color = 2000 // NO STREAK COLOR or Disabled
  487.         ExecuteHamB(Ham_TakeDamage, iEnt, iAttacker, iAttacker, flDamage * get_pcvar_float(cvar_dmg), DMG_BULLET)
  488.     }
  489.    
  490.     if(pev(iEnt, pev_takedamage) != DAMAGE_NO)
  491.     {
  492.         set_hudmessage(255, 0, 0, -1.0, 0.46, 0, 0.2, 0.2)
  493.         show_hudmessage(iAttacker, "\         /^n+^n/         \")
  494.     }
  495.    
  496.     if(trace_color < 2000)
  497.     {
  498.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  499.         write_byte(TE_STREAK_SPLASH)
  500.         engfunc(EngFunc_WriteCoord, flEnd[0])
  501.         engfunc(EngFunc_WriteCoord, flEnd[1])
  502.         engfunc(EngFunc_WriteCoord, flEnd[2])
  503.         engfunc(EngFunc_WriteCoord, WallVector[0] * random_float(25.0,30.0))
  504.         engfunc(EngFunc_WriteCoord, WallVector[1] * random_float(25.0,30.0))
  505.         engfunc(EngFunc_WriteCoord, WallVector[2] * random_float(25.0,30.0))
  506.         write_byte(trace_color)
  507.         write_short(50)
  508.         write_short(3)
  509.         write_short(90)
  510.         message_end()
  511.        
  512.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  513.         write_byte(TE_GUNSHOTDECAL)
  514.         write_coord_f(flEnd[0])
  515.         write_coord_f(flEnd[1])
  516.         write_coord_f(flEnd[2])
  517.         write_short(iAttacker)
  518.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  519.         message_end()
  520.     }
  521. }
  522.  
  523. public Weapon_Deploy_Post(weapon_entity)
  524. {
  525.     static owner
  526.     owner = fm_cs_get_weapon_ent_owner(weapon_entity)
  527.    
  528.     static weaponid
  529.     weaponid = cs_get_weapon_id(weapon_entity)
  530.    
  531.     replace_weapon_models(owner, weaponid)
  532. }
  533.  
  534. public Weapon_AddToPlayer(weapon_entity, id)
  535. {
  536.     if(!is_valid_ent(weapon_entity) || !is_user_connected(id))
  537.         return HAM_IGNORED
  538.    
  539.     if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == WEAPON_KEY)
  540.     {
  541.         g_had_bak47p[id] = true
  542.         entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
  543.         set_weapon_list(id, weapon_name_buffer)
  544.        
  545.         return HAM_HANDLED
  546.     }
  547.     else
  548.     {
  549.         set_weapon_list(id, weapon_base_buffer)
  550.     }
  551.    
  552.     return HAM_IGNORED
  553. }
  554.  
  555. public Weapon_PrimaryAttack(weapon_entity)
  556. {
  557.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  558.    
  559.     if(!g_had_bak47p[Player])
  560.         return
  561.    
  562.     g_IsInPrimaryAttack = 1
  563.     pev(Player,pev_punchangle,cl_pushangle[Player])
  564.    
  565.     g_clip_ammo[Player] = cs_get_weapon_ammo(weapon_entity)
  566. }
  567.  
  568. public Weapon_PrimaryAttack_Post(weapon_entity)
  569. {
  570.     g_IsInPrimaryAttack = 0
  571.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  572.    
  573.     new szClip, szAmmo
  574.     get_user_weapon(Player, szClip, szAmmo)
  575.    
  576.     if(!is_user_alive(Player))
  577.         return
  578.        
  579.     if(g_had_bak47p[Player])
  580.     {
  581.         if(!g_clip_ammo[Player])
  582.         {
  583.             ExecuteHam(Ham_Weapon_PlayEmptySound, weapon_entity)
  584.             return
  585.         }
  586.        
  587.         new Float:push[3]
  588.         pev(Player,pev_punchangle,push)
  589.         xs_vec_sub(push,cl_pushangle[Player],push)
  590.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil),push)
  591.         xs_vec_add(push,cl_pushangle[Player],push)
  592.         set_pev(Player,pev_punchangle,push)
  593.        
  594.         set_weapon_shoot_anim(Player)
  595.         emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  596.         set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", Player+TASK_MUZZLEFLASH)
  597.     }
  598. }
  599.  
  600. public Weapon_ItemPostFrame(weapon_entity)
  601. {
  602.     new id = pev(weapon_entity, pev_owner)
  603.     if(!is_user_connected(id))
  604.         return HAM_IGNORED
  605.     if(!g_had_bak47p[id])
  606.         return HAM_IGNORED
  607.  
  608.     static iClipExtra
  609.     iClipExtra = get_pcvar_num(cvar_clip)
  610.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX)
  611.  
  612.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
  613.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  614.  
  615.     new fInReload = get_pdata_int(weapon_entity, m_fInReload, OFFSET_LINUX_WEAPONS)
  616.     if(fInReload && flNextAttack <= 0.0)
  617.     {
  618.         new j = min(iClipExtra - iClip, iBpAmmo)
  619.    
  620.         set_pdata_int(weapon_entity, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS)
  621.         cs_set_user_bpammo(id, CSW_BAK47P, iBpAmmo-j)
  622.        
  623.         set_pdata_int(weapon_entity, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
  624.         fInReload = 0
  625.     }
  626.     else if(!fInReload && !get_pdata_int(weapon_entity, 74, 4))
  627.     {
  628.         if(!iClip)
  629.             return HAM_IGNORED
  630.            
  631.         if(get_pdata_float(id, 83, 5) <= 0.0 && get_pdata_float(weapon_entity, 46, 4) <= 0.0 ||
  632.         get_pdata_float(weapon_entity, 47, 4) <= 0.0 || get_pdata_float(weapon_entity, 48, 4) <= 0.0)
  633.         {
  634.             if(pev(id, pev_button) & IN_ATTACK)
  635.             {
  636.                 if(g_Mode[id] == MODE_B)
  637.                     Shoot_Special(id)
  638.             }
  639.             else if(pev(id, pev_button) & IN_ATTACK2)
  640.             {
  641.                 set_buffak_zoom(id, 0)
  642.                 set_weapons_timeidle(id, CSW_BAK47P, 0.4)
  643.                 set_player_nextattackx(id, 0.4)
  644.             }
  645.         }
  646.     }
  647.    
  648.     return HAM_IGNORED
  649. }
  650.  
  651. public Weapon_Reload(weapon_entity)
  652. {
  653.     new id = pev(weapon_entity, pev_owner)
  654.     if(!is_user_connected(id))
  655.         return HAM_IGNORED
  656.     if(!g_had_bak47p[id])
  657.         return HAM_IGNORED
  658.     static iClipExtra
  659.     if(g_had_bak47p[id])
  660.         iClipExtra = get_pcvar_num(cvar_clip)
  661.  
  662.     g_weapon_TmpClip[id] = -1
  663.  
  664.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
  665.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  666.  
  667.     if(iBpAmmo <= 0)
  668.         return HAM_SUPERCEDE
  669.  
  670.     if(iClip >= iClipExtra)
  671.         return HAM_SUPERCEDE
  672.  
  673.     g_weapon_TmpClip[id] = iClip
  674.  
  675.     return HAM_IGNORED
  676. }
  677.  
  678. public Weapon_Reload_Post(weapon_entity)
  679. {
  680.     new id = pev(weapon_entity, pev_owner)
  681.     if (!is_user_connected(id))
  682.         return HAM_IGNORED
  683.  
  684.     if(!g_had_bak47p[id])
  685.         return HAM_IGNORED
  686.     if(g_weapon_TmpClip[id] == -1)
  687.         return HAM_IGNORED
  688.    
  689.     set_pdata_int(weapon_entity, m_iClip, g_weapon_TmpClip[id], OFFSET_LINUX_WEAPONS)
  690.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, RELOAD_TIME, OFFSET_LINUX_WEAPONS)
  691.     set_pdata_float(id, m_flNextAttack, RELOAD_TIME, OFFSET_LINUX)
  692.     set_pdata_int(weapon_entity, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
  693.    
  694.     set_weapon_anim(id, ANIM_RELOAD)
  695.     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  696.     set_buffak_zoom(id, 1)
  697.    
  698.     return HAM_IGNORED
  699. }
  700.  
  701. /* ===================== END OF ALL HAM FORWARD ====================== */
  702. /* ================= START OF OTHER PUBLIC FUNCTION  ================= */
  703. public get_bak47p(id)
  704. {
  705.     drop_weapons(id, 1)
  706.     new iWeapon = fm_give_item(id, weapon_base_buffer)
  707.     if(iWeapon > 0)
  708.     {
  709.         cs_set_weapon_ammo(iWeapon, get_pcvar_num(cvar_clip))
  710.         cs_set_user_bpammo(id, CSW_BAK47P, get_pcvar_num(cvar_ammo))
  711.         emit_sound(id, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM,0,PITCH_NORM)
  712.        
  713.         set_weapon_anim(id, ANIM_DRAW)
  714.         set_pdata_float(id, m_flNextAttack, DRAW_TIME, OFFSET_LINUX)
  715.        
  716.         set_weapon_list(id, weapon_name_buffer)
  717.         set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  718.         set_pdata_int(iWeapon, 74, MODE_A)
  719.     }
  720.    
  721.     g_had_bak47p[id] = true
  722.     g_Mode[id] = MODE_A
  723.     remove_bitvar(id)
  724. }
  725.  
  726. public remove_bak47p(id)
  727. {
  728.     g_had_bak47p[id] = false
  729.     g_Mode[id] = MODE_A
  730.     remove_bitvar(id)
  731. }
  732.  
  733. public remove_bitvar(id)
  734. {
  735.     g_attack_type[id] = 0
  736.     g_Muzzleflash[id][0] = 0
  737.     g_Muzzleflash[id][1] = 0
  738. }
  739.  
  740. public weapon_hook(id)
  741. {
  742.     engclient_cmd(id, weapon_base_buffer)
  743.     return PLUGIN_HANDLED
  744. }
  745.  
  746. public replace_weapon_models(id, weaponid)
  747. {
  748.     if(weaponid != CSW_BAK47P)
  749.     {
  750.         if(g_had_bak47p[id])
  751.         {
  752.             remove_bitvar(id)
  753.             set_buffak_zoom(id, 1)
  754.         }
  755.     }
  756.    
  757.     switch(weaponid)
  758.     {
  759.         case CSW_BAK47P:
  760.         {
  761.             if(g_had_bak47p[id])
  762.             {
  763.                 set_pev(id, pev_viewmodel2, V_MODEL)
  764.                 set_pev(id, pev_weaponmodel2, P_MODEL)
  765.                
  766.                 if(oldweap[id] != CSW_BAK47P)
  767.                 {
  768.                     set_weapon_anim(id, ANIM_DRAW)
  769.                     set_player_nextattackx(id, DRAW_TIME)
  770.                     set_weapons_timeidle(id, CSW_BAK47P, DRAW_TIME)
  771.                     set_weapon_list(id, weapon_name_buffer)
  772.                     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  773.                 }
  774.             }
  775.         }
  776.     }
  777.    
  778.     oldweap[id] = weaponid
  779. }
  780.  
  781. public Shoot_Special(id)
  782. {
  783.     if(!is_user_alive(id) || !is_user_connected(id))
  784.         return
  785.        
  786.     new szClip, szWeapId
  787.     szWeapId = get_user_weapon(id, szClip)
  788.     if(szWeapId != CSW_BAK47P || !g_had_bak47p[id] || !szClip)
  789.         return
  790.    
  791.     g_Muzzleflash[id][0] = 3
  792.     set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", id+TASK_MUZZLEFLASH)
  793.    
  794.     static Float:PunchAngles[3]
  795.     PunchAngles[0] = -5.0
  796.     PunchAngles[1] = -2.5
  797.     PunchAngles[2] = -2.5
  798.     set_pev(id, pev_punchangle, PunchAngles)
  799.    
  800.     set_weapon_shoot_anim(id)
  801.     emit_sound(id, CHAN_WEAPON, Fire_Sounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  802.    
  803.     new Float:fStart[3], Float:originF[3]
  804.     new target, body
  805.    
  806.     fm_get_aim_origin(id, originF)
  807.     get_user_aiming(id, target, body)
  808.    
  809.     pev(id, pev_origin, fStart)
  810.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fStart, 0)
  811.     write_byte(TE_SPRITE)
  812.     engfunc(EngFunc_WriteCoord, originF[0])
  813.     engfunc(EngFunc_WriteCoord, originF[1])
  814.     engfunc(EngFunc_WriteCoord, originF[2] + 20.0)
  815.     write_short(sBuffakHit)
  816.     write_byte(10)
  817.     write_byte(240)
  818.     message_end()
  819.    
  820.     new a = FM_NULLENT
  821.     while((a = find_ent_in_sphere(a, originF, float(get_pcvar_num(cvar_radius)))) != 0)
  822.     {
  823.         if(id == a)
  824.             continue
  825.  
  826.         if (!ze_is_user_zombie(a) || !g_bCanDamage)
  827.             continue
  828.    
  829.         if(pev(a, pev_takedamage) != DAMAGE_NO)
  830.             ExecuteHamB(Ham_TakeDamage, a, 0, id, float(get_pcvar_num(cvar_dmg_2)), DMG_BULLET)
  831.     }
  832.    
  833.     if(!is_user_alive(target))
  834.     {
  835.         static Classname[32]
  836.         pev(target, pev_classname, Classname, sizeof(Classname))
  837.        
  838.         if(equal(Classname, "func_breakable"))
  839.             ExecuteHamB(Ham_TakeDamage, target, 0, 0, float(get_pcvar_num(cvar_dmg_2)), DMG_GENERIC)
  840.     }
  841.     else if(is_user_alive(target) && is_user_connected(target))
  842.     {
  843.         static Float:MyOrigin[3]
  844.         pev(id, pev_origin, MyOrigin)
  845.         hook_ent2(target, MyOrigin, 400.0, 2)
  846.         ExecuteHamB(Ham_TakeDamage, target, 0, id, float(get_pcvar_num(cvar_dmg_2))*0.75, DMG_BULLET)
  847.     }
  848.    
  849.     static entity_weapon
  850.     entity_weapon = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, id)
  851.    
  852.     if(!pev_valid(entity_weapon))
  853.         return
  854.    
  855.     cs_set_weapon_ammo(entity_weapon, szClip - 1)
  856.     set_player_nextattackx(id, 0.7)
  857.     set_weapons_timeidle(id, CSW_BAK47P, 0.7)
  858. }
  859.  
  860. public set_weapon_shoot_anim(id)
  861. {
  862.     if(!g_attack_type[id])
  863.     {
  864.         set_weapon_anim(id, ANIM_SHOOT1)
  865.         g_attack_type[id] = 1
  866.     }
  867.     else if(g_attack_type[id] == 1)
  868.     {
  869.         set_weapon_anim(id, ANIM_SHOOT2)
  870.         g_attack_type[id] = 2
  871.     }
  872.     else if(g_attack_type[id] == 2)
  873.     {
  874.         set_weapon_anim(id, ANIM_SHOOT3)
  875.         g_attack_type[id] = 0
  876.     }
  877. }
  878.  
  879. public Re_MuzzleFlash(id)
  880. {
  881.     id -= TASK_MUZZLEFLASH
  882.  
  883.     if(!is_user_alive(id) || !is_user_connected(id))
  884.         return
  885.     if(get_user_weapon(id) != CSW_BAK47P || !g_had_bak47p[id])
  886.         return
  887.    
  888.     if(g_Mode[id] == MODE_A) g_Muzzleflash[id][0] = true
  889.     else if(g_Mode[id] == MODE_B) g_Muzzleflash[id][1] = true
  890. }
  891.  
  892. /* ============= END OF OTHER PUBLIC FUNCTION (Weapon) ============= */
  893. /* ================= START OF ALL STOCK TO MACROS ================== */
  894. stock set_buffak_zoom(id, const reset = 0)
  895. {
  896.     if(reset == 1)
  897.     {
  898.         set_fov(id)
  899.         g_Mode[id] = MODE_A
  900.     }
  901.     else if(reset == 0)
  902.     {
  903.         if(g_Mode[id] == MODE_A)
  904.         {
  905.             set_fov(id, 80)
  906.             g_Mode[id] = MODE_B
  907.         }
  908.         else if(g_Mode[id] == MODE_B)
  909.         {
  910.             set_fov(id)
  911.             g_Mode[id] = MODE_A
  912.         }
  913.     }
  914. }
  915.  
  916. stock set_fov(id, fov = 90)
  917. {
  918.     message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id)
  919.     write_byte(fov)
  920.     message_end()
  921. }
  922.  
  923. stock set_weapon_list(id, const weapon_name[])
  924. {
  925.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
  926.     write_string(weapon_name)
  927.     write_byte(g_list_variables[2])
  928.     write_byte(g_list_variables[3])
  929.     write_byte(g_list_variables[4])
  930.     write_byte(g_list_variables[5])
  931.     write_byte(g_list_variables[6])
  932.     write_byte(g_list_variables[7])
  933.     write_byte(g_list_variables[8])
  934.     write_byte(g_list_variables[9])
  935.     message_end()
  936. }
  937.  
  938. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
  939. {
  940.     static Float:fl_Velocity[3]
  941.     static Float:EntOrigin[3]
  942.    
  943.     pev(ent, pev_origin, EntOrigin)
  944.     static Float:distance_f
  945.     distance_f = 100.0
  946.    
  947.     new Float:fl_Time = distance_f / speed
  948.     if(type == 1)
  949.     {
  950.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
  951.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
  952.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time       
  953.     }
  954.     else if(type == 2)
  955.     {
  956.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
  957.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
  958.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
  959.     }
  960.    
  961.     entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
  962. }
  963.  
  964. stock drop_weapons(id, dropwhat)
  965. {
  966.     static weapons[32], num = 0, i, weaponid
  967.     get_user_weapons(id, weapons, num)
  968.      
  969.     for (i = 0; i < num; i++)
  970.     {
  971.         weaponid = weapons[i]
  972.          
  973.         if(dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  974.         {
  975.             static wname[32]
  976.             get_weaponname(weaponid, wname, sizeof wname - 1)
  977.             engclient_cmd(id, "drop", wname)
  978.         }
  979.     }
  980. }
  981.  
  982. stock set_player_nextattackx(id, Float:nexttime)
  983. {
  984.     if(!is_user_alive(id))
  985.         return
  986.        
  987.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  988. }
  989.  
  990. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  991. {
  992.     if(!is_user_alive(id))
  993.         return
  994.        
  995.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  996.     if(!pev_valid(entwpn))
  997.         return
  998.        
  999.     set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
  1000.     set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
  1001.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, OFFSET_LINUX_WEAPONS)
  1002. }
  1003.  
  1004. stock set_weapons_timeidlex(id, Float:TimeIdle, Float:Idle)
  1005. {
  1006.     new entwpn = fm_get_user_weapon_entity(id, CSW_BASE)
  1007.     if(!pev_valid(entwpn))
  1008.         return
  1009.    
  1010.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  1011.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  1012.     set_pdata_float(entwpn, 48, Idle, 4)
  1013. }
  1014.  
  1015. stock set_weapon_anim(const Player, const Sequence)
  1016. {
  1017.     set_pev(Player, pev_weaponanim, Sequence)
  1018.    
  1019.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  1020.     write_byte(Sequence)
  1021.     write_byte(pev(Player, pev_body))
  1022.     message_end()
  1023. }
  1024.  
  1025. stock precache_viewmodel_sound(const model[]) // I Get This From BTE
  1026. {
  1027.     new file, i, k
  1028.     if((file = fopen(model, "rt")))
  1029.     {
  1030.         new szsoundpath[64], NumSeq, SeqID, Event, NumEvents, EventID
  1031.         fseek(file, 164, SEEK_SET)
  1032.         fread(file, NumSeq, BLOCK_INT)
  1033.         fread(file, SeqID, BLOCK_INT)
  1034.        
  1035.         for(i = 0; i < NumSeq; i++)
  1036.         {
  1037.             fseek(file, SeqID + 48 + 176 * i, SEEK_SET)
  1038.             fread(file, NumEvents, BLOCK_INT)
  1039.             fread(file, EventID, BLOCK_INT)
  1040.             fseek(file, EventID + 176 * i, SEEK_SET)
  1041.            
  1042.             // The Output Is All Sound To Precache In ViewModels (GREAT :V)
  1043.             for(k = 0; k < NumEvents; k++)
  1044.             {
  1045.                 fseek(file, EventID + 4 + 76 * k, SEEK_SET)
  1046.                 fread(file, Event, BLOCK_INT)
  1047.                 fseek(file, 4, SEEK_CUR)
  1048.                
  1049.                 if(Event != 5004)
  1050.                     continue
  1051.                
  1052.                 fread_blocks(file, szsoundpath, 64, BLOCK_CHAR)
  1053.                
  1054.                 if(strlen(szsoundpath))
  1055.                 {
  1056.                     strtolower(szsoundpath)
  1057.                     engfunc(EngFunc_PrecacheSound, szsoundpath)
  1058.                 }
  1059.             }
  1060.         }
  1061.     }
  1062.     fclose(file)
  1063. }
  1064.  
  1065. stock fm_cs_get_weapon_ent_owner(ent)
  1066. {
  1067.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  1068. }
  1069.  
  1070. /* ================= END OF ALL STOCK AND PLUGINS CREATED ================== */
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 439
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#5

Post by czirimbolo » 2 Months Ago

I can still push back with this
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 439
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#6

Post by czirimbolo » 1 Month Ago

can someone help me with this ?
Image

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 3 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#7

Post by Mark » 1 Month Ago

Tell us what this does...

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <xs>
  6.  
  7. #define PLUGIN "[ZP] AK47 Palladin Bloodmoon"
  8. #define VERSION "1.0"
  9. #define AUTHOR "AUTHOR"
  10.  
  11. // CONFIGURATION WEAPON
  12. #define system_name     "bak47p"
  13. #define system_base     "ak47"
  14.  
  15. #define DRAW_TIME       0.66
  16. #define RELOAD_TIME     2.1
  17.  
  18. #define CSW_BAK47P      CSW_AK47
  19. #define WEAPON_KEY      110918273
  20.  
  21. #define OLD_MODEL       "models/w_ak47.mdl"
  22. #define ANIMEXT         "carbine"
  23.  
  24. /*
  25. Support For Human And Survivor
  26. Not Supported For Zombie || Madafaka!!
  27. - ZP_TEAM HUMAN = HUMAN
  28. - ZP_TEAM_SURVIVOR = SURVIVOR
  29. */
  30.  
  31. // ALL MACRO
  32. #define ENG_NULLENT     -1
  33. #define EV_INT_WEAPONKEY    EV_INT_impulse
  34. #define TASK_MUZZLEFLASH    102291
  35.  
  36. #define USE_STOPPED         0
  37. #define OFFSET_LINUX_WEAPONS    4
  38. #define OFFSET_LINUX        5
  39. #define OFFSET_WEAPONOWNER  41
  40. #define OFFSET_ACTIVE_ITEM  373
  41.  
  42. #define m_fKnown        44
  43. #define m_flNextPrimaryAttack   46
  44. #define m_flTimeWeaponIdle  48
  45. #define m_iClip         51
  46. #define m_fInReload     54
  47. #define m_flNextAttack      83
  48. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  49.  
  50. // ALL ANIM
  51. #define ANIM_RELOAD     1
  52. #define ANIM_DRAW       2
  53. #define ANIM_SHOOT1     3
  54. #define ANIM_SHOOT2     4
  55. #define ANIM_SHOOT3     5
  56.  
  57. #define MODE_A          0
  58. #define MODE_B          1
  59.  
  60. // All Models Of The Weapon
  61. new V_MODEL[64] = "models/v_bak47p.mdl"
  62. new W_MODEL[64] = "models/w_bak47p.mdl"
  63. new P_MODEL[64] = "models/p_bak47p.mdl"
  64. new S_MODEL[64] = "sprites/bak47p/ef_buffak_hit.spr"
  65.  
  66. new const WeaponResources[][] =
  67. {
  68.     "sprites/bak47p/bak47p.spr",
  69.     "sprites/bak47p/bak47p.spr"
  70. }
  71.  
  72. new const MuzzleFlash[][] =
  73. {
  74.     "sprites/bak47p/muzzleflash60.spr",
  75.     "sprites/bak47p/muzzleflash65.spr",
  76.     "sprites/bak47p/muzzleflash70.spr"
  77. }
  78.  
  79. // You Can Add Fire Sound Here
  80. new const Fire_Sounds[][] = { "weapons/bak47p-1.wav", "weapons/bak47p-2.wav" }
  81.  
  82. // All Vars Here
  83. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  84. new cvar_dmg, cvar_recoil, cvar_clip, cvar_spd, cvar_ammo, cvar_radius, cvar_dmg_2, cvar_trace_color
  85. new g_MaxPlayers, g_orig_event, g_IsInPrimaryAttack, g_attack_type[33], Float:cl_pushangle[33][3]
  86. new g_had_bak47p[33], g_clip_ammo[33], g_weapon_TmpClip[33], oldweap[33], sBuffakHit
  87. new g_Muzzleflash_Ent[2], g_Muzzleflash[33][2], g_Mode[33], g_list_variables[10], bool:g_bCanDamage
  88.  
  89. // Macros Again :v
  90. new weapon_name_buffer[512]
  91. new weapon_base_buffer[512]
  92.        
  93. const PRIMARY_WEAPONS_BIT_SUM =
  94. (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<<
  95. 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)
  96. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  97.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  98.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  99.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  100.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  101.  
  102. // START TO CREATE PLUGINS || AMXMODX FORWARD
  103. public plugin_init()
  104. {
  105.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s_asep", system_name)
  106.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  107.    
  108.     register_plugin(PLUGIN, VERSION, AUTHOR)
  109.    
  110.     // Event And Message
  111.     register_event("CurWeapon", "Forward_CurrentWeapon", "be", "1=1")
  112.     register_message(get_user_msgid("DeathMsg"), "Forward_DeathMsg")
  113.     register_message(get_user_msgid("WeaponList"), "Forward_MessageWeapList")
  114.    
  115.     // Ham Forward (Entity) || Ham_Use
  116.     RegisterHam(Ham_Use, "func_tank", "Forward_UseStationary_Post", 1)
  117.     RegisterHam(Ham_Use, "func_tankmortar", "Forward_UseStationary_Post", 1)
  118.     RegisterHam(Ham_Use, "func_tankrocket", "Forward_UseStationary_Post", 1)
  119.     RegisterHam(Ham_Use, "func_tanklaser", "Forward_UseStationary_Post", 1)
  120.    
  121.     // Ham Forward (Entity) || Ham_TraceAttack
  122.     RegisterHam(Ham_TraceAttack, "player", "Forward_TraceAttack", 1)
  123.     RegisterHam(Ham_TraceAttack, "worldspawn", "Forward_TraceAttack", 1)
  124.     RegisterHam(Ham_TraceAttack, "func_wall", "Forward_TraceAttack", 1)
  125.     RegisterHam(Ham_TraceAttack, "func_breakable", "Forward_TraceAttack", 1)
  126.     RegisterHam(Ham_TraceAttack, "func_door", "Forward_TraceAttack", 1)
  127.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "Forward_TraceAttack", 1)
  128.     RegisterHam(Ham_TraceAttack, "func_rotating", "Forward_TraceAttack", 1)
  129.     RegisterHam(Ham_TraceAttack, "func_plat", "Forward_TraceAttack", 1)
  130.    
  131.     // Ham Forward (Weapon)
  132.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack")
  133.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base_buffer, "Weapon_PrimaryAttack_Post", 1)
  134.     RegisterHam(Ham_Item_PostFrame, weapon_base_buffer, "Weapon_ItemPostFrame")
  135.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload")
  136.     RegisterHam(Ham_Weapon_Reload, weapon_base_buffer, "Weapon_Reload_Post", 1)
  137.     RegisterHam(Ham_Item_AddToPlayer, weapon_base_buffer, "Weapon_AddToPlayer")
  138.    
  139.     for(new i = 1; i < sizeof WEAPONENTNAMES; i++)
  140.         if(WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "Weapon_Deploy_Post", 1)
  141.        
  142.     // Ham Forward (Player)
  143.     RegisterHam(Ham_Killed, "player", "Forward_PlayerKilled")
  144.    
  145.     // Fakemeta Forward
  146.     register_forward(FM_SetModel, "Forward_SetModel")
  147.     register_forward(FM_PlaybackEvent, "Forward_PlaybackEvent")
  148.     register_forward(FM_UpdateClientData, "Forward_UpdateClientData_Post", 1)
  149.     register_forward(FM_AddToFullPack, "Forward_AddToFullPack", 1)
  150.     register_forward(FM_CheckVisibility, "Forward_CheckVisibility")
  151.    
  152.     // All Some Cvar
  153.     cvar_clip = register_cvar("bak47p_clip", "50")
  154.     cvar_spd = register_cvar("bak47p_speed", "1.15")
  155.     cvar_ammo = register_cvar("bak47p_ammo", "240")
  156.     cvar_dmg = register_cvar("bak47p_damage", "2.1")
  157.     cvar_recoil = register_cvar("bak47p_recoil", "0.62")
  158.     cvar_dmg_2 = register_cvar("bak47p_buff_damage", "350")
  159.     cvar_radius = register_cvar("bak47p_buff_radius", "75")
  160.     cvar_trace_color = register_cvar("bak47p_trace_color", "7")
  161.    
  162.     g_MaxPlayers = get_maxplayers()
  163. }
  164.  
  165. public ze_zombie_appear()
  166. {
  167.     g_bCanDamage = false
  168. }
  169.  
  170. public ze_zombie_release()
  171. {
  172.     g_bCanDamage = true
  173. }
  174.  
  175. public plugin_precache()
  176. {
  177.     formatex(weapon_name_buffer, sizeof(weapon_name_buffer), "weapon_%s", system_name)
  178.     formatex(weapon_base_buffer, sizeof(weapon_base_buffer), "weapon_%s", system_base)
  179.    
  180.     precache_model(V_MODEL)
  181.     precache_model(P_MODEL)
  182.     precache_model(W_MODEL)
  183.     sBuffakHit = precache_model(S_MODEL)
  184.    
  185.     new Buffer[512]
  186.     formatex(Buffer, sizeof(Buffer), "sprites/%s.txt", weapon_name_buffer)
  187.     precache_generic(Buffer) // EG: Output "sprites/weapon_bak47p.txt"
  188.    
  189.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  190.         precache_sound(Fire_Sounds[i])
  191.     for(new i = 0; i < sizeof MuzzleFlash; i++)
  192.         precache_model(MuzzleFlash[i])
  193.     for(new i = 0; i < sizeof WeaponResources; i++)
  194.         precache_model(WeaponResources[i])
  195.        
  196.     precache_viewmodel_sound(V_MODEL)
  197.     formatex(Buffer, sizeof(Buffer), "test_%s", system_name)
  198.    
  199.     register_clcmd(Buffer, "get_bak47p") // EG: Output "test_bak47p"
  200.     register_clcmd(weapon_name_buffer, "weapon_hook")
  201.     register_forward(FM_PrecacheEvent, "Forward_PrecacheEvent_Post", 1)
  202.    
  203.     g_Muzzleflash_Ent[0] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  204.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[0], MuzzleFlash[0])
  205.     set_pev(g_Muzzleflash_Ent[0], pev_scale, 0.08)
  206.     set_pev(g_Muzzleflash_Ent[0], pev_rendermode, kRenderTransTexture)
  207.     set_pev(g_Muzzleflash_Ent[0], pev_renderamt, 0.0)
  208.  
  209.     g_Muzzleflash_Ent[1] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  210.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent[1], MuzzleFlash[1])
  211.     set_pev(g_Muzzleflash_Ent[1], pev_scale, 0.07)
  212.     set_pev(g_Muzzleflash_Ent[1], pev_rendermode, kRenderTransTexture)
  213.     set_pev(g_Muzzleflash_Ent[1], pev_renderamt, 0.0)
  214. }
  215.  
  216. public plugin_natives()
  217. {
  218.     register_native("get_bak47p", "native_get_bak47p", 1)
  219. }
  220.  
  221. public native_get_bak47p(id)
  222. {
  223.     get_bak47p(id)
  224. }
  225.  
  226. // Reset Bitvar (Fix Bug) If You Connect Or Disconnect Server
  227. public client_connect(id) remove_bak47p(id)
  228. public client_disconnected(id) remove_bak47p(id)
  229. public ze_user_infected(id, iInfector) remove_bak47p(id)
  230. public ze_user_humanized(id) remove_bak47p(id)
  231. /* ========= START OF REGISTER HAM TO SUPPORT BOTS FUNC ========= */
  232. new g_HamBot
  233. public client_putinserver(id)
  234. {
  235.     if(!g_HamBot && is_user_bot(id))
  236.     {
  237.         g_HamBot = 1
  238.         set_task(0.1, "Do_RegisterHam", id)
  239.     }
  240. }
  241.  
  242. public Do_RegisterHam(id)
  243. {
  244.     RegisterHamFromEntity(Ham_Killed, id, "Forward_PlayerKilled")
  245.     RegisterHamFromEntity(Ham_TraceAttack, id, "Forward_TraceAttack", 1)
  246. }
  247.  
  248. /* ======== END OF REGISTER HAM TO SUPPORT BOTS FUNC ============= */
  249. /* ============ START OF ALL FORWARD (FAKEMETA) ================== */
  250. public Forward_AddToFullPack(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
  251. {
  252.     if(iEnt == g_Muzzleflash_Ent[0])
  253.     {
  254.         if(g_Muzzleflash[iHost][0] == 3)
  255.         {
  256.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  257.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  258.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  259.            
  260.             g_Muzzleflash[iHost][0] = 2
  261.         }
  262.         else if(g_Muzzleflash[iHost][0] == 2)
  263.         {
  264.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  265.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  266.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  267.            
  268.             g_Muzzleflash[iHost][0] = 1
  269.             g_Muzzleflash[iHost][1] = 1
  270.         }
  271.         else if(g_Muzzleflash[iHost][0] == 1)
  272.         {
  273.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  274.             set_es(esState, ES_RenderAmt, random_float(200.0, 255.0))
  275.             set_es(esState, ES_Scale, random_float(0.06, 0.1))
  276.            
  277.             g_Muzzleflash[iHost][0] = 0
  278.         }
  279.            
  280.         set_es(esState, ES_Skin, iHost)
  281.         set_es(esState, ES_Body, 1)
  282.         set_es(esState, ES_AimEnt, iHost)
  283.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
  284.     }
  285.     else if(iEnt == g_Muzzleflash_Ent[1])
  286.     {
  287.         if(g_Muzzleflash[iHost][1])
  288.         {
  289.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  290.             set_es(esState, ES_RenderAmt, 240.0)
  291.            
  292.             g_Muzzleflash[iHost][1] = 0
  293.         }
  294.            
  295.         set_es(esState, ES_Skin, iHost)
  296.         set_es(esState, ES_Body, 1)
  297.         set_es(esState, ES_AimEnt, iHost)
  298.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
  299.     }
  300.  
  301. }
  302.  
  303. public Forward_CheckVisibility(iEntity, pSet)
  304. {
  305.     if(iEntity == g_Muzzleflash_Ent[0] || iEntity == g_Muzzleflash_Ent[1])
  306.     {
  307.         forward_return(FMV_CELL, 1)
  308.         return FMRES_SUPERCEDE
  309.     }
  310.    
  311.     return FMRES_IGNORED
  312. }
  313.  
  314. public Forward_PrecacheEvent_Post(type, const name[])
  315. {
  316.     new Buffer[512]
  317.     formatex(Buffer, sizeof(Buffer), "events/%s.sc", system_base)
  318.     if(equal(Buffer, name, 0))
  319.     {
  320.         g_orig_event = get_orig_retval()
  321.         return FMRES_HANDLED
  322.     }
  323.     return FMRES_IGNORED
  324. }
  325.  
  326. public Forward_SetModel(entity, model[])
  327. {
  328.     if(!is_valid_ent(entity))
  329.         return FMRES_IGNORED
  330.    
  331.     static szClassName[33]
  332.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  333.        
  334.     if(!equal(szClassName, "weaponbox"))
  335.         return FMRES_IGNORED
  336.    
  337.     static iOwner
  338.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  339.    
  340.     if(equal(model, OLD_MODEL))
  341.     {
  342.         static iStoredAugID
  343.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, entity)
  344.            
  345.         if(!is_valid_ent(iStoredAugID))
  346.             return FMRES_IGNORED
  347.  
  348.         if(g_had_bak47p[iOwner])
  349.         {
  350.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, WEAPON_KEY)
  351.             g_had_bak47p[iOwner] = 0
  352.             entity_set_model(entity, W_MODEL)
  353.            
  354.             return FMRES_SUPERCEDE
  355.         }
  356.     }
  357.     return FMRES_IGNORED
  358. }
  359.  
  360. public Forward_UseStationary_Post(entity, caller, activator, use_type)
  361. {
  362.     if(use_type == USE_STOPPED && is_user_connected(caller))
  363.         replace_weapon_models(caller, get_user_weapon(caller))
  364. }
  365.  
  366. public Forward_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  367. {
  368.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_BAK47P || !g_had_bak47p[Player]))
  369.         return FMRES_IGNORED
  370.    
  371.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  372.     return FMRES_HANDLED
  373. }
  374.  
  375. public Forward_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  376. {
  377.     if((eventid != g_orig_event) || !g_IsInPrimaryAttack)
  378.         return FMRES_IGNORED
  379.     if(!(1 <= invoker <= g_MaxPlayers))
  380.         return FMRES_IGNORED
  381.  
  382.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  383.     return FMRES_SUPERCEDE
  384. }
  385.  
  386. /* ================= END OF ALL FAKEMETA FORWARD ================= */
  387. /* ================= START OF ALL MESSAGE FORWARD ================ */
  388. public Forward_DeathMsg(msg_id, msg_dest, id)
  389. {
  390.     static szTruncatedWeapon[33], iAttacker, iVictim
  391.    
  392.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  393.    
  394.     iAttacker = get_msg_arg_int(1)
  395.     iVictim = get_msg_arg_int(2)
  396.    
  397.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  398.         return PLUGIN_CONTINUE
  399.    
  400.     if(equal(szTruncatedWeapon, system_base) && get_user_weapon(iAttacker) == CSW_BAK47P)
  401.     {
  402.         if(g_had_bak47p[iAttacker])
  403.             set_msg_arg_string(4, system_name)
  404.     }
  405.     return PLUGIN_CONTINUE
  406. }
  407. /* ================== END OF ALL MESSAGE FORWARD ================ */
  408. /* ================== START OF ALL EVENT FORWARD ================ */
  409. public Forward_MessageWeapList(msg_id, msg_dest, id)
  410. {
  411.     if(get_msg_arg_int(8) != CSW_BAK47P)
  412.         return
  413.      
  414.     g_list_variables[2] = get_msg_arg_int(2)
  415.     g_list_variables[3] = get_msg_arg_int(3)
  416.     g_list_variables[4] = get_msg_arg_int(4)
  417.     g_list_variables[5] = get_msg_arg_int(5)
  418.     g_list_variables[6] = get_msg_arg_int(6)
  419.     g_list_variables[7] = get_msg_arg_int(7)
  420.     g_list_variables[8] = get_msg_arg_int(8)
  421.     g_list_variables[9] = get_msg_arg_int(9)
  422. }
  423.  
  424. public Forward_CurrentWeapon(id)
  425. {
  426.     replace_weapon_models(id, read_data(2))
  427.      
  428.     if(!is_user_alive(id))
  429.         return
  430.     if(read_data(2) != CSW_BAK47P || !g_had_bak47p[id])
  431.         return
  432.      
  433.     static Float:Speed
  434.     if(g_had_bak47p[id])
  435.         Speed = get_pcvar_float(cvar_spd)
  436.    
  437.     static weapon[32], Ent
  438.     get_weaponname(read_data(2), weapon, 31)
  439.     Ent = find_ent_by_owner(-1, weapon, id)
  440.     if(pev_valid(Ent))
  441.     {
  442.         static Float:Delay
  443.         Delay = get_pdata_float(Ent, 46, 4) * Speed
  444.         if(Delay > 0.0) set_pdata_float(Ent, 46, Delay, 4)
  445.     }
  446. }
  447. /* ================== END OF ALL EVENT FORWARD =================== */
  448. /* ================== START OF ALL HAM FORWARD ============== */
  449. public Forward_PlayerKilled(id) remove_bak47p(id)
  450. public Forward_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  451. {
  452.     if(!is_user_alive(iAttacker) || !is_user_connected(iAttacker))
  453.         return
  454.     if(get_user_weapon(iAttacker) != CSW_BAK47P || !g_had_bak47p[iAttacker])
  455.         return
  456.  
  457.     static Float:flEnd[3], Float:WallVector[3], trace_color
  458.     get_tr2(ptr, TR_vecEndPos, flEnd)
  459.     get_tr2(ptr, TR_vecPlaneNormal, WallVector)
  460.    
  461.     if(iEnt)
  462.     {
  463.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  464.         write_byte(TE_DECAL)
  465.         write_coord_f(flEnd[0])
  466.         write_coord_f(flEnd[1])
  467.         write_coord_f(flEnd[2])
  468.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  469.         write_short(iEnt)
  470.         message_end()
  471.     }
  472.     else
  473.     {
  474.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  475.         write_byte(TE_WORLDDECAL)
  476.         write_coord_f(flEnd[0])
  477.         write_coord_f(flEnd[1])
  478.         write_coord_f(flEnd[2])
  479.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  480.         message_end()
  481.     }
  482.    
  483.     if(g_Mode[iAttacker] == MODE_A)
  484.     {
  485.         if(!is_user_alive(iEnt)) trace_color = get_pcvar_num(cvar_trace_color)
  486.         else if(is_user_alive(iEnt)) trace_color = 2000 // NO STREAK COLOR or Disabled
  487.         ExecuteHamB(Ham_TakeDamage, iEnt, iAttacker, iAttacker, flDamage * get_pcvar_float(cvar_dmg), DMG_BULLET)
  488.     }
  489.    
  490.     if(pev(iEnt, pev_takedamage) != DAMAGE_NO)
  491.     {
  492.         set_hudmessage(255, 0, 0, -1.0, 0.46, 0, 0.2, 0.2)
  493.         show_hudmessage(iAttacker, "\         /^n+^n/         \")
  494.     }
  495.    
  496.     if(trace_color < 2000)
  497.     {
  498.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  499.         write_byte(TE_STREAK_SPLASH)
  500.         engfunc(EngFunc_WriteCoord, flEnd[0])
  501.         engfunc(EngFunc_WriteCoord, flEnd[1])
  502.         engfunc(EngFunc_WriteCoord, flEnd[2])
  503.         engfunc(EngFunc_WriteCoord, WallVector[0] * random_float(25.0,30.0))
  504.         engfunc(EngFunc_WriteCoord, WallVector[1] * random_float(25.0,30.0))
  505.         engfunc(EngFunc_WriteCoord, WallVector[2] * random_float(25.0,30.0))
  506.         write_byte(trace_color)
  507.         write_short(50)
  508.         write_short(3)
  509.         write_short(90)
  510.         message_end()
  511.        
  512.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  513.         write_byte(TE_GUNSHOTDECAL)
  514.         write_coord_f(flEnd[0])
  515.         write_coord_f(flEnd[1])
  516.         write_coord_f(flEnd[2])
  517.         write_short(iAttacker)
  518.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  519.         message_end()
  520.     }
  521. }
  522.  
  523. public Weapon_Deploy_Post(weapon_entity)
  524. {
  525.     static owner
  526.     owner = fm_cs_get_weapon_ent_owner(weapon_entity)
  527.    
  528.     static weaponid
  529.     weaponid = cs_get_weapon_id(weapon_entity)
  530.    
  531.     replace_weapon_models(owner, weaponid)
  532. }
  533.  
  534. public Weapon_AddToPlayer(weapon_entity, id)
  535. {
  536.     if(!is_valid_ent(weapon_entity) || !is_user_connected(id))
  537.         return HAM_IGNORED
  538.    
  539.     if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == WEAPON_KEY)
  540.     {
  541.         g_had_bak47p[id] = true
  542.         entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
  543.         set_weapon_list(id, weapon_name_buffer)
  544.        
  545.         return HAM_HANDLED
  546.     }
  547.     else
  548.     {
  549.         set_weapon_list(id, weapon_base_buffer)
  550.     }
  551.    
  552.     return HAM_IGNORED
  553. }
  554.  
  555. public Weapon_PrimaryAttack(weapon_entity)
  556. {
  557.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  558.    
  559.     if(!g_had_bak47p[Player])
  560.         return
  561.    
  562.     g_IsInPrimaryAttack = 1
  563.     pev(Player,pev_punchangle,cl_pushangle[Player])
  564.    
  565.     g_clip_ammo[Player] = cs_get_weapon_ammo(weapon_entity)
  566. }
  567.  
  568. public Weapon_PrimaryAttack_Post(weapon_entity)
  569. {
  570.     g_IsInPrimaryAttack = 0
  571.     new Player = get_pdata_cbase(weapon_entity, 41, 4)
  572.    
  573.     new szClip, szAmmo
  574.     get_user_weapon(Player, szClip, szAmmo)
  575.    
  576.     if(!is_user_alive(Player) || !ze_is_user_zombie(Player))
  577.         return
  578.        
  579.     if(g_had_bak47p[Player])
  580.     {
  581.         if(!g_clip_ammo[Player])
  582.         {
  583.             ExecuteHam(Ham_Weapon_PlayEmptySound, weapon_entity)
  584.             return
  585.         }
  586.        
  587.         new Float:push[3]
  588.         pev(Player,pev_punchangle,push)
  589.         xs_vec_sub(push,cl_pushangle[Player],push)
  590.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil),push)
  591.         xs_vec_add(push,cl_pushangle[Player],push)
  592.         set_pev(Player,pev_punchangle,push)
  593.        
  594.         set_weapon_shoot_anim(Player)
  595.         emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  596.         set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", Player+TASK_MUZZLEFLASH)
  597.     }
  598. }
  599.  
  600. public Weapon_ItemPostFrame(weapon_entity)
  601. {
  602.     new id = pev(weapon_entity, pev_owner)
  603.     if(!is_user_connected(id))
  604.         return HAM_IGNORED
  605.     if(!g_had_bak47p[id])
  606.         return HAM_IGNORED
  607.  
  608.     static iClipExtra
  609.     iClipExtra = get_pcvar_num(cvar_clip)
  610.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX)
  611.  
  612.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
  613.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  614.  
  615.     new fInReload = get_pdata_int(weapon_entity, m_fInReload, OFFSET_LINUX_WEAPONS)
  616.     if(fInReload && flNextAttack <= 0.0)
  617.     {
  618.         new j = min(iClipExtra - iClip, iBpAmmo)
  619.    
  620.         set_pdata_int(weapon_entity, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS)
  621.         cs_set_user_bpammo(id, CSW_BAK47P, iBpAmmo-j)
  622.        
  623.         set_pdata_int(weapon_entity, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
  624.         fInReload = 0
  625.     }
  626.     else if(!fInReload && !get_pdata_int(weapon_entity, 74, 4))
  627.     {
  628.         if(!iClip)
  629.             return HAM_IGNORED
  630.            
  631.         if(get_pdata_float(id, 83, 5) <= 0.0 && get_pdata_float(weapon_entity, 46, 4) <= 0.0 ||
  632.         get_pdata_float(weapon_entity, 47, 4) <= 0.0 || get_pdata_float(weapon_entity, 48, 4) <= 0.0)
  633.         {
  634.             if(pev(id, pev_button) & IN_ATTACK)
  635.             {
  636.                 if(g_Mode[id] == MODE_B)
  637.                     Shoot_Special(id)
  638.             }
  639.             else if(pev(id, pev_button) & IN_ATTACK2)
  640.             {
  641.                 set_buffak_zoom(id, 0)
  642.                 set_weapons_timeidle(id, CSW_BAK47P, 0.4)
  643.                 set_player_nextattackx(id, 0.4)
  644.             }
  645.         }
  646.     }
  647.    
  648.     return HAM_IGNORED
  649. }
  650.  
  651. public Weapon_Reload(weapon_entity)
  652. {
  653.     new id = pev(weapon_entity, pev_owner)
  654.     if(!is_user_connected(id))
  655.         return HAM_IGNORED
  656.     if(!g_had_bak47p[id])
  657.         return HAM_IGNORED
  658.     static iClipExtra
  659.     if(g_had_bak47p[id])
  660.         iClipExtra = get_pcvar_num(cvar_clip)
  661.  
  662.     g_weapon_TmpClip[id] = -1
  663.  
  664.     new iBpAmmo = cs_get_user_bpammo(id, CSW_BAK47P)
  665.     new iClip = get_pdata_int(weapon_entity, m_iClip, OFFSET_LINUX_WEAPONS)
  666.  
  667.     if(iBpAmmo <= 0)
  668.         return HAM_SUPERCEDE
  669.  
  670.     if(iClip >= iClipExtra)
  671.         return HAM_SUPERCEDE
  672.  
  673.     g_weapon_TmpClip[id] = iClip
  674.  
  675.     return HAM_IGNORED
  676. }
  677.  
  678. public Weapon_Reload_Post(weapon_entity)
  679. {
  680.     new id = pev(weapon_entity, pev_owner)
  681.     if (!is_user_connected(id))
  682.         return HAM_IGNORED
  683.  
  684.     if(!g_had_bak47p[id])
  685.         return HAM_IGNORED
  686.     if(g_weapon_TmpClip[id] == -1)
  687.         return HAM_IGNORED
  688.    
  689.     set_pdata_int(weapon_entity, m_iClip, g_weapon_TmpClip[id], OFFSET_LINUX_WEAPONS)
  690.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, RELOAD_TIME, OFFSET_LINUX_WEAPONS)
  691.     set_pdata_float(id, m_flNextAttack, RELOAD_TIME, OFFSET_LINUX)
  692.     set_pdata_int(weapon_entity, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
  693.    
  694.     set_weapon_anim(id, ANIM_RELOAD)
  695.     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  696.     set_buffak_zoom(id, 1)
  697.    
  698.     return HAM_IGNORED
  699. }
  700.  
  701. /* ===================== END OF ALL HAM FORWARD ====================== */
  702. /* ================= START OF OTHER PUBLIC FUNCTION  ================= */
  703. public get_bak47p(id)
  704. {
  705.     drop_weapons(id, 1)
  706.     new iWeapon = fm_give_item(id, weapon_base_buffer)
  707.     if(iWeapon > 0)
  708.     {
  709.         cs_set_weapon_ammo(iWeapon, get_pcvar_num(cvar_clip))
  710.         cs_set_user_bpammo(id, CSW_BAK47P, get_pcvar_num(cvar_ammo))
  711.         emit_sound(id, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM,0,PITCH_NORM)
  712.        
  713.         set_weapon_anim(id, ANIM_DRAW)
  714.         set_pdata_float(id, m_flNextAttack, DRAW_TIME, OFFSET_LINUX)
  715.        
  716.         set_weapon_list(id, weapon_name_buffer)
  717.         set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  718.         set_pdata_int(iWeapon, 74, MODE_A)
  719.     }
  720.    
  721.     g_had_bak47p[id] = true
  722.     g_Mode[id] = MODE_A
  723.     remove_bitvar(id)
  724. }
  725.  
  726. public remove_bak47p(id)
  727. {
  728.     g_had_bak47p[id] = false
  729.     g_Mode[id] = MODE_A
  730.     remove_bitvar(id)
  731. }
  732.  
  733. public remove_bitvar(id)
  734. {
  735.     g_attack_type[id] = 0
  736.     g_Muzzleflash[id][0] = 0
  737.     g_Muzzleflash[id][1] = 0
  738. }
  739.  
  740. public weapon_hook(id)
  741. {
  742.     engclient_cmd(id, weapon_base_buffer)
  743.     return PLUGIN_HANDLED
  744. }
  745.  
  746. public replace_weapon_models(id, weaponid)
  747. {
  748.     if(weaponid != CSW_BAK47P)
  749.     {
  750.         if(g_had_bak47p[id])
  751.         {
  752.             remove_bitvar(id)
  753.             set_buffak_zoom(id, 1)
  754.         }
  755.     }
  756.    
  757.     switch(weaponid)
  758.     {
  759.         case CSW_BAK47P:
  760.         {
  761.             if(g_had_bak47p[id])
  762.             {
  763.                 set_pev(id, pev_viewmodel2, V_MODEL)
  764.                 set_pev(id, pev_weaponmodel2, P_MODEL)
  765.                
  766.                 if(oldweap[id] != CSW_BAK47P)
  767.                 {
  768.                     set_weapon_anim(id, ANIM_DRAW)
  769.                     set_player_nextattackx(id, DRAW_TIME)
  770.                     set_weapons_timeidle(id, CSW_BAK47P, DRAW_TIME)
  771.                     set_weapon_list(id, weapon_name_buffer)
  772.                     set_pdata_string(id, (492) * 4, ANIMEXT, -1 , 20)
  773.                 }
  774.             }
  775.         }
  776.     }
  777.    
  778.     oldweap[id] = weaponid
  779. }
  780.  
  781. public Shoot_Special(id)
  782. {
  783.     if(!is_user_alive(id) || !is_user_connected(id))
  784.         return
  785.        
  786.     new szClip, szWeapId
  787.     szWeapId = get_user_weapon(id, szClip)
  788.     if(szWeapId != CSW_BAK47P || !g_had_bak47p[id] || !szClip)
  789.         return
  790.    
  791.     g_Muzzleflash[id][0] = 3
  792.     set_task(random_float(0.001, 0.005), "Re_MuzzleFlash", id+TASK_MUZZLEFLASH)
  793.    
  794.     static Float:PunchAngles[3]
  795.     PunchAngles[0] = -5.0
  796.     PunchAngles[1] = -2.5
  797.     PunchAngles[2] = -2.5
  798.     set_pev(id, pev_punchangle, PunchAngles)
  799.    
  800.     set_weapon_shoot_anim(id)
  801.     emit_sound(id, CHAN_WEAPON, Fire_Sounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  802.    
  803.     new Float:fStart[3], Float:originF[3]
  804.     new target, body
  805.    
  806.     fm_get_aim_origin(id, originF)
  807.     get_user_aiming(id, target, body)
  808.    
  809.     pev(id, pev_origin, fStart)
  810.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fStart, 0)
  811.     write_byte(TE_SPRITE)
  812.     engfunc(EngFunc_WriteCoord, originF[0])
  813.     engfunc(EngFunc_WriteCoord, originF[1])
  814.     engfunc(EngFunc_WriteCoord, originF[2] + 20.0)
  815.     write_short(sBuffakHit)
  816.     write_byte(10)
  817.     write_byte(240)
  818.     message_end()
  819.    
  820.     new a = FM_NULLENT
  821.     while((a = find_ent_in_sphere(a, originF, float(get_pcvar_num(cvar_radius)))) != 0)
  822.     {
  823.         if(id == a)
  824.             continue
  825.  
  826.         if (!ze_is_user_zombie(a) || !g_bCanDamage)
  827.             continue
  828.    
  829.         if(pev(a, pev_takedamage) != DAMAGE_NO)
  830.             ExecuteHamB(Ham_TakeDamage, a, 0, id, float(get_pcvar_num(cvar_dmg_2)), DMG_BULLET)
  831.     }
  832.    
  833.     if(!is_user_alive(target))
  834.     {
  835.         static Classname[32]
  836.         pev(target, pev_classname, Classname, sizeof(Classname))
  837.        
  838.         if(equal(Classname, "func_breakable"))
  839.             ExecuteHamB(Ham_TakeDamage, target, 0, 0, float(get_pcvar_num(cvar_dmg_2)), DMG_GENERIC)
  840.     }
  841.     else if(is_user_alive(target) && is_user_connected(target))
  842.     {
  843.         static Float:MyOrigin[3]
  844.         pev(id, pev_origin, MyOrigin)
  845.         hook_ent2(target, MyOrigin, 400.0, 2)
  846.         ExecuteHamB(Ham_TakeDamage, target, 0, id, float(get_pcvar_num(cvar_dmg_2))*0.75, DMG_BULLET)
  847.     }
  848.    
  849.     static entity_weapon
  850.     entity_weapon = find_ent_by_owner(ENG_NULLENT, weapon_base_buffer, id)
  851.    
  852.     if(!pev_valid(entity_weapon))
  853.         return
  854.    
  855.     cs_set_weapon_ammo(entity_weapon, szClip - 1)
  856.     set_player_nextattackx(id, 0.7)
  857.     set_weapons_timeidle(id, CSW_BAK47P, 0.7)
  858. }
  859.  
  860. public set_weapon_shoot_anim(id)
  861. {
  862.     if(!g_attack_type[id])
  863.     {
  864.         set_weapon_anim(id, ANIM_SHOOT1)
  865.         g_attack_type[id] = 1
  866.     }
  867.     else if(g_attack_type[id] == 1)
  868.     {
  869.         set_weapon_anim(id, ANIM_SHOOT2)
  870.         g_attack_type[id] = 2
  871.     }
  872.     else if(g_attack_type[id] == 2)
  873.     {
  874.         set_weapon_anim(id, ANIM_SHOOT3)
  875.         g_attack_type[id] = 0
  876.     }
  877. }
  878.  
  879. public Re_MuzzleFlash(id)
  880. {
  881.     id -= TASK_MUZZLEFLASH
  882.  
  883.     if(!is_user_alive(id) || !is_user_connected(id))
  884.         return
  885.     if(get_user_weapon(id) != CSW_BAK47P || !g_had_bak47p[id])
  886.         return
  887.    
  888.     if(g_Mode[id] == MODE_A) g_Muzzleflash[id][0] = true
  889.     else if(g_Mode[id] == MODE_B) g_Muzzleflash[id][1] = true
  890. }
  891.  
  892. /* ============= END OF OTHER PUBLIC FUNCTION (Weapon) ============= */
  893. /* ================= START OF ALL STOCK TO MACROS ================== */
  894. stock set_buffak_zoom(id, const reset = 0)
  895. {
  896.     if(reset == 1)
  897.     {
  898.         set_fov(id)
  899.         g_Mode[id] = MODE_A
  900.     }
  901.     else if(reset == 0)
  902.     {
  903.         if(g_Mode[id] == MODE_A)
  904.         {
  905.             set_fov(id, 80)
  906.             g_Mode[id] = MODE_B
  907.         }
  908.         else if(g_Mode[id] == MODE_B)
  909.         {
  910.             set_fov(id)
  911.             g_Mode[id] = MODE_A
  912.         }
  913.     }
  914. }
  915.  
  916. stock set_fov(id, fov = 90)
  917. {
  918.     message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id)
  919.     write_byte(fov)
  920.     message_end()
  921. }
  922.  
  923. stock set_weapon_list(id, const weapon_name[])
  924. {
  925.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
  926.     write_string(weapon_name)
  927.     write_byte(g_list_variables[2])
  928.     write_byte(g_list_variables[3])
  929.     write_byte(g_list_variables[4])
  930.     write_byte(g_list_variables[5])
  931.     write_byte(g_list_variables[6])
  932.     write_byte(g_list_variables[7])
  933.     write_byte(g_list_variables[8])
  934.     write_byte(g_list_variables[9])
  935.     message_end()
  936. }
  937.  
  938. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
  939. {
  940.     static Float:fl_Velocity[3]
  941.     static Float:EntOrigin[3]
  942.    
  943.     pev(ent, pev_origin, EntOrigin)
  944.     static Float:distance_f
  945.     distance_f = 100.0
  946.    
  947.     new Float:fl_Time = distance_f / speed
  948.     if(type == 1)
  949.     {
  950.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
  951.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
  952.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time      
  953.     }
  954.     else if(type == 2)
  955.     {
  956.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
  957.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
  958.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
  959.     }
  960.    
  961.     entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
  962. }
  963.  
  964. stock drop_weapons(id, dropwhat)
  965. {
  966.     static weapons[32], num = 0, i, weaponid
  967.     get_user_weapons(id, weapons, num)
  968.      
  969.     for (i = 0; i < num; i++)
  970.     {
  971.         weaponid = weapons[i]
  972.          
  973.         if(dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  974.         {
  975.             static wname[32]
  976.             get_weaponname(weaponid, wname, sizeof wname - 1)
  977.             engclient_cmd(id, "drop", wname)
  978.         }
  979.     }
  980. }
  981.  
  982. stock set_player_nextattackx(id, Float:nexttime)
  983. {
  984.     if(!is_user_alive(id))
  985.         return
  986.        
  987.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  988. }
  989.  
  990. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  991. {
  992.     if(!is_user_alive(id))
  993.         return
  994.        
  995.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  996.     if(!pev_valid(entwpn))
  997.         return
  998.        
  999.     set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
  1000.     set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
  1001.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, OFFSET_LINUX_WEAPONS)
  1002. }
  1003.  
  1004. stock set_weapons_timeidlex(id, Float:TimeIdle, Float:Idle)
  1005. {
  1006.     new entwpn = fm_get_user_weapon_entity(id, CSW_BASE)
  1007.     if(!pev_valid(entwpn))
  1008.         return
  1009.    
  1010.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  1011.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  1012.     set_pdata_float(entwpn, 48, Idle, 4)
  1013. }
  1014.  
  1015. stock set_weapon_anim(const Player, const Sequence)
  1016. {
  1017.     set_pev(Player, pev_weaponanim, Sequence)
  1018.    
  1019.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  1020.     write_byte(Sequence)
  1021.     write_byte(pev(Player, pev_body))
  1022.     message_end()
  1023. }
  1024.  
  1025. stock precache_viewmodel_sound(const model[]) // I Get This From BTE
  1026. {
  1027.     new file, i, k
  1028.     if((file = fopen(model, "rt")))
  1029.     {
  1030.         new szsoundpath[64], NumSeq, SeqID, Event, NumEvents, EventID
  1031.         fseek(file, 164, SEEK_SET)
  1032.         fread(file, NumSeq, BLOCK_INT)
  1033.         fread(file, SeqID, BLOCK_INT)
  1034.        
  1035.         for(i = 0; i < NumSeq; i++)
  1036.         {
  1037.             fseek(file, SeqID + 48 + 176 * i, SEEK_SET)
  1038.             fread(file, NumEvents, BLOCK_INT)
  1039.             fread(file, EventID, BLOCK_INT)
  1040.             fseek(file, EventID + 176 * i, SEEK_SET)
  1041.            
  1042.             // The Output Is All Sound To Precache In ViewModels (GREAT :V)
  1043.             for(k = 0; k < NumEvents; k++)
  1044.             {
  1045.                 fseek(file, EventID + 4 + 76 * k, SEEK_SET)
  1046.                 fread(file, Event, BLOCK_INT)
  1047.                 fseek(file, 4, SEEK_CUR)
  1048.                
  1049.                 if(Event != 5004)
  1050.                     continue
  1051.                
  1052.                 fread_blocks(file, szsoundpath, 64, BLOCK_CHAR)
  1053.                
  1054.                 if(strlen(szsoundpath))
  1055.                 {
  1056.                     strtolower(szsoundpath)
  1057.                     engfunc(EngFunc_PrecacheSound, szsoundpath)
  1058.                 }
  1059.             }
  1060.         }
  1061.     }
  1062.     fclose(file)
  1063. }
  1064.  
  1065. stock fm_cs_get_weapon_ent_owner(ent)
  1066. {
  1067.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  1068. }
  1069.  
  1070. /* ================= END OF ALL STOCK AND PLUGINS CREATED ================== */

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 439
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#8

Post by czirimbolo » 1 Month Ago

still nothing
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests