Resolved add native

Unpaid Requests, Public Plugins
Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

add native

#1

Post by Luxurious » 4 Months Ago

Pleas add native in this weapons to add in level

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_flTimeWeaponIdle			48
#define m_iClip					51
#define m_fInReload				54
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[33]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

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" }

public plugin_init()
{
	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
	
	g_itemid_watergun = ze_register_item("WaterGun", 40, 0)
	g_MaxPlayers = get_member_game(m_nMaxPlayers)
}

public plugin_precache()
{
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public ze_user_humanized(id)
{
	g_has_watergun[id] = false
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public client_connect(id)
{
	g_has_watergun[id] = false
}

public client_disconnected(id)
{
	g_has_watergun[id] = false

	remove_task(id + TASK_FBURN )
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id))
	{
		g_has_watergun[id] = false

		remove_task(id + TASK_FBURN)
	}
}

public fw_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, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public ze_select_item_pre(id, itemid)
{
	if (itemid != g_itemid_watergun)
		return ZE_ITEM_AVAILABLE

	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW

	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	if(itemid != g_itemid_watergun)
		return

	give_watergun(id)
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_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 fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			if (ze_is_user_zombie(id))
				return
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !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
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			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_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_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, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

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

stock UTIL_PlayWeaponAnimation(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()
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     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)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);


Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Item register */
    g_balrog = ze_register_item("Balrog Ethereal", 10, 0);
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "3.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_cost=register_cvar("dinfinity_cost", "15")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 163
Joined: 2 Years Ago
Has thanked: 15 times
Been thanked: 3 times
Age: 19
Contact:

#2

Post by sPe3doN » 4 Months Ago

balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}

Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#3

Post by Luxurious » 4 Months Ago

sPe3doN wrote:
4 Months Ago
balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}
Thx but where Watergun and dual ??

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 163
Joined: 2 Years Ago
Has thanked: 15 times
Been thanked: 3 times
Age: 19
Contact:

#4

Post by sPe3doN » 4 Months Ago

Luxurious wrote:
4 Months Ago
sPe3doN wrote:
4 Months Ago
balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}
Thx but where Watergun and dual ??
dual

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_cost=register_cvar("dinfinity_cost", "15")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_natives()
{
    register_native("give_dual_infinity", "native_give_dual_infinity", 1)
}
 
public native_give_dual_infinity(id)
{
    give_dual_infinity(id)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}
water gun

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_flTimeWeaponIdle			48
#define m_iClip					51
#define m_fInReload				54
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[33]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

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" }

public plugin_init()
{
	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
	
	g_itemid_watergun = ze_register_item("WaterGun", 40, 0)
	g_MaxPlayers = get_member_game(m_nMaxPlayers)
}

public plugin_precache()
{
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public plugin_natives()
{
    register_native("give_watergun", "native_give_watergun", 1)
}
 
public native_give_watergun(id)
{
    give_watergun(id)
}

public ze_user_humanized(id)
{
	g_has_watergun[id] = false
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public client_connect(id)
{
	g_has_watergun[id] = false
}

public client_disconnected(id)
{
	g_has_watergun[id] = false

	remove_task(id + TASK_FBURN )
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id))
	{
		g_has_watergun[id] = false

		remove_task(id + TASK_FBURN)
	}
}

public fw_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, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public ze_select_item_pre(id, itemid)
{
	if (itemid != g_itemid_watergun)
		return ZE_ITEM_AVAILABLE

	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW

	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	if(itemid != g_itemid_watergun)
		return

	give_watergun(id)
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_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 fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			if (ze_is_user_zombie(id))
				return
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !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
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			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_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_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, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

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

stock UTIL_PlayWeaponAnimation(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()
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     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)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);

Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#5

Post by Luxurious » 4 Months Ago

sPe3doN wrote:
4 Months Ago
Luxurious wrote:
4 Months Ago
sPe3doN wrote:
4 Months Ago
balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}
Thx but where Watergun and dual ??
dual

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_cost=register_cvar("dinfinity_cost", "15")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_natives()
{
    register_native("give_dual_infinity", "native_give_dual_infinity", 1)
}
 
public native_give_dual_infinity(id)
{
    give_dual_infinity(id)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}
water gun

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_flTimeWeaponIdle			48
#define m_iClip					51
#define m_fInReload				54
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[33]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

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" }

public plugin_init()
{
	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
	
	g_itemid_watergun = ze_register_item("WaterGun", 40, 0)
	g_MaxPlayers = get_member_game(m_nMaxPlayers)
}

public plugin_precache()
{
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public plugin_natives()
{
    register_native("give_watergun", "native_give_watergun", 1)
}
 
public native_give_watergun(id)
{
    give_watergun(id)
}

public ze_user_humanized(id)
{
	g_has_watergun[id] = false
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public client_connect(id)
{
	g_has_watergun[id] = false
}

public client_disconnected(id)
{
	g_has_watergun[id] = false

	remove_task(id + TASK_FBURN )
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id))
	{
		g_has_watergun[id] = false

		remove_task(id + TASK_FBURN)
	}
}

public fw_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, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public ze_select_item_pre(id, itemid)
{
	if (itemid != g_itemid_watergun)
		return ZE_ITEM_AVAILABLE

	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW

	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	if(itemid != g_itemid_watergun)
		return

	give_watergun(id)
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_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 fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			if (ze_is_user_zombie(id))
				return
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !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
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			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_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_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, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

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

stock UTIL_PlayWeaponAnimation(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()
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     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)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);
Thx So Much

Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#6

Post by Luxurious » 1 Month Ago

sPe3doN wrote:
4 Months Ago
Luxurious wrote:
4 Months Ago
sPe3doN wrote:
4 Months Ago
balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}
Thx but where Watergun and dual ??
dual

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_cost=register_cvar("dinfinity_cost", "15")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_natives()
{
    register_native("give_dual_infinity", "native_give_dual_infinity", 1)
}
 
public native_give_dual_infinity(id)
{
    give_dual_infinity(id)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}
water gun

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_flTimeWeaponIdle			48
#define m_iClip					51
#define m_fInReload				54
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[33]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

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" }

public plugin_init()
{
	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
	
	g_itemid_watergun = ze_register_item("WaterGun", 40, 0)
	g_MaxPlayers = get_member_game(m_nMaxPlayers)
}

public plugin_precache()
{
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public plugin_natives()
{
    register_native("give_watergun", "native_give_watergun", 1)
}
 
public native_give_watergun(id)
{
    give_watergun(id)
}

public ze_user_humanized(id)
{
	g_has_watergun[id] = false
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public client_connect(id)
{
	g_has_watergun[id] = false
}

public client_disconnected(id)
{
	g_has_watergun[id] = false

	remove_task(id + TASK_FBURN )
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id))
	{
		g_has_watergun[id] = false

		remove_task(id + TASK_FBURN)
	}
}

public fw_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, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public ze_select_item_pre(id, itemid)
{
	if (itemid != g_itemid_watergun)
		return ZE_ITEM_AVAILABLE

	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW

	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	if(itemid != g_itemid_watergun)
		return

	give_watergun(id)
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_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 fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			if (ze_is_user_zombie(id))
				return
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !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
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			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_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_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, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

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

stock UTIL_PlayWeaponAnimation(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()
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     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)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);

Code: Select all

//// ze_dual.sma
//
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v1.8.3\scripting\ze_dual.sma(133) : error 017: undefined symbol "give_dual_infinity"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v1.8.3\scripting\ze_dual.sma(78) : warning 204: symbol is assigned a value that is never used: "pcvar_cost"
//
// 1 Error.
// Could not locate output file D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v1.8.3\scripting\compiled\ze_dual.amx (compile failed).
//
// Compilation Time: 5.2 sec
Dual Have This Problem.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 163
Joined: 2 Years Ago
Has thanked: 15 times
Been thanked: 3 times
Age: 19
Contact:

#7

Post by sPe3doN » 1 Month Ago

fixed:

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public plugin_natives()
{
    register_native("give_infinity", "native_give_infinity", 1)
}
 
public native_give_infinity(id)
{
    give_infinity(id)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*?²ï¢» ?¦­é³¼ î?£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}

Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#8

Post by Luxurious » 1 Month Ago

sPe3doN wrote:
4 Months Ago
Luxurious wrote:
4 Months Ago
sPe3doN wrote:
4 Months Ago
balrog

Code: Select all

/*================================================================================
 
            --------------------------------
            [ZE] Extra Item: Balrog Ethereal
            --------------------------------
 
        Balrog Ethereal
        Copyright (C) 2017 by Crazy + ZE DEV TEAM
 
        -------------------
        -*- Description -*-
        -------------------
 
        This plugin add a new weapon into your zombie plague mod with
        the name of Balrog Ethereal. That weapon launch a powerfull beams!
        When the laser hit any object, a explosion effect with red color appers.
 
        ----------------
        -*- Commands -*-
        ----------------
 
        * zp_give_balrog_ethereal <target> - Give the item to target.
 
        -------------
        -*- Cvars -*-
        -------------
 
        * ze_balrog_ethereal_ammo <number> - Ammo amout.
        * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
        * ze_balrog_ethereal_one_round <0/1> - Only one round.
        * ze_balrog_ethereal_damage <number> - Damage multiplier.
        * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
 
        ------------------
        -*- Change Log -*-
        ------------------
 
        * v1.5: (Mar 2017)
            - Updated all the code, added explosion effect, added new cvars;
 
        * v1.6: (Mar 2017)
            - Added custom weapon hud;
 
        ---------------
        -*- Credits -*-
        ---------------
 
        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.
        * ZE DEV TEAM : For converting this Item
 
 
=================================================================================*/
#include <zombie_escape>
#include <cstrike>
#include <engine>
 
/*================================================================================
 [Plugin Customization]
=================================================================================*/
 
// Item Name
#define ITEM_NAME "Balrog Ethereal"
 
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
new const PLUGIN_VERSION[] = "v1.6";
 
new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
 
new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
 
new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_balrog, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
 
const BALROG_KEY = 0982478;
 
const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;
 
const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;
 
const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
 
enum
{
    idle = 0,
    reload,
    draw,
    shoot1,
    shoot2,
    shoot3
}
 
public plugin_natives()
{
    register_native("give_balrog", "native_give_balrog", 1)
}
 
public plugin_init()
{
    /* Plugin register */
    register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
 
    /* Events */
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
 
    /* Messages */
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
 
    /* Forwards */
    register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    register_forward(FM_SetModel, "fw_SetModel");
    register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
 
    /* Ham Forwards */
    RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
 
    /* Cvars */
    cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
 
    /* Max Players */
    g_maxplayers = get_maxplayers()
}
 
public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
 
    engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
 
    for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
 
    g_laser_sprite = precache_model("sprites/laserbeam.spr");
    g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
 
    register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    register_clcmd("weapon_bethereal", "cmd_balrog_selected");
}
 
public ze_user_infected(id)
{
    g_has_balrog[id] = false;
}
 
public ze_user_humanized(id)
{
    g_has_balrog[id] = false;
}
 
public client_putinserver(id)
{
    g_has_balrog[id] = false;
 
    get_user_name(id, g_playername[id], charsmax(g_playername[]));
}
 
public event_round_start()
{
    for (new id = 0; id <= g_maxplayers; id++)
    {
        if (get_pcvar_num(cvar_balrog_oneround))
        g_has_balrog[id] = false;
    }
}
 
public cmd_balrog_selected(client)
{
    engclient_cmd(client, "weapon_ump45");
    return PLUGIN_HANDLED;
}
 
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!is_user_alive(msg_entity))
        return;
 
    if (!g_has_balrog[msg_entity])
        return;
 
    if (get_user_weapon(msg_entity) != CSW_UMP45)
        return;
 
    if (get_msg_arg_int(1) != 1)
        return;
 
    if (get_pcvar_num(cvar_balrog_unlimited))
    {
        static ent;
        ent = fm_cs_get_current_weapon_ent(msg_entity);
 
        if (!pev_valid(ent))
            return;
 
        cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
        set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    }
}
 
public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_balrog)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_balrog)
        return;
 
    if (g_has_balrog[id])
    {
        client_print(id, print_chat, "[ZE] You already have the %s.", ITEM_NAME);
        return;
    }
 
    give_balrog(id);
 
    client_print(id, print_chat, "[ZE] You bought the %s.", ITEM_NAME);
}
 
public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
 
    if (!g_has_balrog[id])
        return FMRES_IGNORED;
 
    if (get_user_weapon(id) != CSW_UMP45)
        return FMRES_IGNORED;
 
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
 
    return FMRES_IGNORED;
}
 
public fw_SetModel(ent, const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED;
 
    if (!equal(model, "models/w_ump45.mdl"))
        return HAM_IGNORED;
 
    static class_name[33];
    pev(ent, pev_classname, class_name, charsmax(class_name));
 
    if (!equal(class_name, "weaponbox"))
        return FMRES_IGNORED;
 
    static owner, weapon;
    owner = pev(ent, pev_owner);
    weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
 
    if (!g_has_balrog[owner] || !pev_valid(weapon))
        return FMRES_IGNORED;
 
    g_has_balrog[owner] = false;
 
    set_pev(weapon, pev_impulse, BALROG_KEY);
 
    engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
 
    return FMRES_SUPERCEDE;
}
 
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event_balrog) || !g_primary_attack)
        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;
}
 
public fw_PrecacheEvent_Post(type, const name[])
{
    if (!equal("events/ump45.sc", name))
        return HAM_IGNORED;
 
    g_event_balrog = get_orig_retval()
 
    return FMRES_HANDLED;
}
 
public fw_Item_Deploy_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
 
    play_weapon_anim(id, draw);
 
    return HAM_IGNORED;
}
 
public fw_Item_AddToPlayer_Post(ent, id)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (pev(ent, pev_impulse) == BALROG_KEY)
    {
        g_has_balrog[id] = true;
        set_pev(ent, pev_impulse, 0);
    }
 
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    write_byte(6)
    write_byte(100)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(15)
    write_byte(CSW_UMP45)
    write_byte(0)
    message_end()
 
    return HAM_IGNORED;
}
 
public fw_Item_PostFrame(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
 
    if (fInReload && flNextAttack <= 0.0)
    {
        new temp_clip = min(cvar_clip - clip, bpammo);
 
        set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
 
        cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
 
        set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
 
        fInReload = 0;
    }
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = true;
 
    return HAM_IGNORED;
}
 
public fw_PrimaryAttack_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (!cs_get_weapon_ammo(ent))
        return HAM_IGNORED;
 
    g_primary_attack = false;
 
    play_weapon_anim(id, random_num(shoot1, shoot3));
 
    emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
 
    make_laser_beam(id, 7, 100, 0, 0);
 
    return HAM_IGNORED;
}
 
public fw_Reload(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    static cvar_clip;
 
    if (g_has_balrog[id])
        cvar_clip = get_pcvar_num(cvar_balrog_clip);
 
    g_balrog_reload_clip[id] = -1;
 
    new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
 
    if (bpammo <= 0)
        return HAM_SUPERCEDE;
 
    if (clip >= cvar_clip)
        return HAM_SUPERCEDE;
   
    g_balrog_reload_clip[id] = clip;
 
    return HAM_IGNORED;
}
 
public fw_Reload_Post(ent)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;
 
    new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
 
    if (!is_user_alive(id))
        return HAM_IGNORED;
 
    if (!g_has_balrog[id])
        return HAM_IGNORED;
 
    if (g_balrog_reload_clip[id] == -1)
        return HAM_IGNORED;
 
    set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
 
    play_weapon_anim(id, reload);
 
    return HAM_IGNORED;
}
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
    if (!is_user_alive(attacker))
        return HAM_IGNORED;
 
    if (get_user_weapon(attacker) != CSW_UMP45)
        return HAM_IGNORED;
 
    if (!g_has_balrog[attacker])
        return HAM_IGNORED;
 
    make_explosion_effect(attacker);
 
    return HAM_IGNORED;
}
 
give_balrog(id)
{
    drop_primary(id);
 
    g_has_balrog[id] = true;
 
    new weapon = fm_give_item(id, "weapon_ump45");
 
    cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
}
 
play_weapon_anim(id, frame)
{
    set_pev(id, pev_weaponanim, frame);
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    write_byte(frame)
    write_byte(pev(id, pev_body))
    message_end()
}
 
make_laser_beam(id, Size, R, G, B)
{
    static End[3];
    get_user_origin(id, End, 3);
   
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte (TE_BEAMENTPOINT)
    write_short( id |0x1000 )
    write_coord(End[0])
    write_coord(End[1])
    write_coord(End[2])
    write_short(g_laser_sprite)
    write_byte(0)
    write_byte(1)
    write_byte(1)
    write_byte(Size)
    write_byte(4)
    write_byte(R)
    write_byte(G)
    write_byte(B)
    write_byte(255)
    write_byte(0)
    message_end()
}
 
make_explosion_effect(id)
{
    static end[3];
    get_user_origin(id, end, 3);
 
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(end[0])
    write_coord(end[1])
    write_coord(end[2])
    write_short(g_balrog_exp)
    write_byte(10)
    write_byte(15)
    write_byte(4)
    message_end()
}
 
drop_primary(id)
{
    static weapons[32], num;
    get_user_weapons(id, weapons, num);
 
    for (new i = 0; i < num; i++)
    {
        if (WEAPON_BITSUM & (1<<weapons[i]))
        {
            static wname[32];
            get_weaponname(weapons[i], wname, sizeof wname - 1);
 
            engclient_cmd(id, "drop", wname);
        }
    }
}
 
stock fm_give_item(index, const item[])
{
    if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
        return 0;
 
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    if (!pev_valid(ent))
        return 0;
 
    new Float:origin[3];
    pev(index, pev_origin, origin);
    set_pev(ent, pev_origin, origin);
    set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    dllfunc(DLLFunc_Spawn, ent);
 
    new save = pev(ent, pev_solid);
    dllfunc(DLLFunc_Touch, ent, index);
    if (pev(ent, pev_solid) != save)
        return ent;
 
    engfunc(EngFunc_RemoveEntity, ent);
 
    return -1;
}
 
stock fm_cs_get_current_weapon_ent(id)
{
    if (pev_valid(id) != 2)
        return -1;
   
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
 
public native_give_balrog(id)
{
    if ((get_user_flags(id) & ADMIN_LEVEL_H))
    {
        give_balrog(id);
    }
}
Thx but where Watergun and dual ??
dual

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fakemeta_util>


#define PLUGIN "[ZE] Extra : DualInfinity"
#define VERSION "1.0"
#define AUTHOR "SexY Devil CJ"

#define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"

#define OFFSET_LINUX_WEAPONS 4 
#define OFFSET_LINUX 5

#define m_flNextAttack	83
#define m_flNextPrimaryAttack 	46
#define m_flTimeWeaponIdle	48
#define m_fInReload		54

#define pev_weaponkey pev_impulse
#define weaponkey_value 18318

#define CSW_INFINITY CSW_ELITE

new const g_weapon_entity[]="weapon_elite"
new const g_weapon_event1[]="events/elite_right.sc"
new const g_weapon_event2[]="events/elite_left.sc"
new const g_weapon_weaponbox_model[]="models/w_elite.mdl"

new const weapon_list_txt[]="weapon_dual_infinity2"

new const weapon_list_sprites[][]=
{	
	"sprites/zp/640hud42.spr",
	"sprites/zp/640hud43.spr",
	"sprites/zp/640hud7.spr"
}

new const ViewModel[]="models/zp/v_infinityex2.mdl"
new const PlayerModel[]="models/zp/p_infinity.mdl"
new const WorldModel[]="models/zp/w_infinity.mdl"

new const Sounds[][]=
{
	"weapons/infi-1.wav",
	"weapons/infi_clipin.wav",
	"weapons/infi_clipon.wav",
	"weapons/infi_clipout.wav",
	"weapons/infi_draw.wav"
}

new Blood[2]

new g_orig_event_dinfinity

new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
new g_mode[33], g_anim_mode[33]

new g_itemid

new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast

new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs

new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast

const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) 

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd(weapon_list_txt, "Redirect")
	
	pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
	pcvar_cost=register_cvar("dinfinity_cost", "15")
	pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
	pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
	pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
	pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
	
	pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
	pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
	pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
	pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
	pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
	
	pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
	pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
	pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
	pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
	pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")	
	
	ReadSettings()
	
	RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
	RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
	RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
	RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
	RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
	RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
	
	RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)	
	
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
	register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
	register_forward(FM_CmdStart,  "fwCmdStart")
	register_forward(FM_SetModel, "fwSetModel")
	
	new item_name[64]
	
	get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
	
	g_itemid = ze_register_item("Dual Infinity", 15, 0)
}

public plugin_natives()
{
    register_native("give_dual_infinity", "native_give_dual_infinity", 1)
}
 
public native_give_dual_infinity(id)
{
    give_dual_infinity(id)
}

public plugin_precache()
{
	precache_model(ViewModel)
	precache_model(PlayerModel)
	precache_model(WorldModel)
	
	for(new i; i<=charsmax(Sounds); i++)
	{
		precache_sound(Sounds[i])
	}
	
	Blood[0] = precache_model("sprites/bloodspray.spr")
	Blood[1] = precache_model("sprites/blood.spr")	
	
	new tmp[128]
	
	formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
	
	precache_generic(tmp)
	
	for(new i; i<=charsmax(weapon_list_sprites); i++)
	{
		precache_generic(weapon_list_sprites[i])
		
	}
	
	register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
}

public ReadSettings()
{
	new confdir[64], path[128]
	
	get_configsdir(confdir, charsmax(confdir))
	
	formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
	
	server_cmd("exec %s", path)
	server_exec()
	
	cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
	cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
	
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}


public Redirect(id)
{	
	client_cmd(id, g_weapon_entity)	
}

public ze_select_item_post(id,  itemid)
{
	if(itemid!=g_itemid)
		return
	
	give_infinity(id)	
}

public client_disconnected(id)
{
	g_HasInfinity[id]=false	
}

public ze_user_infected(id, iInfector)
{	
	g_HasInfinity[id]=false
}

public give_infinity(id)
{
	drop_weapons(id, 2)
	
	g_HasInfinity[id]=true
	
	new ent=fm_give_item(id, g_weapon_entity)
	
	cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
	cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))

	
	InfinitySprite(id)	
}

public fwPrecachePost(type, const name[])
{
	if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
	{
		g_orig_event_dinfinity=get_orig_retval()
		
		return FMRES_HANDLED
	}
	
	return FMRES_IGNORED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_dinfinity))
		return FMRES_IGNORED
	
	if (!is_valid_player(invoker))
		return FMRES_IGNORED
	
	fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
{
	if (!is_valid_player(id))
		return FMRES_IGNORED
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return FMRES_IGNORED
	
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fwCmdStart(id, uc_handle, seed)
{
	if(!is_valid_player(id))
		return
	
	if(get_user_weapon(id)!=CSW_INFINITY)
		return
		
	static buttons; buttons=get_uc(uc_handle, UC_Buttons)
	
	if(!(buttons&IN_ATTACK2))
	{
		g_mode[id]=0
		
		return
	}	
	
	static ent; ent=get_pdata_cbase(id, 373)	
	
	if((buttons&IN_ATTACK))	/*Fix*/
	{
		set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
		
		g_mode[id]=0
			
		return	
	}	
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
		return		
	
	g_mode[id]=1
			
	if(cs_get_weapon_ammo(ent)!=0)
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
}

public fwSetModel(ent, model[])
{
	if(!pev_valid(ent))
		return FMRES_IGNORED;

	if(!equal(model, g_weapon_weaponbox_model)) 
		return FMRES_IGNORED;

	static classname[33]
	pev(ent, pev_classname, classname, charsmax(classname))
		
	if(!equal(classname, "weaponbox"))
		return FMRES_IGNORED

	static owner; owner=pev(ent, pev_owner)
	static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
	
	if(g_HasInfinity[owner]&&pev_valid(weap))
	{
		set_pev(weap, pev_weaponkey, weaponkey_value)
		
		g_HasInfinity[owner]=false
		
		fm_entity_set_model(ent, WorldModel)
		
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fwAddToPlayer(ent, id)
{
	if(pev_valid(ent))
	{
		if(pev(ent, pev_weaponkey)==weaponkey_value)
		{
			g_HasInfinity[id] = true
		
			set_pev(ent, pev_weaponkey, 0)
		
			InfinitySprite(id)
		
			return HAM_HANDLED
			
		}
	}
		
	return HAM_IGNORED
}

public fwDeployPost(ent)
{
	new id=fm_get_weapon_owner(ent)

	if (!is_valid_player(id))
		return
	
	set_pev(id, pev_viewmodel2, ViewModel)
	set_pev(id, pev_weaponmodel2, PlayerModel)

	playanim(id, 15)

	set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)

	g_anim_mode[id]=!g_anim_mode[id]
}
	
public fwPrimaryAttack(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if (!is_valid_player(id))
		return
	
	pev(id,pev_punchangle,cl_pushangle[id])
	
	g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
}

public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
{
	if(!is_valid_player(attacker))
		return 

	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return 
			
	static Float:fEnd[3]
	
	get_tr2(ptr, TR_vecEndPos, fEnd)
	
	make_bullet_decals(attacker, fEnd)
	
	g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
}

public fwReloadPre(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return HAM_IGNORED

	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
	{
		set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
		
		set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
		set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
		set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
		
		set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)

		playanim(id, 14)
	}
	
	return HAM_SUPERCEDE
}

public fwItemPostFrame(ent)
{
	new id=fm_get_weapon_owner(ent)
	
	if(!is_valid_player(id))
		return
	
	static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
	static clip; clip=cs_get_weapon_ammo(ent)
	
	if(clip<g_player_weapon_ammo[id])
	{
		g_player_weapon_ammo[id]=clip
	
		new Float:push[3]
	
		pev(id,pev_punchangle,push)
		
		xs_vec_sub(push,cl_pushangle[id],push)
		xs_vec_mul_scalar(push,0.8,push)
		xs_vec_add(push,cl_pushangle[id],push)
	
		if(g_mode[id]==0)
		{
			if(g_shoot_anim[id]==0)
			{

				playanim(id, 2)
			}
			else
			{
				playanim(id, 12)	
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
		}
		else
		{
			if(g_shoot_anim[id]==0)
			{
				playanim(id, (g_anim_mode[id])?18:16)
				
				push[0]+=1.0
				push[1]-=1.5
			}
			else
			{
				playanim(id, (g_anim_mode[id])?19:17)
				
				push[0]+=1.0
				push[1]+=1.5
			}
			
			set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
		}
		
		g_shoot_anim[id]=!g_shoot_anim[id]		
				
		set_pev(id,pev_punchangle,push)	
		
		emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
	
	if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
	{
		
		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
		
		for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
		{
			if(bpammo==0)
				break
			bpammo--
			clip++
		}	
		
		cs_set_weapon_ammo(ent, clip)
		cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
		
	}
}

public fwDamagePre(id, weapon, attacker, Float:damage)
{
	
	if(!is_valid_player(attacker))
		return
	
	if(get_user_weapon(attacker)!=CSW_INFINITY)
		return
	
	new Float:Damage
	
	switch(g_hitgroup[attacker])
	{
		
		case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
		
		case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
		
		case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
		
		case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
		
		case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
		
	}
	
	SetHamParamFloat(4, Damage)
}

public fwRemoveItem(id, ent)
{
	if(!is_valid_player(id))
		return
		
	new classname[62]
	
	pev(ent, pev_classname, classname, 61)
	
	if(!equal(classname, g_weapon_entity))
		return
	
	DefaultSprite(id)
		
}

public make_bullet_decals(id, Float:Origin[3])
{
	new target, body
	get_user_aiming(id, target, body, 999999)
	
	if(is_user_alive(target))
	{
		if(ze_is_user_zombie(id))
		{
			new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
			pev(id, pev_origin, fStart)
			
			velocity_by_aim(id, 64, fVel)
			
			fStart[0] = Origin[0]
			fStart[1] = Origin[1]
			fStart[2] = Origin[2]
			fEnd[0] = fStart[0]+fVel[0]
			fEnd[1] = fStart[1]+fVel[1]
			fEnd[2] = fStart[2]+fVel[2]
	
			new res
			engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
			get_tr2(res, TR_vecEndPos, fRes)
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
			write_byte(TE_BLOODSPRITE)
			write_coord(floatround(fStart[0])) 
			write_coord(floatround(fStart[1])) 
			write_coord(floatround(fStart[2])) 
			write_short(Blood[0])
			write_short(Blood[1])
			write_byte(70)
			write_byte(random_num(1,2))
			message_end()
		}
	} 
		
	else 
	{
		new decal = 41

		if(target)
		{
			
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			write_short(target)
			message_end()
		}
		else 
		{	
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(floatround(Origin[0]))
			write_coord(floatround(Origin[1]))
			write_coord(floatround(Origin[2]))
			write_byte(decal)
			message_end()
		}
		
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(floatround(Origin[0]))
		write_coord(floatround(Origin[1]))
		write_coord(floatround(Origin[2]))
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public InfinitySprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(weapon_list_txt) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public DefaultSprite(id)
{
	message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
	write_string(g_weapon_entity) 
	write_byte(10)
	write_byte(120)
	write_byte(-1)
	write_byte(-1)
	write_byte(1)
	write_byte(1)
	write_byte(CSW_INFINITY)
	write_byte(0)
	message_end()
}

public is_valid_player(id)
{
		
	if(!is_user_alive(id))
		return false
		
	if(!g_HasInfinity[id])
		return false

	return true	
}

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

stock playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}

stock fm_get_weapon_owner(weapon)
{	
	return get_pdata_cbase(weapon, 41, 4)
	
}
water gun

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_flTimeWeaponIdle			48
#define m_iClip					51
#define m_fInReload				54
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[33]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

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" }

public plugin_init()
{
	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
	
	g_itemid_watergun = ze_register_item("WaterGun", 40, 0)
	g_MaxPlayers = get_member_game(m_nMaxPlayers)
}

public plugin_precache()
{
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public plugin_natives()
{
    register_native("give_watergun", "native_give_watergun", 1)
}
 
public native_give_watergun(id)
{
    give_watergun(id)
}

public ze_user_humanized(id)
{
	g_has_watergun[id] = false
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public client_connect(id)
{
	g_has_watergun[id] = false
}

public client_disconnected(id)
{
	g_has_watergun[id] = false

	remove_task(id + TASK_FBURN )
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id))
	{
		g_has_watergun[id] = false

		remove_task(id + TASK_FBURN)
	}
}

public fw_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, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public ze_select_item_pre(id, itemid)
{
	if (itemid != g_itemid_watergun)
		return ZE_ITEM_AVAILABLE

	if (ze_is_user_zombie(id))
		return ZE_ITEM_DONT_SHOW

	return ZE_ITEM_AVAILABLE
}

public ze_select_item_post(id, itemid)
{
	if(itemid != g_itemid_watergun)
		return

	give_watergun(id)
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_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 fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			if (ze_is_user_zombie(id))
				return
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !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
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			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_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_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, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

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

stock UTIL_PlayWeaponAnimation(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()
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     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)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);

all is worked but is already in extra-items and natives not work

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1764
Joined: 2 Years Ago
Location: Egypt
Has thanked: 30 times
Been thanked: 87 times
Age: 21
Contact:

#9

Post by Raheem » 1 Month Ago

1. Barlog:
    1. /*================================================================================
    2.  
    3.             --------------------------------
    4.             [ZE] Extra Item: Balrog Ethereal
    5.             --------------------------------
    6.  
    7.         Balrog Ethereal
    8.         Copyright (C) 2017 by Crazy + ZE DEV TEAM
    9.  
    10.         -------------------
    11.         -*- Description -*-
    12.         -------------------
    13.  
    14.         This plugin add a new weapon into your zombie plague mod with
    15.         the name of Balrog Ethereal. That weapon launch a powerfull beams!
    16.         When the laser hit any object, a explosion effect with red color appers.
    17.  
    18.         ----------------
    19.         -*- Commands -*-
    20.         ----------------
    21.  
    22.         * zp_give_balrog_ethereal <target> - Give the item to target.
    23.  
    24.         -------------
    25.         -*- Cvars -*-
    26.         -------------
    27.  
    28.         * ze_balrog_ethereal_ammo <number> - Ammo amout.
    29.         * ze_balrog_ethereal_clip <number> - Clip amout. (Max: 100)
    30.         * ze_balrog_ethereal_one_round <0/1> - Only one round.
    31.         * ze_balrog_ethereal_damage <number> - Damage multiplier.
    32.         * ze_balrog_ethereal_unlimited <0/1> - Unlimited ammunition.
    33.  
    34.         ------------------
    35.         -*- Change Log -*-
    36.         ------------------
    37.  
    38.         * v1.5: (Mar 2017)
    39.             - Updated all the code, added explosion effect, added new cvars;
    40.  
    41.         * v1.6: (Mar 2017)
    42.             - Added custom weapon hud;
    43.  
    44.         ---------------
    45.         -*- Credits -*-
    46.         ---------------
    47.  
    48.         * MeRcyLeZZ: for the nice zombie plague mod.
    49.         * Crazy: created the extra item code.
    50.         * deanamx: for the nice weapon model.
    51.         * And all zombie-mod players that use this weapon.
    52.         * ZE DEV TEAM : For converting this Item
    53.  
    54.  
    55. =================================================================================*/
    56. #include <zombie_escape>
    57. #include <cstrike>
    58. #include <engine>
    59.  
    60. /*================================================================================
    61.  [Plugin Customization]
    62. =================================================================================*/
    63.  
    64.  
    65. /*================================================================================
    66.  Customization ends here! Yes, that's it. Editing anything beyond
    67.  here is not officially supported. Proceed at your own risk...
    68. =================================================================================*/
    69.  
    70. new const PLUGIN_VERSION[] = "v1.6";
    71.  
    72. new const V_BALROG_MDL[64] = "models/zombie_escape/v_balrog_ethereal.mdl";
    73. new const P_BALROG_MDL[64] = "models/zombie_escape/p_balrog_ethereal.mdl";
    74. new const W_BALROG_MDL[64] = "models/zombie_escape/w_balrog_ethereal.mdl";
    75.  
    76. new const BALROG_SOUNDS[][] = { "weapons/ethereal_shoot.wav", "weapons/ethereal_reload.wav", "weapons/ethereal_idle1.wav", "weapons/ethereal_draw.wav" };
    77.  
    78. new g_has_balrog[33], g_laser_sprite, g_balrog_exp, g_event_balrog, g_playername[33][32], g_maxplayers, g_primary_attack, g_balrog_reload_clip[33], cvar_balrog_clip, cvar_balrog_ammo, cvar_balrog_damage, cvar_balrog_oneround, cvar_balrog_unlimited;
    79.  
    80. const BALROG_KEY = 0982478;
    81.  
    82. const m_iClip = 51;
    83. const m_flNextAttack = 83;
    84. const m_fInReload = 54;
    85.  
    86. const OFFSET_WEAPON_OWNER = 41;
    87. const OFFSET_LINUX_WEAPONS = 4;
    88. const OFFSET_LINUX = 5;
    89. const OFFSET_ACTIVE_ITEM = 373;
    90.  
    91. const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));
    92.  
    93. enum
    94. {
    95.     idle = 0,
    96.     reload,
    97.     draw,
    98.     shoot1,
    99.     shoot2,
    100.     shoot3
    101. }
    102.  
    103. public plugin_natives()
    104. {
    105.     register_native("give_balrog", "native_give_balrog", 1)
    106. }
    107.  
    108. public plugin_init()
    109. {
    110.     /* Plugin register */
    111.     register_plugin("[ZE] Extra Item: Balrog Ethereal", PLUGIN_VERSION, "Crazy");
    112.  
    113.     /* Events */
    114.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
    115.  
    116.     /* Messages */
    117.     register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
    118.  
    119.     /* Forwards */
    120.     register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
    121.     register_forward(FM_SetModel, "fw_SetModel");
    122.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
    123.  
    124.     /* Ham Forwards */
    125.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
    126.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
    127.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
    128.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
    129.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
    130.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
    131.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
    132.     RegisterHam(Ham_Item_Deploy, "weapon_ump45", "fw_Item_Deploy_Post", 1);
    133.     RegisterHam(Ham_Item_AddToPlayer, "weapon_ump45", "fw_Item_AddToPlayer_Post", 1);
    134.     RegisterHam(Ham_Item_PostFrame, "weapon_ump45", "fw_Item_PostFrame");
    135.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack");
    136.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ump45", "fw_PrimaryAttack_Post", 1);
    137.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload");
    138.     RegisterHam(Ham_Weapon_Reload, "weapon_ump45", "fw_Reload_Post", 1);
    139.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
    140.  
    141.     /* Cvars */
    142.     cvar_balrog_clip = register_cvar("ze_balrog_minigun_clip", "50");
    143.     cvar_balrog_ammo = register_cvar("ze_balrog_minigun_ammo", "200");
    144.     cvar_balrog_damage = register_cvar("ze_balrog_minigun_damage", "2.0");
    145.     cvar_balrog_oneround = register_cvar("ze_balrog_minigun_one_round", "0");
    146.     cvar_balrog_unlimited = register_cvar("ze_balrog_minigun_unlimited", "0");
    147.  
    148.     /* Max Players */
    149.     g_maxplayers = get_maxplayers()
    150. }
    151.  
    152. public plugin_precache()
    153. {
    154.     engfunc(EngFunc_PrecacheModel, V_BALROG_MDL);
    155.     engfunc(EngFunc_PrecacheModel, P_BALROG_MDL);
    156.     engfunc(EngFunc_PrecacheModel, W_BALROG_MDL);
    157.  
    158.     engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_bethereal.txt");
    159.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud2_bethereal.spr");
    160.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud10_bethereal.spr");
    161.     engfunc(EngFunc_PrecacheGeneric, "sprites/640hud74_bethereal.spr");
    162.  
    163.     for (new i = 0; i < sizeof BALROG_SOUNDS; i++)
    164.     engfunc(EngFunc_PrecacheSound, BALROG_SOUNDS[i]);
    165.  
    166.     g_laser_sprite = precache_model("sprites/laserbeam.spr");
    167.     g_balrog_exp = precache_model("sprites/zombie_plague/balrog_ethereal_exp.spr");
    168.  
    169.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
    170.     register_clcmd("weapon_bethereal", "cmd_balrog_selected");
    171. }
    172.  
    173. public ze_user_infected(id)
    174. {
    175.     g_has_balrog[id] = false;
    176. }
    177.  
    178. public ze_user_humanized(id)
    179. {
    180.     g_has_balrog[id] = false;
    181. }
    182.  
    183. public client_putinserver(id)
    184. {
    185.     g_has_balrog[id] = false;
    186.  
    187.     get_user_name(id, g_playername[id], charsmax(g_playername[]));
    188. }
    189.  
    190. public event_round_start()
    191. {
    192.     for (new id = 0; id <= g_maxplayers; id++)
    193.     {
    194.         if (get_pcvar_num(cvar_balrog_oneround))
    195.         g_has_balrog[id] = false;
    196.     }
    197. }
    198.  
    199. public cmd_balrog_selected(client)
    200. {
    201.     engclient_cmd(client, "weapon_ump45");
    202.     return PLUGIN_HANDLED;
    203. }
    204.  
    205. public message_cur_weapon(msg_id, msg_dest, msg_entity)
    206. {
    207.     if (!is_user_alive(msg_entity))
    208.         return;
    209.  
    210.     if (!g_has_balrog[msg_entity])
    211.         return;
    212.  
    213.     if (get_user_weapon(msg_entity) != CSW_UMP45)
    214.         return;
    215.  
    216.     if (get_msg_arg_int(1) != 1)
    217.         return;
    218.  
    219.     if (get_pcvar_num(cvar_balrog_unlimited))
    220.     {
    221.         static ent;
    222.         ent = fm_cs_get_current_weapon_ent(msg_entity);
    223.  
    224.         if (!pev_valid(ent))
    225.             return;
    226.  
    227.         cs_set_weapon_ammo(ent, get_pcvar_num(cvar_balrog_clip));
    228.         set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_balrog_clip));
    229.     }
    230. }
    231.  
    232. public fw_UpdateData_Post(id, sendweapons, cd_handle)
    233. {
    234.     if (!is_user_alive(id))
    235.         return FMRES_IGNORED;
    236.  
    237.     if (!g_has_balrog[id])
    238.         return FMRES_IGNORED;
    239.  
    240.     if (get_user_weapon(id) != CSW_UMP45)
    241.         return FMRES_IGNORED;
    242.  
    243.     set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
    244.  
    245.     return FMRES_IGNORED;
    246. }
    247.  
    248. public fw_SetModel(ent, const model[])
    249. {
    250.     if (!pev_valid(ent))
    251.         return FMRES_IGNORED;
    252.  
    253.     if (!equal(model, "models/w_ump45.mdl"))
    254.         return HAM_IGNORED;
    255.  
    256.     static class_name[33];
    257.     pev(ent, pev_classname, class_name, charsmax(class_name));
    258.  
    259.     if (!equal(class_name, "weaponbox"))
    260.         return FMRES_IGNORED;
    261.  
    262.     static owner, weapon;
    263.     owner = pev(ent, pev_owner);
    264.     weapon = find_ent_by_owner(-1, "weapon_ump45", ent);
    265.  
    266.     if (!g_has_balrog[owner] || !pev_valid(weapon))
    267.         return FMRES_IGNORED;
    268.  
    269.     g_has_balrog[owner] = false;
    270.  
    271.     set_pev(weapon, pev_impulse, BALROG_KEY);
    272.  
    273.     engfunc(EngFunc_SetModel, ent, W_BALROG_MDL);
    274.  
    275.     return FMRES_SUPERCEDE;
    276. }
    277.  
    278. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    279. {
    280.     if ((eventid != g_event_balrog) || !g_primary_attack)
    281.         return FMRES_IGNORED;
    282.  
    283.     if (!(1 <= invoker <= g_maxplayers))
    284.         return FMRES_IGNORED;
    285.  
    286.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
    287.  
    288.     return FMRES_SUPERCEDE;
    289. }
    290.  
    291. public fw_PrecacheEvent_Post(type, const name[])
    292. {
    293.     if (!equal("events/ump45.sc", name))
    294.         return HAM_IGNORED;
    295.  
    296.     g_event_balrog = get_orig_retval()
    297.  
    298.     return FMRES_HANDLED;
    299. }
    300.  
    301. public fw_Item_Deploy_Post(ent)
    302. {
    303.     if (!pev_valid(ent))
    304.         return HAM_IGNORED;
    305.  
    306.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    307.  
    308.     if (!is_user_alive(id))
    309.         return HAM_IGNORED;
    310.  
    311.     if (!g_has_balrog[id])
    312.         return HAM_IGNORED;
    313.  
    314.     set_pev(id, pev_viewmodel2, V_BALROG_MDL);
    315.     set_pev(id, pev_weaponmodel2, P_BALROG_MDL);
    316.  
    317.     play_weapon_anim(id, draw);
    318.  
    319.     return HAM_IGNORED;
    320. }
    321.  
    322. public fw_Item_AddToPlayer_Post(ent, id)
    323. {
    324.     if (!pev_valid(ent))
    325.         return HAM_IGNORED;
    326.  
    327.     if (!is_user_alive(id))
    328.         return HAM_IGNORED;
    329.  
    330.     if (pev(ent, pev_impulse) == BALROG_KEY)
    331.     {
    332.         g_has_balrog[id] = true;
    333.         set_pev(ent, pev_impulse, 0);
    334.     }
    335.  
    336.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    337.     write_string((g_has_balrog[id] ? "weapon_bethereal" : "weapon_ump45"))
    338.     write_byte(6)
    339.     write_byte(100)
    340.     write_byte(-1)
    341.     write_byte(-1)
    342.     write_byte(0)
    343.     write_byte(15)
    344.     write_byte(CSW_UMP45)
    345.     write_byte(0)
    346.     message_end()
    347.  
    348.     return HAM_IGNORED;
    349. }
    350.  
    351. public fw_Item_PostFrame(ent)
    352. {
    353.     if (!pev_valid(ent))
    354.         return HAM_IGNORED;
    355.  
    356.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    357.  
    358.     if (!is_user_alive(id))
    359.         return HAM_IGNORED;
    360.  
    361.     if (!g_has_balrog[id])
    362.         return HAM_IGNORED;
    363.  
    364.     static cvar_clip; cvar_clip = get_pcvar_num(cvar_balrog_clip);
    365.  
    366.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    367.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    368.  
    369.     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
    370.     new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);
    371.  
    372.     if (fInReload && flNextAttack <= 0.0)
    373.     {
    374.         new temp_clip = min(cvar_clip - clip, bpammo);
    375.  
    376.         set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);
    377.  
    378.         cs_set_user_bpammo(id, CSW_UMP45, bpammo-temp_clip);
    379.  
    380.         set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);
    381.  
    382.         fInReload = 0;
    383.     }
    384.  
    385.     return HAM_IGNORED;
    386. }
    387.  
    388. public fw_PrimaryAttack(ent)
    389. {
    390.     if (!pev_valid(ent))
    391.         return HAM_IGNORED;
    392.  
    393.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    394.  
    395.     if (!is_user_alive(id))
    396.         return HAM_IGNORED;
    397.  
    398.     if (!g_has_balrog[id])
    399.         return HAM_IGNORED;
    400.  
    401.     if (!cs_get_weapon_ammo(ent))
    402.         return HAM_IGNORED;
    403.  
    404.     g_primary_attack = true;
    405.  
    406.     return HAM_IGNORED;
    407. }
    408.  
    409. public fw_PrimaryAttack_Post(ent)
    410. {
    411.     if (!pev_valid(ent))
    412.         return HAM_IGNORED;
    413.  
    414.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    415.  
    416.     if (!is_user_alive(id))
    417.         return HAM_IGNORED;
    418.  
    419.     if (!g_has_balrog[id])
    420.         return HAM_IGNORED;
    421.  
    422.     if (!cs_get_weapon_ammo(ent))
    423.         return HAM_IGNORED;
    424.  
    425.     g_primary_attack = false;
    426.  
    427.     play_weapon_anim(id, random_num(shoot1, shoot3));
    428.  
    429.     emit_sound(id, CHAN_WEAPON, BALROG_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    430.  
    431.     make_laser_beam(id, 7, 100, 0, 0);
    432.  
    433.     return HAM_IGNORED;
    434. }
    435.  
    436. public fw_Reload(ent)
    437. {
    438.     if (!pev_valid(ent))
    439.         return HAM_IGNORED;
    440.  
    441.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    442.  
    443.     if (!is_user_alive(id))
    444.         return HAM_IGNORED;
    445.  
    446.     if (!g_has_balrog[id])
    447.         return HAM_IGNORED;
    448.  
    449.     static cvar_clip;
    450.  
    451.     if (g_has_balrog[id])
    452.         cvar_clip = get_pcvar_num(cvar_balrog_clip);
    453.  
    454.     g_balrog_reload_clip[id] = -1;
    455.  
    456.     new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
    457.     new bpammo = cs_get_user_bpammo(id, CSW_UMP45);
    458.  
    459.     if (bpammo <= 0)
    460.         return HAM_SUPERCEDE;
    461.  
    462.     if (clip >= cvar_clip)
    463.         return HAM_SUPERCEDE;
    464.    
    465.     g_balrog_reload_clip[id] = clip;
    466.  
    467.     return HAM_IGNORED;
    468. }
    469.  
    470. public fw_Reload_Post(ent)
    471. {
    472.     if (!pev_valid(ent))
    473.         return HAM_IGNORED;
    474.  
    475.     new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);
    476.  
    477.     if (!is_user_alive(id))
    478.         return HAM_IGNORED;
    479.  
    480.     if (!g_has_balrog[id])
    481.         return HAM_IGNORED;
    482.  
    483.     if (g_balrog_reload_clip[id] == -1)
    484.         return HAM_IGNORED;
    485.  
    486.     set_pdata_int(ent, m_iClip, g_balrog_reload_clip[id], OFFSET_LINUX_WEAPONS);
    487.     set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);
    488.  
    489.     play_weapon_anim(id, reload);
    490.  
    491.     return HAM_IGNORED;
    492. }
    493.  
    494. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, dmg_bits)
    495. {
    496.     if (!is_user_alive(attacker))
    497.         return HAM_IGNORED;
    498.  
    499.     if (!g_has_balrog[attacker])
    500.         return HAM_IGNORED;
    501.  
    502.     if (get_user_weapon(attacker) != CSW_UMP45)
    503.         return HAM_IGNORED;
    504.  
    505.     SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_balrog_damage));
    506.  
    507.     make_explosion_effect(attacker);
    508.  
    509.     return HAM_IGNORED;
    510. }
    511.  
    512. public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
    513. {
    514.     if (!is_user_alive(attacker))
    515.         return HAM_IGNORED;
    516.  
    517.     if (get_user_weapon(attacker) != CSW_UMP45)
    518.         return HAM_IGNORED;
    519.  
    520.     if (!g_has_balrog[attacker])
    521.         return HAM_IGNORED;
    522.  
    523.     make_explosion_effect(attacker);
    524.  
    525.     return HAM_IGNORED;
    526. }
    527.  
    528. give_balrog(id)
    529. {
    530.     drop_primary(id);
    531.  
    532.     g_has_balrog[id] = true;
    533.  
    534.     new weapon = fm_give_item(id, "weapon_ump45");
    535.  
    536.     cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_balrog_clip));
    537.     cs_set_user_bpammo(id, CSW_UMP45, get_pcvar_num(cvar_balrog_ammo));
    538. }
    539.  
    540. play_weapon_anim(id, frame)
    541. {
    542.     set_pev(id, pev_weaponanim, frame);
    543.  
    544.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
    545.     write_byte(frame)
    546.     write_byte(pev(id, pev_body))
    547.     message_end()
    548. }
    549.  
    550. make_laser_beam(id, Size, R, G, B)
    551. {
    552.     static End[3];
    553.     get_user_origin(id, End, 3);
    554.    
    555.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    556.     write_byte (TE_BEAMENTPOINT)
    557.     write_short( id |0x1000 )
    558.     write_coord(End[0])
    559.     write_coord(End[1])
    560.     write_coord(End[2])
    561.     write_short(g_laser_sprite)
    562.     write_byte(0)
    563.     write_byte(1)
    564.     write_byte(1)
    565.     write_byte(Size)
    566.     write_byte(4)
    567.     write_byte(R)
    568.     write_byte(G)
    569.     write_byte(B)
    570.     write_byte(255)
    571.     write_byte(0)
    572.     message_end()
    573. }
    574.  
    575. make_explosion_effect(id)
    576. {
    577.     static end[3];
    578.     get_user_origin(id, end, 3);
    579.  
    580.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    581.     write_byte(3)
    582.     write_coord(end[0])
    583.     write_coord(end[1])
    584.     write_coord(end[2])
    585.     write_short(g_balrog_exp)
    586.     write_byte(10)
    587.     write_byte(15)
    588.     write_byte(4)
    589.     message_end()
    590. }
    591.  
    592. drop_primary(id)
    593. {
    594.     static weapons[32], num;
    595.     get_user_weapons(id, weapons, num);
    596.  
    597.     for (new i = 0; i < num; i++)
    598.     {
    599.         if (WEAPON_BITSUM & (1<<weapons[i]))
    600.         {
    601.             static wname[32];
    602.             get_weaponname(weapons[i], wname, sizeof wname - 1);
    603.  
    604.             engclient_cmd(id, "drop", wname);
    605.         }
    606.     }
    607. }
    608.  
    609. stock fm_give_item(index, const item[])
    610. {
    611.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
    612.         return 0;
    613.  
    614.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
    615.     if (!pev_valid(ent))
    616.         return 0;
    617.  
    618.     new Float:origin[3];
    619.     pev(index, pev_origin, origin);
    620.     set_pev(ent, pev_origin, origin);
    621.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    622.     dllfunc(DLLFunc_Spawn, ent);
    623.  
    624.     new save = pev(ent, pev_solid);
    625.     dllfunc(DLLFunc_Touch, ent, index);
    626.     if (pev(ent, pev_solid) != save)
    627.         return ent;
    628.  
    629.     engfunc(EngFunc_RemoveEntity, ent);
    630.  
    631.     return -1;
    632. }
    633.  
    634. stock fm_cs_get_current_weapon_ent(id)
    635. {
    636.     if (pev_valid(id) != 2)
    637.         return -1;
    638.    
    639.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
    640. }
    641.  
    642. public native_give_balrog(id)
    643. {
    644.     //if ((get_user_flags(id) & ADMIN_LEVEL_H))
    645.     //{
    646.         give_balrog(id);
    647.     //}
    648. }
2. Dual:
    1. #include <zombie_escape>
    2. #include <cstrike>
    3. #include <fakemeta_util>
    4.  
    5.  
    6. #define PLUGIN "[ZE] Extra : DualInfinity"
    7. #define VERSION "1.0"
    8. #define AUTHOR "SexY Devil CJ"
    9.  
    10. #define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"
    11.  
    12. #define OFFSET_LINUX_WEAPONS 4
    13. #define OFFSET_LINUX 5
    14.  
    15. #define m_flNextAttack  83
    16. #define m_flNextPrimaryAttack   46
    17. #define m_flTimeWeaponIdle  48
    18. #define m_fInReload     54
    19.  
    20. #define pev_weaponkey pev_impulse
    21. #define weaponkey_value 18318
    22.  
    23. #define CSW_INFINITY CSW_ELITE
    24.  
    25. new const g_weapon_entity[]="weapon_elite"
    26. new const g_weapon_event1[]="events/elite_right.sc"
    27. new const g_weapon_event2[]="events/elite_left.sc"
    28. new const g_weapon_weaponbox_model[]="models/w_elite.mdl"
    29.  
    30. new const weapon_list_txt[]="weapon_dual_infinity2"
    31.  
    32. new const weapon_list_sprites[][]=
    33. {  
    34.     "sprites/zp/640hud42.spr",
    35.     "sprites/zp/640hud43.spr",
    36.     "sprites/zp/640hud7.spr"
    37. }
    38.  
    39. new const ViewModel[]="models/zp/v_infinityex2.mdl"
    40. new const PlayerModel[]="models/zp/p_infinity.mdl"
    41. new const WorldModel[]="models/zp/w_infinity.mdl"
    42.  
    43. new const Sounds[][]=
    44. {
    45.     "weapons/infi-1.wav",
    46.     "weapons/infi_clipin.wav",
    47.     "weapons/infi_clipon.wav",
    48.     "weapons/infi_clipout.wav",
    49.     "weapons/infi_draw.wav"
    50. }
    51.  
    52. new Blood[2]
    53.  
    54. new g_orig_event_dinfinity
    55.  
    56. new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
    57. new g_mode[33], g_anim_mode[33]
    58.  
    59. new g_itemid
    60.  
    61. new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast
    62.  
    63. new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
    64. new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs
    65.  
    66. new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast
    67.  
    68. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
    69.  
    70. public plugin_init()
    71. {  
    72.     register_plugin(PLUGIN, VERSION, AUTHOR)
    73.    
    74.     register_clcmd(weapon_list_txt, "Redirect")
    75.    
    76.     pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
    77.     pcvar_cost=register_cvar("dinfinity_cost", "15")
    78.     pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
    79.     pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
    80.     pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
    81.     pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
    82.    
    83.     pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
    84.     pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
    85.     pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
    86.     pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
    87.     pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
    88.    
    89.     pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
    90.     pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
    91.     pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
    92.     pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
    93.     pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")  
    94.    
    95.     ReadSettings()
    96.    
    97.     RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
    98.     RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
    99.     RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
    100.     RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
    101.     RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame")
    102.     RegisterHam(Ham_TakeDamage, "player", "fwDamagePre")
    103.     RegisterHam(Ham_RemovePlayerItem, "player", "fwRemoveItem")
    104.    
    105.     RegisterHam(Ham_TraceAttack, "player", "fwTraceAttackPost", 1)
    106.     RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttackPost", 1)
    107.     RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttackPost", 1)
    108.     RegisterHam(Ham_TraceAttack, "func_wall", "fwTraceAttackPost", 1)
    109.     RegisterHam(Ham_TraceAttack, "func_door", "fwTraceAttackPost", 1)
    110.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fwTraceAttackPost", 1)
    111.     RegisterHam(Ham_TraceAttack, "func_plat", "fwTraceAttackPost", 1)
    112.     RegisterHam(Ham_TraceAttack, "func_rotating", "fwTraceAttackPost", 1)  
    113.    
    114.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")  
    115.     register_forward(FM_UpdateClientData, "fwUpdateClientDataPost", 1)
    116.     register_forward(FM_CmdStart,  "fwCmdStart")
    117.     register_forward(FM_SetModel, "fwSetModel")
    118.    
    119.     new item_name[64]
    120.    
    121.     get_pcvar_string(pcvar_item_name, item_name, charsmax(item_name))
    122. }
    123.  
    124. public plugin_natives()
    125. {
    126.     register_native("give_dual_infinity", "native_give_dual_infinity", 1)
    127. }
    128.  
    129. public native_give_dual_infinity(id)
    130. {
    131.     give_infinity(id)
    132. }
    133.  
    134. public plugin_precache()
    135. {
    136.     precache_model(ViewModel)
    137.     precache_model(PlayerModel)
    138.     precache_model(WorldModel)
    139.    
    140.     for(new i; i<=charsmax(Sounds); i++)
    141.     {
    142.         precache_sound(Sounds[i])
    143.     }
    144.    
    145.     Blood[0] = precache_model("sprites/bloodspray.spr")
    146.     Blood[1] = precache_model("sprites/blood.spr")
    147.    
    148.     new tmp[128]
    149.    
    150.     formatex(tmp, charsmax(tmp), "sprites/%s.txt", weapon_list_txt)
    151.    
    152.     precache_generic(tmp)
    153.    
    154.     for(new i; i<=charsmax(weapon_list_sprites); i++)
    155.     {
    156.         precache_generic(weapon_list_sprites[i])
    157.        
    158.     }
    159.    
    160.     register_forward(FM_PrecacheEvent, "fwPrecachePost", 1)
    161. }
    162.  
    163. public ReadSettings()
    164. {
    165.     new confdir[64], path[128]
    166.    
    167.     get_configsdir(confdir, charsmax(confdir))
    168.    
    169.     formatex(path, charsmax(path), "%s/%s", confdir, CONFIG_CFG_FILE)
    170.    
    171.     server_cmd("exec %s", path)
    172.     server_exec()
    173.    
    174.     cvar_time_fire_normal=get_pcvar_float(pcvar_time_fire_normal)/*ط²ï¢» ي¦­é³¼ î،£è«³*/
    175.     cvar_time_fire_fast=get_pcvar_float(pcvar_time_fire_fast)
    176.    
    177. }
    178.  
    179. public Redirect(id)
    180. {  
    181.     client_cmd(id, g_weapon_entity)
    182. }
    183.  
    184. public client_disconnected(id)
    185. {
    186.     g_HasInfinity[id]=false
    187. }
    188.  
    189. public ze_user_infected(id, iInfector)
    190. {  
    191.     g_HasInfinity[id]=false
    192. }
    193.  
    194. public give_infinity(id)
    195. {
    196.     drop_weapons(id, 2)
    197.    
    198.     g_HasInfinity[id]=true
    199.    
    200.     new ent=fm_give_item(id, g_weapon_entity)
    201.    
    202.     cs_set_user_bpammo(id, CSW_INFINITY, get_pcvar_num(pcvar_bpammo))
    203.     cs_set_weapon_ammo(ent, get_pcvar_num(pcvar_clipammo))
    204.  
    205.    
    206.     InfinitySprite(id)
    207. }
    208.  
    209. public fwPrecachePost(type, const name[])
    210. {
    211.     if (equal(g_weapon_event1, name) || equal(g_weapon_event2, name) )
    212.     {
    213.         g_orig_event_dinfinity=get_orig_retval()
    214.        
    215.         return FMRES_HANDLED
    216.     }
    217.    
    218.     return FMRES_IGNORED
    219. }
    220.  
    221. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    222. {
    223.     if ((eventid != g_orig_event_dinfinity))
    224.         return FMRES_IGNORED
    225.    
    226.     if (!is_valid_player(invoker))
    227.         return FMRES_IGNORED
    228.    
    229.     fm_playback_event(flags|FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    230.    
    231.     return FMRES_SUPERCEDE
    232. }
    233.  
    234. public fwUpdateClientDataPost(id, SendWeapons, CD_Handle)
    235. {
    236.     if (!is_valid_player(id))
    237.         return FMRES_IGNORED
    238.    
    239.     if(get_user_weapon(id)!=CSW_INFINITY)
    240.         return FMRES_IGNORED
    241.    
    242.    
    243.     set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
    244.    
    245.     return FMRES_HANDLED
    246. }
    247.  
    248. public fwCmdStart(id, uc_handle, seed)
    249. {
    250.     if(!is_valid_player(id))
    251.         return
    252.    
    253.     if(get_user_weapon(id)!=CSW_INFINITY)
    254.         return
    255.        
    256.     static buttons; buttons=get_uc(uc_handle, UC_Buttons)
    257.    
    258.     if(!(buttons&IN_ATTACK2))
    259.     {
    260.         g_mode[id]=0
    261.        
    262.         return
    263.     }  
    264.    
    265.     static ent; ent=get_pdata_cbase(id, 373)  
    266.    
    267.     if((buttons&IN_ATTACK)) /*Fix*/
    268.     {
    269.         set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal,  OFFSET_LINUX_WEAPONS)
    270.        
    271.         g_mode[id]=0
    272.            
    273.         return
    274.     }  
    275.    
    276.     if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)||get_pdata_float(ent, m_flNextPrimaryAttack,  OFFSET_LINUX_WEAPONS)>-0.1)
    277.         return    
    278.    
    279.     g_mode[id]=1
    280.            
    281.     if(cs_get_weapon_ammo(ent)!=0)
    282.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    283. }
    284.  
    285. public fwSetModel(ent, model[])
    286. {
    287.     if(!pev_valid(ent))
    288.         return FMRES_IGNORED;
    289.  
    290.     if(!equal(model, g_weapon_weaponbox_model))
    291.         return FMRES_IGNORED;
    292.  
    293.     static classname[33]
    294.     pev(ent, pev_classname, classname, charsmax(classname))
    295.        
    296.     if(!equal(classname, "weaponbox"))
    297.         return FMRES_IGNORED
    298.  
    299.     static owner; owner=pev(ent, pev_owner)
    300.     static weap;weap=fm_find_ent_by_owner(-1, g_weapon_entity, ent)
    301.    
    302.     if(g_HasInfinity[owner]&&pev_valid(weap))
    303.     {
    304.         set_pev(weap, pev_weaponkey, weaponkey_value)
    305.        
    306.         g_HasInfinity[owner]=false
    307.        
    308.         fm_entity_set_model(ent, WorldModel)
    309.        
    310.         return FMRES_SUPERCEDE
    311.     }
    312.    
    313.     return FMRES_IGNORED
    314. }
    315.  
    316. public fwAddToPlayer(ent, id)
    317. {
    318.     if(pev_valid(ent))
    319.     {
    320.         if(pev(ent, pev_weaponkey)==weaponkey_value)
    321.         {
    322.             g_HasInfinity[id] = true
    323.        
    324.             set_pev(ent, pev_weaponkey, 0)
    325.        
    326.             InfinitySprite(id)
    327.        
    328.             return HAM_HANDLED
    329.            
    330.         }
    331.     }
    332.        
    333.     return HAM_IGNORED
    334. }
    335.  
    336. public fwDeployPost(ent)
    337. {
    338.     new id=fm_get_weapon_owner(ent)
    339.  
    340.     if (!is_valid_player(id))
    341.         return
    342.    
    343.     set_pev(id, pev_viewmodel2, ViewModel)
    344.     set_pev(id, pev_weaponmodel2, PlayerModel)
    345.  
    346.     playanim(id, 15)
    347.  
    348.     set_pdata_float(ent, m_flNextPrimaryAttack, 0.8,  OFFSET_LINUX_WEAPONS)
    349.  
    350.     g_anim_mode[id]=!g_anim_mode[id]
    351. }
    352.    
    353. public fwPrimaryAttack(ent)
    354. {
    355.     new id=fm_get_weapon_owner(ent)
    356.    
    357.     if (!is_valid_player(id))
    358.         return
    359.    
    360.     pev(id,pev_punchangle,cl_pushangle[id])
    361.    
    362.     g_player_weapon_ammo[id]=cs_get_weapon_ammo(ent)
    363. }
    364.  
    365. public fwTraceAttackPost(ent, attacker, Float:damage, Float:dir[3], ptr, damage_type)
    366. {
    367.     if(!is_valid_player(attacker))
    368.         return
    369.  
    370.     if(get_user_weapon(attacker)!=CSW_INFINITY)
    371.         return
    372.            
    373.     static Float:fEnd[3]
    374.    
    375.     get_tr2(ptr, TR_vecEndPos, fEnd)
    376.    
    377.     make_bullet_decals(attacker, fEnd)
    378.    
    379.     g_hitgroup[attacker]=get_tr2(ptr, TR_iHitgroup)
    380. }
    381.  
    382. public fwReloadPre(ent)
    383. {
    384.     new id=fm_get_weapon_owner(ent)
    385.    
    386.     if(!is_valid_player(id))
    387.         return HAM_IGNORED
    388.  
    389.     static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
    390.    
    391.     static clip; clip=cs_get_weapon_ammo(ent)
    392.    
    393.     if(bpammo>0&&clip<get_pcvar_num(pcvar_clipammo))
    394.     {
    395.         set_pdata_int(ent, 55, 0, OFFSET_LINUX_WEAPONS)
    396.        
    397.         set_pdata_float(id, m_flNextAttack, 4.4, OFFSET_LINUX)
    398.         set_pdata_float(ent, m_flTimeWeaponIdle, 4.4, OFFSET_LINUX_WEAPONS)
    399.         set_pdata_float(ent, m_flNextPrimaryAttack, 4.4, OFFSET_LINUX_WEAPONS)
    400.         set_pdata_float(ent, 47, 4.4, OFFSET_LINUX_WEAPONS)
    401.        
    402.         set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS)
    403.  
    404.         playanim(id, 14)
    405.     }
    406.    
    407.     return HAM_SUPERCEDE
    408. }
    409.  
    410. public fwItemPostFrame(ent)
    411. {
    412.     new id=fm_get_weapon_owner(ent)
    413.    
    414.     if(!is_valid_player(id))
    415.         return
    416.    
    417.     static bpammo; bpammo=cs_get_user_bpammo(id, CSW_INFINITY)
    418.     static clip; clip=cs_get_weapon_ammo(ent)
    419.    
    420.     if(clip<g_player_weapon_ammo[id])
    421.     {
    422.         g_player_weapon_ammo[id]=clip
    423.    
    424.         new Float:push[3]
    425.    
    426.         pev(id,pev_punchangle,push)
    427.        
    428.         xs_vec_sub(push,cl_pushangle[id],push)
    429.         xs_vec_mul_scalar(push,0.8,push)
    430.         xs_vec_add(push,cl_pushangle[id],push)
    431.    
    432.         if(g_mode[id]==0)
    433.         {
    434.             if(g_shoot_anim[id]==0)
    435.             {
    436.  
    437.                 playanim(id, 2)
    438.             }
    439.             else
    440.             {
    441.                 playanim(id, 12)  
    442.             }
    443.            
    444.             set_pdata_float(ent, m_flNextPrimaryAttack, cvar_time_fire_normal, OFFSET_LINUX_WEAPONS)
    445.         }
    446.         else
    447.         {
    448.             if(g_shoot_anim[id]==0)
    449.             {
    450.                 playanim(id, (g_anim_mode[id])?18:16)
    451.                
    452.                 push[0]+=1.0
    453.                 push[1]-=1.5
    454.             }
    455.             else
    456.             {
    457.                 playanim(id, (g_anim_mode[id])?19:17)
    458.                
    459.                 push[0]+=1.0
    460.                 push[1]+=1.5
    461.             }
    462.            
    463.             set_pdata_float(ent, m_flNextPrimaryAttack,cvar_time_fire_fast, OFFSET_LINUX_WEAPONS)
    464.         }
    465.        
    466.         g_shoot_anim[id]=!g_shoot_anim[id]    
    467.                
    468.         set_pev(id,pev_punchangle,push)
    469.        
    470.         emit_sound(id, CHAN_WEAPON, Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    471.     }
    472.    
    473.     if(get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS)&&get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
    474.     {
    475.        
    476.         set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS)
    477.        
    478.         for(new i = clip; i<get_pcvar_num(pcvar_clipammo); i++)
    479.         {
    480.             if(bpammo==0)
    481.                 break
    482.             bpammo--
    483.             clip++
    484.         }  
    485.        
    486.         cs_set_weapon_ammo(ent, clip)
    487.         cs_set_user_bpammo(id, CSW_INFINITY, bpammo)
    488.        
    489.     }
    490. }
    491.  
    492. public fwDamagePre(id, weapon, attacker, Float:damage)
    493. {
    494.    
    495.     if(!is_valid_player(attacker))
    496.         return
    497.    
    498.     if(get_user_weapon(attacker)!=CSW_INFINITY)
    499.         return
    500.    
    501.     new Float:Damage
    502.    
    503.     switch(g_hitgroup[attacker])
    504.     {
    505.        
    506.         case HIT_HEAD: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_head:pcvar_normal_damage_head)
    507.        
    508.         case HIT_CHEST: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_chest:pcvar_normal_damage_chest)
    509.        
    510.         case HIT_STOMACH: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_stomach:pcvar_normal_damage_stomach)
    511.        
    512.         case HIT_LEFTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
    513.         case HIT_RIGHTARM: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_arms:pcvar_normal_damage_arms)
    514.        
    515.         case HIT_LEFTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
    516.         case HIT_RIGHTLEG: Damage=get_pcvar_float((g_mode[attacker])?pcvar_fast_damage_legs:pcvar_normal_damage_legs)
    517.        
    518.     }
    519.    
    520.     SetHamParamFloat(4, Damage)
    521. }
    522.  
    523. public fwRemoveItem(id, ent)
    524. {
    525.     if(!is_valid_player(id))
    526.         return
    527.        
    528.     new classname[62]
    529.    
    530.     pev(ent, pev_classname, classname, 61)
    531.    
    532.     if(!equal(classname, g_weapon_entity))
    533.         return
    534.    
    535.     DefaultSprite(id)
    536.        
    537. }
    538.  
    539. public make_bullet_decals(id, Float:Origin[3])
    540. {
    541.     new target, body
    542.     get_user_aiming(id, target, body, 999999)
    543.    
    544.     if(is_user_alive(target))
    545.     {
    546.         if(ze_is_user_zombie(id))
    547.         {
    548.             new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
    549.             pev(id, pev_origin, fStart)
    550.            
    551.             velocity_by_aim(id, 64, fVel)
    552.            
    553.             fStart[0] = Origin[0]
    554.             fStart[1] = Origin[1]
    555.             fStart[2] = Origin[2]
    556.             fEnd[0] = fStart[0]+fVel[0]
    557.             fEnd[1] = fStart[1]+fVel[1]
    558.             fEnd[2] = fStart[2]+fVel[2]
    559.    
    560.             new res
    561.             engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
    562.             get_tr2(res, TR_vecEndPos, fRes)
    563.            
    564.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    565.             write_byte(TE_BLOODSPRITE)
    566.             write_coord(floatround(fStart[0]))
    567.             write_coord(floatround(fStart[1]))
    568.             write_coord(floatround(fStart[2]))
    569.             write_short(Blood[0])
    570.             write_short(Blood[1])
    571.             write_byte(70)
    572.             write_byte(random_num(1,2))
    573.             message_end()
    574.         }
    575.     }
    576.        
    577.     else
    578.     {
    579.         new decal = 41
    580.  
    581.         if(target)
    582.         {
    583.            
    584.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    585.             write_byte(TE_DECAL)
    586.             write_coord(floatround(Origin[0]))
    587.             write_coord(floatround(Origin[1]))
    588.             write_coord(floatround(Origin[2]))
    589.             write_byte(decal)
    590.             write_short(target)
    591.             message_end()
    592.         }
    593.         else
    594.         {  
    595.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    596.             write_byte(TE_WORLDDECAL)
    597.             write_coord(floatround(Origin[0]))
    598.             write_coord(floatround(Origin[1]))
    599.             write_coord(floatround(Origin[2]))
    600.             write_byte(decal)
    601.             message_end()
    602.         }
    603.        
    604.        
    605.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    606.         write_byte(TE_GUNSHOTDECAL)
    607.         write_coord(floatround(Origin[0]))
    608.         write_coord(floatround(Origin[1]))
    609.         write_coord(floatround(Origin[2]))
    610.         write_short(id)
    611.         write_byte(decal)
    612.         message_end()
    613.     }
    614. }
    615.  
    616. public InfinitySprite(id)
    617. {
    618.     message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
    619.     write_string(weapon_list_txt)
    620.     write_byte(10)
    621.     write_byte(120)
    622.     write_byte(-1)
    623.     write_byte(-1)
    624.     write_byte(1)
    625.     write_byte(1)
    626.     write_byte(CSW_INFINITY)
    627.     write_byte(0)
    628.     message_end()
    629. }
    630.  
    631. public DefaultSprite(id)
    632. {
    633.     message_begin( MSG_ONE, get_user_msgid("WeaponList"), .player=id )
    634.     write_string(g_weapon_entity)
    635.     write_byte(10)
    636.     write_byte(120)
    637.     write_byte(-1)
    638.     write_byte(-1)
    639.     write_byte(1)
    640.     write_byte(1)
    641.     write_byte(CSW_INFINITY)
    642.     write_byte(0)
    643.     message_end()
    644. }
    645.  
    646. public is_valid_player(id)
    647. {
    648.        
    649.     if(!is_user_alive(id))
    650.         return false
    651.        
    652.     if(!g_HasInfinity[id])
    653.         return false
    654.  
    655.     return true
    656. }
    657.  
    658. stock drop_weapons(id, dropwhat)
    659. {
    660.     static weapons[32], num, i, weaponid
    661.     num = 0
    662.     get_user_weapons(id, weapons, num)
    663.    
    664.     for (i = 0; i < num; i++)
    665.     {
    666.         weaponid = weapons[i]
    667.        
    668.         if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
    669.         {
    670.             static wname[32]
    671.             get_weaponname(weaponid, wname, sizeof wname - 1)
    672.            
    673.             engclient_cmd(id, "drop", wname)
    674.         }
    675.     }
    676.    
    677. }
    678.  
    679. stock playanim(player,anim)
    680. {
    681.     set_pev(player, pev_weaponanim, anim)
    682.    
    683.     message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
    684.     write_byte(anim)
    685.     write_byte(pev(player, pev_body))
    686.     message_end()
    687. }
    688.  
    689. stock fm_get_weapon_owner(weapon)
    690. {  
    691.     return get_pdata_cbase(weapon, 41, 4)
    692.    
    693. }
3. Water gun:
    1. #include <zombie_escape>
    2. #include <engine>
    3. #include <fun>
    4. #include <xs>
    5. #include <cstrike>
    6.  
    7. #define ENG_NULLENT     -1
    8. #define EV_INT_WEAPONKEY    EV_INT_impulse
    9. #define watergun_WEAPONKEY 893
    10. #define MAX_PLAYERS               32
    11. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
    12.  
    13. #define TASK_FBURN              100
    14. #define ID_FBURN                    ( taskid - TASK_FBURN )
    15.  
    16. new bool:g_fRoundEnd
    17.  
    18. #define FIRE_DURATION       6
    19. #define FIRE_DAMAGE     25
    20.  
    21. const USE_STOPPED = 0
    22. const OFFSET_ACTIVE_ITEM = 373
    23. const OFFSET_WEAPONOWNER = 41
    24. const OFFSET_LINUX = 5
    25. const OFFSET_LINUX_WEAPONS = 4
    26.  
    27. #define WEAP_LINUX_XTRA_OFF     4
    28. #define m_fKnown                    44
    29. #define m_flNextPrimaryAttack       46
    30. #define m_flTimeWeaponIdle          48
    31. #define m_iClip                 51
    32. #define m_fInReload             54
    33. #define PLAYER_LINUX_XTRA_OFF   5
    34. #define m_flNextAttack              83
    35.  
    36. #define watergun_RELOAD_TIME    3.5
    37. #define watergun_RELOAD     1
    38. #define watergun_DRAW       2
    39. #define watergun_SHOOT1     3
    40. #define watergun_SHOOT2     4
    41.  
    42. new g_flameSpr
    43. new g_smokeSpr
    44.  
    45. new g_burning_duration[33]
    46.  
    47. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    48.  
    49. new const Fire_Sounds[][] = { "weapons/waterp.wav" }
    50.  
    51. new watergun_V_MODEL[64] = "models/zombie_escape/watergun/v_waterg.mdl"
    52. new watergun_P_MODEL[64] = "models/zombie_escape/watergun/p_waterg.mdl"
    53. new watergun_W_MODEL[64] = "models/zombie_escape/watergun/w_waterg.mdl"
    54.  
    55. //new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    56.  
    57. new cvar_dmg_watergun, cvar_recoil_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
    58. new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
    59. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
    60. new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
    61. new watergun_sprite
    62.  
    63. const PRIMARY_WEAPONS_BIT_SUM =
    64. (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<<
    65. 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)
    66. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
    67.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
    68.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
    69.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
    70.             "weapon_ak47", "weapon_knife", "weapon_p90" }
    71.  
    72. public plugin_init()
    73. {
    74.     register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")
    75.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
    76.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    77.     RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
    78.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
    79.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
    80.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
    81.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
    82.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
    83.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
    84.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
    85.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
    86.     RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
    87.     RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
    88.     RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
    89.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    90.     RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
    91.     register_forward(FM_SetModel, "fw_SetModel")
    92.     register_event( "DeathMsg", "EV_DeathMsg", "a" );
    93.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    94.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
    95.  
    96.     cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.2")
    97.     cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")
    98.     cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")
    99.     cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")
    100.     cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")
    101.    
    102.     g_MaxPlayers = get_member_game(m_nMaxPlayers)
    103. }
    104.  
    105. public plugin_precache()
    106. {
    107.     precache_model(watergun_V_MODEL)
    108.     precache_model(watergun_P_MODEL)
    109.     precache_model(watergun_W_MODEL)
    110.     for(new i = 0; i < sizeof Fire_Sounds; i++)
    111.     precache_sound(Fire_Sounds[i]) 
    112.     m_iBlood[0] = precache_model("sprites/blood.spr")
    113.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    114.     watergun_sprite = precache_model("sprites/zombie_escape/watergun/watergun.spr")
    115.  
    116.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
    117. }
    118.  
    119. public plugin_natives()
    120. {
    121.     register_native("give_watergun", "native_give_watergun", 1)
    122. }
    123.  
    124. public native_give_watergun(id)
    125. {
    126.     give_watergun(id)
    127. }
    128.  
    129. public ze_user_humanized(id)
    130. {
    131.     g_has_watergun[id] = false
    132. }
    133.  
    134. public fwPrecacheEvent_Post(type, const name[])
    135. {
    136.     if (equal("events/mp5n.sc", name))
    137.     {
    138.         g_orig_event_watergun = get_orig_retval()
    139.         return FMRES_HANDLED
    140.     }
    141.     return FMRES_IGNORED
    142. }
    143.  
    144. public client_connect(id)
    145. {
    146.     g_has_watergun[id] = false
    147. }
    148.  
    149. public client_disconnected(id)
    150. {
    151.     g_has_watergun[id] = false
    152.  
    153.     remove_task(id + TASK_FBURN )
    154. }
    155.  
    156. public ze_user_infected(id)
    157. {
    158.     if (ze_is_user_zombie(id))
    159.     {
    160.         g_has_watergun[id] = false
    161.  
    162.         remove_task(id + TASK_FBURN)
    163.     }
    164. }
    165.  
    166. public fw_SetModel(entity, model[])
    167. {
    168.     if(!is_valid_ent(entity))
    169.         return FMRES_IGNORED
    170.    
    171.     static szClassName[33]
    172.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    173.        
    174.     if(!equal(szClassName, "weaponbox"))
    175.         return FMRES_IGNORED
    176.    
    177.     static iOwner
    178.    
    179.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    180.    
    181.     if(equal(model, "models/w_mp5.mdl"))
    182.     {
    183.         static iStoredAugID
    184.        
    185.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
    186.    
    187.         if(!is_valid_ent(iStoredAugID))
    188.             return FMRES_IGNORED
    189.    
    190.         if(g_has_watergun[iOwner])
    191.         {
    192.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
    193.            
    194.             g_has_watergun[iOwner] = false
    195.            
    196.             entity_set_model(entity, watergun_W_MODEL)
    197.            
    198.             return FMRES_SUPERCEDE
    199.         }
    200.     }
    201.     return FMRES_IGNORED
    202. }
    203.  
    204. public EV_DeathMsg( )
    205. {
    206.     static pevVictim;
    207.     pevVictim = read_data( 2 )
    208.    
    209.     if( !is_user_connected( pevVictim ) )
    210.         return
    211.        
    212.     remove_task( pevVictim + TASK_FBURN )
    213. }
    214.  
    215. public PlayerSpawn_Post( Player )
    216. {
    217.     if( !is_user_alive( Player ) )
    218.         return;
    219.        
    220.     g_burning_duration[ Player ] = 0
    221. }
    222.  
    223. public give_watergun(id)
    224. {
    225.     drop_weapons(id, 1)
    226.     new iWep2 = give_item(id,"weapon_mp5navy")
    227.     if( iWep2 > 0 )
    228.     {
    229.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
    230.         cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))
    231.         UTIL_PlayWeaponAnimation(id, watergun_DRAW)
    232.         set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
    233.     }
    234.     g_has_watergun[id] = true
    235. }
    236.  
    237. public fw_watergun_AddToPlayer(watergun, id)
    238. {
    239.     if(!is_valid_ent(watergun) || !is_user_connected(id))
    240.         return HAM_IGNORED
    241.    
    242.     if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
    243.     {
    244.         g_has_watergun[id] = true
    245.        
    246.         entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
    247.        
    248.         return HAM_HANDLED
    249.     }
    250.     return HAM_IGNORED
    251. }
    252.  
    253. public fw_UseStationary_Post(entity, caller, activator, use_type)
    254. {
    255.     if (use_type == USE_STOPPED && is_user_connected(caller))
    256.         replace_weapon_models(caller, get_user_weapon(caller))
    257. }
    258.  
    259. public fw_Item_Deploy_Post(weapon_ent)
    260. {
    261.     static owner
    262.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
    263.    
    264.     static weaponid
    265.     weaponid = cs_get_weapon_id(weapon_ent)
    266.    
    267.     replace_weapon_models(owner, weaponid)
    268. }
    269.  
    270. public CurrentWeapon(id)
    271. {
    272.      replace_weapon_models(id, read_data(2))
    273.  
    274.      if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
    275.           return
    276.      
    277.      static Float:iSpeed
    278.      if(g_has_watergun[id])
    279.           iSpeed = get_pcvar_float(cvar_spd_watergun)
    280.      
    281.      static weapon[32],Ent
    282.      get_weaponname(read_data(2),weapon,31)
    283.      Ent = find_ent_by_owner(-1,weapon,id)
    284.      if(Ent)
    285.      {
    286.           static Float:Delay
    287.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
    288.           if (Delay > 0.0)
    289.           {
    290.                set_pdata_float(Ent, 46, Delay, 4)
    291.           }
    292.      }
    293. }
    294.  
    295. replace_weapon_models(id, weaponid)
    296. {
    297.     switch (weaponid)
    298.     {
    299.         case CSW_MP5NAVY:
    300.         {
    301.             if (ze_is_user_zombie(id))
    302.                 return
    303.            
    304.             if(g_has_watergun[id])
    305.             {
    306.                 set_pev(id, pev_viewmodel2, watergun_V_MODEL)
    307.                 set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
    308.                 if(oldweap[id] != CSW_MP5NAVY)
    309.                 {
    310.                     UTIL_PlayWeaponAnimation(id, watergun_DRAW)
    311.                     set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
    312.                 }
    313.             }
    314.         }
    315.     }
    316.     oldweap[id] = weaponid
    317. }
    318.  
    319. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
    320. {
    321.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_MP5NAVY || !g_has_watergun[Player]))
    322.         return FMRES_IGNORED
    323.    
    324.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    325.     return FMRES_HANDLED
    326. }
    327.  
    328. public fw_watergun_PrimaryAttack(Weapon)
    329. {
    330.     new Player = get_pdata_cbase(Weapon, 41, 4)
    331.    
    332.     if (!g_has_watergun[Player])
    333.         return
    334.    
    335.     g_IsInPrimaryAttack = 1
    336.     pev(Player,pev_punchangle,cl_pushangle[Player])
    337.    
    338.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
    339. }
    340.  
    341. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    342. {
    343.     if ((eventid != g_orig_event_watergun) || !g_IsInPrimaryAttack)
    344.         return FMRES_IGNORED
    345.     if (!(1 <= invoker <= g_MaxPlayers))
    346.     return FMRES_IGNORED
    347.  
    348.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    349.     return FMRES_SUPERCEDE
    350. }
    351.  
    352. public fw_watergun_PrimaryAttack_Post(Weapon)
    353. {
    354.     g_IsInPrimaryAttack = 0
    355.     new Player = get_pdata_cbase(Weapon, 41, 4)
    356.    
    357.     new szClip, szAmmo
    358.     get_user_weapon(Player, szClip, szAmmo)
    359.    
    360.     if(!is_user_alive(Player))
    361.         return
    362.  
    363.     if(g_has_watergun[Player])
    364.     {
    365.         if (!g_clip_ammo[Player])
    366.             return
    367.  
    368.         new Float:push[3]
    369.         pev(Player,pev_punchangle,push)
    370.         xs_vec_sub(push,cl_pushangle[Player],push)
    371.        
    372.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_watergun),push)
    373.         xs_vec_add(push,cl_pushangle[Player],push)
    374.         set_pev(Player,pev_punchangle,push)
    375.        
    376.         emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    377.         UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))
    378.  
    379.         static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
    380.         pev(Player, pev_v_angle, plrViewAngles)
    381.  
    382.         static Float:VecSrc[3], Float:VecDst[3]
    383.    
    384.         //VecSrc = pev->origin + pev->view_ofs
    385.         pev(Player, pev_origin, PlrOrigin)
    386.         pev(Player, pev_view_ofs, VecSrc)
    387.         xs_vec_add(VecSrc, PlrOrigin, VecSrc)
    388.  
    389.         //VecDst = VecDir * 8192.0
    390.         angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
    391.         xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
    392.         xs_vec_add(VecDst, VecSrc, VecDst);
    393.    
    394.         new hTrace = create_tr2()
    395.         engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
    396.         get_tr2(hTrace, TR_vecEndPos, VecEnd);
    397.  
    398.         create_tracer_water(Player, VecSrc, VecEnd)
    399.     }
    400. }
    401.  
    402. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    403. {
    404.     if(!is_user_alive(attacker))
    405.         return;
    406.  
    407.     if (victim != attacker && is_user_connected(attacker))
    408.     {
    409.         if(get_user_weapon(attacker) == CSW_MP5NAVY)
    410.         {
    411.             if(g_has_watergun[attacker])
    412.             {
    413.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))
    414.  
    415.                 if( !task_exists( victim + TASK_FBURN ) )
    416.                 {
    417.                     g_burning_duration[ victim ] += FIRE_DURATION * 5
    418.                
    419.                     set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
    420.                 }
    421.             }
    422.         }
    423.     }
    424. }
    425.  
    426. public message_DeathMsg(msg_id, msg_dest, id)
    427. {
    428.     static szTruncatedWeapon[33], iAttacker, iVictim
    429.    
    430.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    431.    
    432.     iAttacker = get_msg_arg_int(1)
    433.     iVictim = get_msg_arg_int(2)
    434.    
    435.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
    436.         return PLUGIN_CONTINUE
    437.    
    438.     if(equal(szTruncatedWeapon, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
    439.     {
    440.         if(g_has_watergun[iAttacker])
    441.             set_msg_arg_string(4, "mp5navy")
    442.     }
    443.     return PLUGIN_CONTINUE
    444. }
    445.  
    446. stock fm_cs_get_current_weapon_ent(id)
    447. {
    448.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
    449. }
    450.  
    451. stock fm_cs_get_weapon_ent_owner(ent)
    452. {
    453.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
    454. }
    455.  
    456. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
    457. {
    458.     set_pev(Player, pev_weaponanim, Sequence)
    459.    
    460.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    461.     write_byte(Sequence)
    462.     write_byte(pev(Player, pev_body))
    463.     message_end()
    464. }
    465.  
    466. public watergun_ItemPostFrame(weapon_entity)
    467. {
    468.      new id = pev(weapon_entity, pev_owner)
    469.      if (!is_user_connected(id))
    470.           return HAM_IGNORED
    471.  
    472.      if (!g_has_watergun[id])
    473.           return HAM_IGNORED
    474.  
    475.      static iClipExtra
    476.      
    477.      iClipExtra = get_pcvar_num(cvar_clip_watergun)
    478.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
    479.  
    480.      new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
    481.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
    482.  
    483.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
    484.  
    485.      if( fInReload && flNextAttack <= 0.0 )
    486.      {
    487.          new j = min(iClipExtra - iClip, iBpAmmo)
    488.    
    489.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
    490.          cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
    491.        
    492.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
    493.          fInReload = 0
    494.      }
    495.      return HAM_IGNORED
    496. }
    497.  
    498. public watergun_Reload(weapon_entity)
    499. {
    500.      new id = pev(weapon_entity, pev_owner)
    501.      if (!is_user_connected(id))
    502.           return HAM_IGNORED
    503.  
    504.      if (!g_has_watergun[id])
    505.           return HAM_IGNORED
    506.  
    507.      static iClipExtra
    508.  
    509.      if(g_has_watergun[id])
    510.           iClipExtra = get_pcvar_num(cvar_clip_watergun)
    511.  
    512.      g_watergun_TmpClip[id] = -1
    513.  
    514.      new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
    515.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
    516.  
    517.      if (iBpAmmo <= 0)
    518.           return HAM_SUPERCEDE
    519.  
    520.      if (iClip >= iClipExtra)
    521.           return HAM_SUPERCEDE
    522.  
    523.      g_watergun_TmpClip[id] = iClip
    524.  
    525.      return HAM_IGNORED
    526. }
    527.  
    528. public watergun_Reload_Post(weapon_entity)
    529. {
    530.     new id = pev(weapon_entity, pev_owner)
    531.     if (!is_user_connected(id))
    532.         return HAM_IGNORED
    533.  
    534.     if (!g_has_watergun[id])
    535.         return HAM_IGNORED
    536.  
    537.     if (g_watergun_TmpClip[id] == -1)
    538.         return HAM_IGNORED
    539.  
    540.     set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)
    541.  
    542.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
    543.  
    544.     set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
    545.  
    546.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
    547.  
    548.     UTIL_PlayWeaponAnimation(id, watergun_RELOAD)
    549.  
    550.     return HAM_IGNORED
    551. }
    552.  
    553. stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
    554. {
    555.     static iVec1[3]
    556.     FVecIVec(fVec1, iVec1)
    557.  
    558.     static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
    559.     pev(id, pev_v_angle, angles)
    560.     engfunc(EngFunc_MakeVectors, angles)
    561.     global_get(glb_v_forward, v_forward)
    562.     global_get(glb_v_right, v_right)
    563.     global_get(glb_v_up, v_up)
    564.  
    565.     //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
    566.     pev(id, pev_origin, player_origin)
    567.     pev(id, pev_view_ofs, player_view_offset)
    568.     xs_vec_add(player_origin, player_view_offset, gun_position)
    569.  
    570.     xs_vec_mul_scalar(v_forward, 24.0, v_forward)
    571.     xs_vec_mul_scalar(v_right, 3.0, v_right)
    572.  
    573.     if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
    574.         xs_vec_mul_scalar(v_up, 6.0, v_up)
    575.     else
    576.         xs_vec_mul_scalar(v_up, -2.0, v_up)
    577.  
    578.     xs_vec_add(gun_position, v_forward, origin)
    579.     xs_vec_add(origin, v_right, origin)
    580.     xs_vec_add(origin, v_up, origin)
    581.  
    582.     vSrc[0] = origin[0]
    583.     vSrc[1] = origin[1]
    584.     vSrc[2] = origin[2]
    585.  
    586.     new Float:dist = get_distance_f(vSrc, fVec2)
    587.     new CountDrops = floatround(dist / 50.0)
    588.    
    589.     if (CountDrops > 20)
    590.         CountDrops = 20
    591.    
    592.     if (CountDrops < 2)
    593.         CountDrops = 2
    594.  
    595.     message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
    596.     write_byte(TE_SPRITETRAIL)
    597.     engfunc(EngFunc_WriteCoord, vSrc[0])
    598.     engfunc(EngFunc_WriteCoord, vSrc[1])
    599.     engfunc(EngFunc_WriteCoord, vSrc[2])
    600.     engfunc(EngFunc_WriteCoord, fVec2[0])
    601.     engfunc(EngFunc_WriteCoord, fVec2[1])
    602.     engfunc(EngFunc_WriteCoord, fVec2[2])
    603.     write_short(watergun_sprite)
    604.     write_byte(CountDrops)
    605.     write_byte(0)
    606.     write_byte(1)
    607.     write_byte(60)
    608.     write_byte(10)
    609.     message_end()
    610.  
    611.     message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
    612.     write_byte(TE_BEAMPOINTS)
    613.     engfunc(EngFunc_WriteCoord, fVec2[0])
    614.     engfunc(EngFunc_WriteCoord, fVec2[1])
    615.     engfunc(EngFunc_WriteCoord, fVec2[2])
    616.     engfunc(EngFunc_WriteCoord, vSrc[0])
    617.     engfunc(EngFunc_WriteCoord, vSrc[1])
    618.     engfunc(EngFunc_WriteCoord, vSrc[2])
    619.     write_short(watergun_sprite)
    620.     write_byte(6)
    621.     write_byte(200)
    622.     write_byte(1)
    623.     write_byte(100)
    624.     write_byte(0)
    625.     write_byte(64); write_byte(64); write_byte(192);
    626.     write_byte(192)
    627.     write_byte(250)
    628.     message_end()
    629. }
    630.  
    631. stock drop_weapons(id, dropwhat)
    632. {
    633.      static weapons[32], num, i, weaponid
    634.      num = 0
    635.      get_user_weapons(id, weapons, num)
    636.      
    637.      for (i = 0; i < num; i++)
    638.      {
    639.           weaponid = weapons[i]
    640.          
    641.           if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    642.           {
    643.                static wname[32]
    644.                get_weaponname(weaponid, wname, sizeof wname - 1)
    645.                engclient_cmd(id, "drop", wname)
    646.           }
    647.      }
    648. }
    649.  
    650. public CTask__BurningFlame( taskid )
    651. {
    652.     // Get player origin and flags
    653.     static origin[3], flags
    654.     get_user_origin(ID_FBURN, origin)
    655.     flags = pev(ID_FBURN, pev_flags)
    656.    
    657.     // Madness mode - in water - burning stopped
    658.     if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
    659.     {
    660.         // Smoke sprite
    661.         message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    662.         write_byte(TE_SMOKE) // TE id
    663.         write_coord(origin[0]) // x
    664.         write_coord(origin[1]) // y
    665.         write_coord(origin[2]-50) // z
    666.         write_short(g_smokeSpr) // sprite
    667.         write_byte(random_num(15, 20)) // scale
    668.         write_byte(random_num(10, 20)) // framerate
    669.         message_end()
    670.        
    671.         // Task not needed anymore
    672.         remove_task(taskid)
    673.         return
    674.     }
    675.    
    676.     // Get player's health
    677.     static health
    678.     health = pev(ID_FBURN, pev_health)
    679.    
    680.     // Take damage from the fire
    681.     if (health - FIRE_DAMAGE > 0)
    682.         fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
    683.    
    684.     // Flame sprite
    685.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    686.     write_byte(TE_SPRITE) // TE id
    687.     write_coord(origin[0]+random_num(-5, 5)) // x
    688.     write_coord(origin[1]+random_num(-5, 5)) // y
    689.     write_coord(origin[2]+random_num(-10, 10)) // z
    690.     write_short(g_flameSpr) // sprite
    691.     write_byte(random_num(5, 10)) // scale
    692.     write_byte(200) // brightness
    693.     message_end()
    694.  
    695.    
    696.     g_burning_duration[ID_FBURN]--
    697. }
    698.  
    699. stock fm_set_user_health( index, health )
    700.     health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);
Last edited by Raheem on 12 Mar 2019, 19:44, edited 1 time in total.
Reason: Updated dual
You don't know? Learn and you will know.

Luxurious
Senior Member
Senior Member
Egypt
Posts: 103
Joined: 1 Year Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#10

Post by Luxurious » 1 Month Ago

Raheem wrote:
1 Month Ago
2. Dual:
    1. #include <zombie_escape>
    2. #include <cstrike>
    3. #include <fakemeta_util>
    4.  
    5.  
    6. #define PLUGIN "[ZE] Extra : DualInfinity"
    7. #define VERSION "1.0"
    8. #define AUTHOR "SexY Devil CJ"
    9.  
    10. #define CONFIG_CFG_FILE "weapons/dual_infinity.cfg"
    11.  
    12. #define OFFSET_LINUX_WEAPONS 4
    13. #define OFFSET_LINUX 5
    14.  
    15. #define m_flNextAttack  83
    16. #define m_flNextPrimaryAttack   46
    17. #define m_flTimeWeaponIdle  48
    18. #define m_fInReload     54
    19.  
    20. #define pev_weaponkey pev_impulse
    21. #define weaponkey_value 18318
    22.  
    23. #define CSW_INFINITY CSW_ELITE
    24.  
    25. new const g_weapon_entity[]="weapon_elite"
    26. new const g_weapon_event1[]="events/elite_right.sc"
    27. new const g_weapon_event2[]="events/elite_left.sc"
    28. new const g_weapon_weaponbox_model[]="models/w_elite.mdl"
    29.  
    30. new const weapon_list_txt[]="weapon_dual_infinity2"
    31.  
    32. new const weapon_list_sprites[][]=
    33. {  
    34.     "sprites/zp/640hud42.spr",
    35.     "sprites/zp/640hud43.spr",
    36.     "sprites/zp/640hud7.spr"
    37. }
    38.  
    39. new const ViewModel[]="models/zp/v_infinityex2.mdl"
    40. new const PlayerModel[]="models/zp/p_infinity.mdl"
    41. new const WorldModel[]="models/zp/w_infinity.mdl"
    42.  
    43. new const Sounds[][]=
    44. {
    45.     "weapons/infi-1.wav",
    46.     "weapons/infi_clipin.wav",
    47.     "weapons/infi_clipon.wav",
    48.     "weapons/infi_clipout.wav",
    49.     "weapons/infi_draw.wav"
    50. }
    51.  
    52. new Blood[2]
    53.  
    54. new g_orig_event_dinfinity
    55.  
    56. new g_HasInfinity[33], g_player_weapon_ammo[33], Float:cl_pushangle[33][3],  g_shoot_anim[33], g_hitgroup[33]
    57. new g_mode[33], g_anim_mode[33]
    58.  
    59. new g_itemid
    60.  
    61. new pcvar_item_name, pcvar_clipammo, pcvar_bpammo, pcvar_cost, pcvar_time_fire_normal, pcvar_time_fire_fast
    62.  
    63. new pcvar_normal_damage_head, pcvar_normal_damage_chest, pcvar_normal_damage_stomach, pcvar_normal_damage_arms, pcvar_normal_damage_legs
    64. new pcvar_fast_damage_head, pcvar_fast_damage_chest, pcvar_fast_damage_stomach, pcvar_fast_damage_arms, pcvar_fast_damage_legs
    65.  
    66. new Float:cvar_time_fire_normal, Float:cvar_time_fire_fast
    67.  
    68. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
    69.  
    70. public plugin_init()
    71. {  
    72.     register_plugin(PLUGIN, VERSION, AUTHOR)
    73.    
    74.     register_clcmd(weapon_list_txt, "Redirect")
    75.    
    76.     pcvar_item_name=register_cvar("dinfinity_item_name", "Dual Infinity")
    77.     pcvar_cost=register_cvar("dinfinity_cost", "15")
    78.     pcvar_bpammo=register_cvar("dinfinity_bpammo", "100")
    79.     pcvar_clipammo=register_cvar("dinfinity_clipammo", "40")
    80.     pcvar_time_fire_normal=register_cvar("dinfinity_fire_normal_period", "0.15")
    81.     pcvar_time_fire_fast=register_cvar("dinfinity_fire_fast_period", "0.02")
    82.    
    83.     pcvar_normal_damage_head=register_cvar("dinfinity_normal_damage_head", "130")
    84.     pcvar_normal_damage_chest=register_cvar("dinfinity_normal_damage_chest", "34")
    85.     pcvar_normal_damage_stomach=register_cvar("dinfinity_normal_damage_stomach", "34")
    86.     pcvar_normal_damage_arms=register_cvar("dinfinity_normal_damage_arms", "34")
    87.     pcvar_normal_damage_legs=register_cvar("dinfinity_normal_damage_legs", "34")
    88.    
    89.     pcvar_fast_damage_head=register_cvar("dinfinity_fast_damage_head", "115")
    90.     pcvar_fast_damage_chest=register_cvar("dinfinity_fast_damage_chest", "30")
    91.     pcvar_fast_damage_stomach=register_cvar("dinfinity_fast_damage_stomach", "30")
    92.     pcvar_fast_damage_arms=register_cvar("dinfinity_fast_damage_arms", "30")
    93.     pcvar_fast_damage_legs=register_cvar("dinfinity_fast_damage_legs", "30")   
    94.    
    95.     ReadSettings()
    96.    
    97.     RegisterHam(Ham_Item_AddToPlayer, g_weapon_entity, "fwAddToPlayer", 1)
    98.     RegisterHam(Ham_Item_Deploy, g_weapon_entity, "fwDeployPost", 1)
    99.     RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon_entity, "fwPrimaryAttack")
    100.     RegisterHam(Ham_Weapon_Reload, g_weapon_entity, "fwReloadPre")
    101.     RegisterHam(Ham_Item_PostFrame, g_weapon_entity, "fwItemPostFrame"