add native

Unpaid Requests, Public Plugins
Post Reply
Luxurious
Member
Member
Egypt
Posts: 89
Joined: 10 Months Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

add native

#1

Post by Luxurious » 1 Week 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
Bosnia & Herzegovina
Posts: 144
Joined: 1 Year Ago
Has thanked: 12 times
Been thanked: 2 times
Age: 19
Contact:

#2

Post by sPe3doN » 1 Week 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
Member
Member
Egypt
Posts: 89
Joined: 10 Months Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#3

Post by Luxurious » 1 Week Ago

sPe3doN wrote:
1 Week 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
Bosnia & Herzegovina
Posts: 144
Joined: 1 Year Ago
Has thanked: 12 times
Been thanked: 2 times
Age: 19
Contact:

#4

Post by sPe3doN » 1 Week Ago

Luxurious wrote:
1 Week Ago
sPe3doN wrote:
1 Week 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
Member
Member
Egypt
Posts: 89
Joined: 10 Months Ago
Location: Egypt
Has thanked: 2 times
Been thanked: 1 time
Contact:

#5

Post by Luxurious » 1 Week Ago

sPe3doN wrote:
1 Week Ago
Luxurious wrote:
1 Week Ago
sPe3doN wrote:
1 Week 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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests