horse gun

Unpaid Requests, Public Plugins
Post Reply
User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

horse gun

#1

Post by Luxurious » 5 years ago

i tried to convert this Extra-item to ze but i got this problem , Pls Help!

//// azp_weapon_Horse_gun.sma
//
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(129) : error 017: undefined symbol "g_itemid"
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(213) : warning 233: symbol "client_disconnect" is marked as deprecated: Use client_disconnected() instead.
//
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(219) : error 017: undefined symbol "zp_get_user_zombie"
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(227) : error 017: undefined symbol "is_valid_ent"
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : error 017: undefined symbol "entity_get_string"
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : warning 215: expression has no effect
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : warning 215: expression has no effect
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : error 001: expected token: ";", but found ")"
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : error 029: invalid expression, assumed zero
// C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\azp_weapon_Horse_gun.sma(231) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 7 Errors.
// Could not locate output file C:\Users\ana_m\Desktop\addons\Compiler v1.8.3\scripting\compiled\azp_weapon_Horse_gun.amx (compile failed).
//

Code: Select all

#include <zombie_escape>
#include <cstrike>
#include <fun>


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

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 horsegun_RELOAD_TIME 	3.6
#define horsegun_RELOAD			1
#define horsegun_DRAW			2
#define horsegun_SHOOT1			3
#define horsegun_SHOOT2			4

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

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

new horsegun_V_MODEL[64] = "models/horse/v_horsegun.mdl"
new horsegun_P_MODEL[64] = "models/horse/p_horsegun.mdl"
new horsegun_W_MODEL[64] = "models/horse/w_horsegun.mdl"

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

new cvar_dmg_horsegun, cvar_recoil_horsegun, g_itemid_horsegun, cvar_clip_horsegun, cvar_spd_horsegun, cvar_horsegun_ammo
new g_MaxPlayers, g_orig_event_horsegun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_horsegun[33], g_clip_ammo[33], g_horsegun_TmpClip[33], oldweap[33]
new gmsgWeaponList

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("[ZP] Extra: [CSO]Horsegun", "1.0","")
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mac10", "fw_horsegun_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_mac10", "fw_horsegun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mac10", "fw_horsegun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mac10", "horsegun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mac10", "horsegun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mac10", "horsegun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	register_forward(FM_SetModel, "fw_SetModel")
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)

	cvar_dmg_horsegun = register_cvar("zp_horsegun_dmg", "1.0")
	cvar_recoil_horsegun = register_cvar("zp_horsegun_recoil", "0.7")
	cvar_clip_horsegun = register_cvar("zp_horsegun_clip", "20")
	cvar_spd_horsegun = register_cvar("zp_horsegun_spd", "1.2")
	cvar_horsegun_ammo = register_cvar("zp_horsegun_ammo", "100")
	
	g_itemid_horsegun = ze_register_item("[Automat] \r[CSO]Horsegun", 0, 0)
	g_MaxPlayers = get_maxplayers()
	gmsgWeaponList = get_user_msgid("WeaponList")
}

public plugin_precache()
{
	precache_model(horsegun_V_MODEL)
	precache_model(horsegun_P_MODEL)
	precache_model(horsegun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds[i])	
	precache_sound("weapons/horsegun_clipin.wav")
	precache_sound("weapons/horsegun_clipout.wav")
	precache_sound("weapons/horsegun_draw.wav")
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	precache_generic("sprites/weapon_horsegun.txt")
    	precache_generic("sprites/horse/640hud103.spr")
    	precache_generic("sprites/horse/640hud7.spr")
	
        register_clcmd("weapon_horsegun", "weapon_hook")	

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

public weapon_hook(id)
{
    	engclient_cmd(id, "weapon_mac10")
    	return PLUGIN_HANDLED
}

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 fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
	if(!is_user_alive(iAttacker))
		return

	new g_currentweapon = get_user_weapon(iAttacker)

	if(g_currentweapon != CSW_MAC10) return
	
	if(!g_has_horsegun[iAttacker]) return

	static Float:flEnd[3]
	get_tr2(ptr, TR_vecEndPos, flEnd)
	
	if(iEnt)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_DECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		write_short(iEnt)
		message_end()
	}
	else
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		message_end()
	}
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_GUNSHOTDECAL)
	write_coord_f(flEnd[0])
	write_coord_f(flEnd[1])
	write_coord_f(flEnd[2])
	write_short(iAttacker)
	write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
	message_end()
}

public zp_user_humanized_post(id)
{
	g_has_horsegun[id] = false
}

public plugin_natives ()
{
	register_native("give_weapon_horsegun", "native_give_weapon_add", 1)
}
public native_give_weapon_add(id)
{
	give_horsegun(id)
}

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

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

public client_disconnect(id)
{
	g_has_horsegun[id] = false
}

public ze_user_infected(id, iInfector)
{
	if (zp_get_user_zombie(id))
	{
		g_has_horsegun[id] = false
	}
}

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_mac10.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mac10", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_horsegun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, horsegun_WEAPONKEY)
			
			g_has_horsegun[iOwner] = false
			
			entity_set_model(entity, horsegun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public give_horsegun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mac10")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_horsegun))
		cs_set_user_bpammo (id, CSW_MAC10, get_pcvar_num(cvar_horsegun_ammo))	
		UTIL_PlayWeaponAnimation(id, horsegun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)

		message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
		write_string("weapon_horsegun")
		write_byte(6)
		write_byte(100)
		write_byte(-1)
		write_byte(-1)
		write_byte(0)
		write_byte(13)
		write_byte(CSW_MAC10)
		message_end()
	}
	g_has_horsegun[id] = true
}

public zp_extra_item_selected(id, itemid)
{
	if(itemid != g_itemid_horsegun)
		return

	give_horsegun(id)
}

public fw_horsegun_AddToPlayer(horsegun, id)
{
	if(!is_valid_ent(horsegun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(horsegun, EV_INT_WEAPONKEY) == horsegun_WEAPONKEY)
	{
		g_has_horsegun[id] = true
		
		entity_set_int(horsegun, EV_INT_WEAPONKEY, 0)

		message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
		write_string("weapon_horsegun")
		write_byte(6)
		write_byte(100)
		write_byte(-1)
		write_byte(-1)
		write_byte(0)
		write_byte(13)
		write_byte(CSW_MAC10)
		message_end()
		
		return HAM_HANDLED
	}
	else
	{
		message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
		write_string("weapon_mac10")
		write_byte(6)
		write_byte(100)
		write_byte(-1)
		write_byte(-1)
		write_byte(0)
		write_byte(13)
		write_byte(CSW_MAC10)
		message_end()
	}
	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_MAC10 || !g_has_horsegun[id])
          return
     
     static Float:iSpeed
     if(g_has_horsegun[id])
          iSpeed = get_pcvar_float(cvar_spd_horsegun)
     
     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_MAC10:
		{
			if (ze_is_user_zombie(id) || zp_get_user_survivor(id))
				return
			
			if(g_has_horsegun[id])
			{
				set_pev(id, pev_viewmodel2, horsegun_V_MODEL)
				set_pev(id, pev_weaponmodel2, horsegun_P_MODEL)
				if(oldweap[id] != CSW_MAC10) 
				{
					UTIL_PlayWeaponAnimation(id, horsegun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)

					message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
					write_string("weapon_horsegun")
					write_byte(6)
					write_byte(100)
					write_byte(-1)
					write_byte(-1)
					write_byte(0)
					write_byte(13)
					write_byte(CSW_MAC10)
					message_end()
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

public fw_horsegun_PrimaryAttack(Weapon)
{
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	if (!g_has_horsegun[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_horsegun) || !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_horsegun_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_horsegun[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_horsegun),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(horsegun_SHOOT1, horsegun_SHOOT2))
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MAC10)
		{
			if(g_has_horsegun[attacker])
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_horsegun))
		}
	}
}

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, "mac10") && get_user_weapon(iAttacker) == CSW_MAC10)
	{
		if(g_has_horsegun[iAttacker])
			set_msg_arg_string(4, "unknown")
	}
	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 horsegun_ItemPostFrame(weapon_entity) 
{
     new id = pev(weapon_entity, pev_owner)
     if (!is_user_connected(id))
          return HAM_IGNORED

     if (!g_has_horsegun[id])
          return HAM_IGNORED

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

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MAC10)
     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_MAC10, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

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

     if (!g_has_horsegun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_horsegun[id])
          iClipExtra = get_pcvar_num(cvar_clip_horsegun)

     g_horsegun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MAC10)
     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_horsegun_TmpClip[id] = iClip

     return HAM_IGNORED
}

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

	if (!g_has_horsegun[id])
		return HAM_IGNORED

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

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

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, horsegun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, horsegun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, horsegun_RELOAD)

	return HAM_IGNORED
}

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)
          }
     }
}
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 5 years ago

  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <fun>
  4. #include <engine>
  5. #include <xs>
  6.  
  7. #define ENG_NULLENT         -1
  8. #define EV_INT_WEAPONKEY    EV_INT_impulse
  9. #define horsegun_WEAPONKEY  860
  10. #define MAX_PLAYERS         32
  11. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  12.  
  13. const USE_STOPPED = 0
  14. const OFFSET_ACTIVE_ITEM = 373
  15. const OFFSET_WEAPONOWNER = 41
  16. const OFFSET_LINUX = 5
  17. const OFFSET_LINUX_WEAPONS = 4
  18.  
  19. #define WEAP_LINUX_XTRA_OFF     4
  20. #define m_fKnown                    44
  21. #define m_flNextPrimaryAttack       46
  22. #define m_flTimeWeaponIdle          48
  23. #define m_iClip                 51
  24. #define m_fInReload             54
  25. #define PLAYER_LINUX_XTRA_OFF   5
  26. #define m_flNextAttack              83
  27.  
  28. #define horsegun_RELOAD_TIME    3.6
  29. #define horsegun_RELOAD         1
  30. #define horsegun_DRAW           2
  31. #define horsegun_SHOOT1         3
  32. #define horsegun_SHOOT2         4
  33.  
  34. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  35.  
  36. new const Fire_Sounds[][] = { "weapons/mp7.wav" }
  37.  
  38. new horsegun_V_MODEL[64] = "models/horse/v_horsegun.mdl"
  39. new horsegun_P_MODEL[64] = "models/horse/p_horsegun.mdl"
  40. new horsegun_W_MODEL[64] = "models/horse/w_horsegun.mdl"
  41.  
  42. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  43.  
  44. new cvar_dmg_horsegun, cvar_recoil_horsegun, g_itemid_horsegun, cvar_clip_horsegun, cvar_spd_horsegun, cvar_horsegun_ammo
  45. new g_MaxPlayers, g_orig_event_horsegun, g_IsInPrimaryAttack
  46. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
  47. new g_has_horsegun[33], g_clip_ammo[33], g_horsegun_TmpClip[33], oldweap[33]
  48. new gmsgWeaponList
  49.  
  50. const PRIMARY_WEAPONS_BIT_SUM =
  51. (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<<
  52. 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)
  53. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  54.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  55.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  56.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  57.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  58.  
  59. public plugin_init()
  60. {
  61.     register_plugin("[ZE] Extra: [CSO]Horsegun", "1.0","")
  62.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  63.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  64.     RegisterHam(Ham_Item_AddToPlayer, "weapon_mac10", "fw_horsegun_AddToPlayer")
  65.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  66.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  67.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  68.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  69.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  70.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  71.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mac10", "fw_horsegun_PrimaryAttack")
  72.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mac10", "fw_horsegun_PrimaryAttack_Post", 1)
  73.     RegisterHam(Ham_Item_PostFrame, "weapon_mac10", "horsegun_ItemPostFrame")
  74.     RegisterHam(Ham_Weapon_Reload, "weapon_mac10", "horsegun_Reload")
  75.     RegisterHam(Ham_Weapon_Reload, "weapon_mac10", "horsegun_Reload_Post", 1)
  76.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  77.     register_forward(FM_SetModel, "fw_SetModel")
  78.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  79.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  80.    
  81.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  82.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  83.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  84.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  85.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  86.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  87.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  88.  
  89.     cvar_dmg_horsegun = register_cvar("ze_horsegun_dmg", "1.0")
  90.     cvar_recoil_horsegun = register_cvar("ze_horsegun_recoil", "0.7")
  91.     cvar_clip_horsegun = register_cvar("ze_horsegun_clip", "20")
  92.     cvar_spd_horsegun = register_cvar("ze_horsegun_spd", "1.2")
  93.     cvar_horsegun_ammo = register_cvar("ze_horsegun_ammo", "100")
  94.    
  95.     g_itemid_horsegun = ze_register_item("[Automat] \r[CSO]Horsegun", 0, 0)
  96.     g_MaxPlayers = get_maxplayers()
  97.     gmsgWeaponList = get_user_msgid("WeaponList")
  98. }
  99.  
  100. public plugin_precache()
  101. {
  102.     precache_model(horsegun_V_MODEL)
  103.     precache_model(horsegun_P_MODEL)
  104.     precache_model(horsegun_W_MODEL)
  105.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  106.     precache_sound(Fire_Sounds[i]) 
  107.     precache_sound("weapons/horsegun_clipin.wav")
  108.     precache_sound("weapons/horsegun_clipout.wav")
  109.     precache_sound("weapons/horsegun_draw.wav")
  110.     m_iBlood[0] = precache_model("sprites/blood.spr")
  111.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  112.     precache_generic("sprites/weapon_horsegun.txt")
  113.         precache_generic("sprites/horse/640hud103.spr")
  114.         precache_generic("sprites/horse/640hud7.spr")
  115.    
  116.         register_clcmd("weapon_horsegun", "weapon_hook")   
  117.  
  118.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  119. }
  120.  
  121. public weapon_hook(id)
  122. {
  123.         engclient_cmd(id, "weapon_mac10")
  124.         return PLUGIN_HANDLED
  125. }
  126.  
  127. public ze_select_item_pre(id, itemid)
  128. {
  129.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  130.     if (itemid != g_itemid_horsegun)
  131.         return ZE_ITEM_AVAILABLE
  132.    
  133.     // Available for Humans only, So don't show it for zombies
  134.     if (ze_is_user_zombie(id))
  135.         return ZE_ITEM_DONT_SHOW
  136.    
  137.     return ZE_ITEM_AVAILABLE
  138. }
  139.  
  140. public ze_select_item_post(player, itemid)
  141. {
  142.     if (itemid != g_itemid_horsegun)
  143.         return
  144.    
  145.     give_horsegun(player)
  146. }
  147.  
  148. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  149. {
  150.     if(!is_user_alive(iAttacker))
  151.         return
  152.  
  153.     new g_currentweapon = get_user_weapon(iAttacker)
  154.  
  155.     if(g_currentweapon != CSW_MAC10) return
  156.    
  157.     if(!g_has_horsegun[iAttacker]) return
  158.  
  159.     static Float:flEnd[3]
  160.     get_tr2(ptr, TR_vecEndPos, flEnd)
  161.    
  162.     if(iEnt)
  163.     {
  164.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  165.         write_byte(TE_DECAL)
  166.         write_coord_f(flEnd[0])
  167.         write_coord_f(flEnd[1])
  168.         write_coord_f(flEnd[2])
  169.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  170.         write_short(iEnt)
  171.         message_end()
  172.     }
  173.     else
  174.     {
  175.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  176.         write_byte(TE_WORLDDECAL)
  177.         write_coord_f(flEnd[0])
  178.         write_coord_f(flEnd[1])
  179.         write_coord_f(flEnd[2])
  180.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  181.         message_end()
  182.     }
  183.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  184.     write_byte(TE_GUNSHOTDECAL)
  185.     write_coord_f(flEnd[0])
  186.     write_coord_f(flEnd[1])
  187.     write_coord_f(flEnd[2])
  188.     write_short(iAttacker)
  189.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  190.     message_end()
  191. }
  192.  
  193. public ze_user_humanized(id)
  194. {
  195.     g_has_horsegun[id] = false
  196. }
  197.  
  198. public plugin_natives ()
  199. {
  200.     register_native("give_weapon_horsegun", "native_give_weapon_add", 1)
  201. }
  202.  
  203. public native_give_weapon_add(id)
  204. {
  205.     give_horsegun(id)
  206. }
  207.  
  208. public fwPrecacheEvent_Post(type, const name[])
  209. {
  210.     if (equal("events/mac10.sc", name))
  211.     {
  212.         g_orig_event_horsegun = get_orig_retval()
  213.         return FMRES_HANDLED
  214.     }
  215.     return FMRES_IGNORED
  216. }
  217.  
  218. public client_connect(id)
  219. {
  220.     g_has_horsegun[id] = false
  221. }
  222.  
  223. public client_disconnected(id)
  224. {
  225.     g_has_horsegun[id] = false
  226. }
  227.  
  228. public ze_user_infected(id, iInfector)
  229. {
  230.     if (ze_is_user_zombie(id))
  231.     {
  232.         g_has_horsegun[id] = false
  233.     }
  234. }
  235.  
  236. public fw_SetModel(entity, model[])
  237. {
  238.     if(!is_valid_ent(entity))
  239.         return FMRES_IGNORED
  240.    
  241.     static szClassName[33]
  242.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  243.        
  244.     if(!equal(szClassName, "weaponbox"))
  245.         return FMRES_IGNORED
  246.    
  247.     static iOwner
  248.    
  249.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  250.    
  251.     if(equal(model, "models/w_mac10.mdl"))
  252.     {
  253.         static iStoredAugID
  254.        
  255.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mac10", entity)
  256.    
  257.         if(!is_valid_ent(iStoredAugID))
  258.             return FMRES_IGNORED
  259.    
  260.         if(g_has_horsegun[iOwner])
  261.         {
  262.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, horsegun_WEAPONKEY)
  263.            
  264.             g_has_horsegun[iOwner] = false
  265.            
  266.             entity_set_model(entity, horsegun_W_MODEL)
  267.            
  268.             return FMRES_SUPERCEDE
  269.         }
  270.     }
  271.     return FMRES_IGNORED
  272. }
  273.  
  274. public give_horsegun(id)
  275. {
  276.     drop_weapons(id, 1)
  277.     new iWep2 = give_item(id,"weapon_mac10")
  278.     if( iWep2 > 0 )
  279.     {
  280.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_horsegun))
  281.         cs_set_user_bpammo (id, CSW_MAC10, get_pcvar_num(cvar_horsegun_ammo))  
  282.         UTIL_PlayWeaponAnimation(id, horsegun_DRAW)
  283.         set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  284.  
  285.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  286.         write_string("weapon_horsegun")
  287.         write_byte(6)
  288.         write_byte(100)
  289.         write_byte(-1)
  290.         write_byte(-1)
  291.         write_byte(0)
  292.         write_byte(13)
  293.         write_byte(CSW_MAC10)
  294.         message_end()
  295.     }
  296.     g_has_horsegun[id] = true
  297. }
  298.  
  299. public fw_horsegun_AddToPlayer(horsegun, id)
  300. {
  301.     if(!is_valid_ent(horsegun) || !is_user_connected(id))
  302.         return HAM_IGNORED
  303.    
  304.     if(entity_get_int(horsegun, EV_INT_WEAPONKEY) == horsegun_WEAPONKEY)
  305.     {
  306.         g_has_horsegun[id] = true
  307.        
  308.         entity_set_int(horsegun, EV_INT_WEAPONKEY, 0)
  309.  
  310.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  311.         write_string("weapon_horsegun")
  312.         write_byte(6)
  313.         write_byte(100)
  314.         write_byte(-1)
  315.         write_byte(-1)
  316.         write_byte(0)
  317.         write_byte(13)
  318.         write_byte(CSW_MAC10)
  319.         message_end()
  320.        
  321.         return HAM_HANDLED
  322.     }
  323.     else
  324.     {
  325.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  326.         write_string("weapon_mac10")
  327.         write_byte(6)
  328.         write_byte(100)
  329.         write_byte(-1)
  330.         write_byte(-1)
  331.         write_byte(0)
  332.         write_byte(13)
  333.         write_byte(CSW_MAC10)
  334.         message_end()
  335.     }
  336.     return HAM_IGNORED
  337. }
  338.  
  339. public fw_UseStationary_Post(entity, caller, activator, use_type)
  340. {
  341.     if (use_type == USE_STOPPED && is_user_connected(caller))
  342.         replace_weapon_models(caller, get_user_weapon(caller))
  343. }
  344.  
  345. public fw_Item_Deploy_Post(weapon_ent)
  346. {
  347.     static owner
  348.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  349.    
  350.     static weaponid
  351.     weaponid = cs_get_weapon_id(weapon_ent)
  352.    
  353.     replace_weapon_models(owner, weaponid)
  354. }
  355.  
  356. public CurrentWeapon(id)
  357. {
  358.      replace_weapon_models(id, read_data(2))
  359.  
  360.      if(read_data(2) != CSW_MAC10 || !g_has_horsegun[id])
  361.           return
  362.      
  363.      static Float:iSpeed
  364.      if(g_has_horsegun[id])
  365.           iSpeed = get_pcvar_float(cvar_spd_horsegun)
  366.      
  367.      static weapon[32],Ent
  368.      get_weaponname(read_data(2),weapon,31)
  369.      Ent = find_ent_by_owner(-1,weapon,id)
  370.      if(Ent)
  371.      {
  372.           static Float:Delay
  373.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  374.           if (Delay > 0.0)
  375.           {
  376.                set_pdata_float(Ent, 46, Delay, 4)
  377.           }
  378.      }
  379. }
  380.  
  381. replace_weapon_models(id, weaponid)
  382. {
  383.     switch (weaponid)
  384.     {
  385.         case CSW_MAC10:
  386.         {
  387.             if (ze_is_user_zombie(id))
  388.                 return
  389.            
  390.             if(g_has_horsegun[id])
  391.             {
  392.                 set_pev(id, pev_viewmodel2, horsegun_V_MODEL)
  393.                 set_pev(id, pev_weaponmodel2, horsegun_P_MODEL)
  394.                 if(oldweap[id] != CSW_MAC10)
  395.                 {
  396.                     UTIL_PlayWeaponAnimation(id, horsegun_DRAW)
  397.                     set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  398.  
  399.                     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  400.                     write_string("weapon_horsegun")
  401.                     write_byte(6)
  402.                     write_byte(100)
  403.                     write_byte(-1)
  404.                     write_byte(-1)
  405.                     write_byte(0)
  406.                     write_byte(13)
  407.                     write_byte(CSW_MAC10)
  408.                     message_end()
  409.                 }
  410.             }
  411.         }
  412.     }
  413.     oldweap[id] = weaponid
  414. }
  415.  
  416. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  417. {
  418.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_MAC10 || !g_has_horsegun[Player]))
  419.         return FMRES_IGNORED
  420.    
  421.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  422.     return FMRES_HANDLED
  423. }
  424.  
  425. public fw_horsegun_PrimaryAttack(Weapon)
  426. {
  427.     new Player = get_pdata_cbase(Weapon, 41, 4)
  428.    
  429.     if (!g_has_horsegun[Player])
  430.         return
  431.    
  432.     g_IsInPrimaryAttack = 1
  433.     pev(Player,pev_punchangle,cl_pushangle[Player])
  434.    
  435.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  436. }
  437.  
  438. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  439. {
  440.     if ((eventid != g_orig_event_horsegun) || !g_IsInPrimaryAttack)
  441.         return FMRES_IGNORED
  442.     if (!(1 <= invoker <= g_MaxPlayers))
  443.     return FMRES_IGNORED
  444.  
  445.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  446.     return FMRES_SUPERCEDE
  447. }
  448.  
  449. public fw_horsegun_PrimaryAttack_Post(Weapon)
  450. {
  451.     g_IsInPrimaryAttack = 0
  452.     new Player = get_pdata_cbase(Weapon, 41, 4)
  453.    
  454.     new szClip, szAmmo
  455.     get_user_weapon(Player, szClip, szAmmo)
  456.    
  457.     if(!is_user_alive(Player))
  458.         return
  459.  
  460.     if(g_has_horsegun[Player])
  461.     {
  462.         if (!g_clip_ammo[Player])
  463.             return
  464.  
  465.         new Float:push[3]
  466.         pev(Player,pev_punchangle,push)
  467.         xs_vec_sub(push,cl_pushangle[Player],push)
  468.        
  469.         xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_horsegun),push)
  470.         xs_vec_add(push,cl_pushangle[Player],push)
  471.         set_pev(Player,pev_punchangle,push)
  472.        
  473.         emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  474.         UTIL_PlayWeaponAnimation(Player, random_num(horsegun_SHOOT1, horsegun_SHOOT2))
  475.     }
  476. }
  477.  
  478. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  479. {
  480.     if (victim != attacker && is_user_connected(attacker))
  481.     {
  482.         if(get_user_weapon(attacker) == CSW_MAC10)
  483.         {
  484.             if(g_has_horsegun[attacker])
  485.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_horsegun))
  486.         }
  487.     }
  488. }
  489.  
  490. public message_DeathMsg(msg_id, msg_dest, id)
  491. {
  492.     static szTruncatedWeapon[33], iAttacker, iVictim
  493.    
  494.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  495.    
  496.     iAttacker = get_msg_arg_int(1)
  497.     iVictim = get_msg_arg_int(2)
  498.    
  499.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  500.         return PLUGIN_CONTINUE
  501.    
  502.     if(equal(szTruncatedWeapon, "mac10") && get_user_weapon(iAttacker) == CSW_MAC10)
  503.     {
  504.         if(g_has_horsegun[iAttacker])
  505.             set_msg_arg_string(4, "unknown")
  506.     }
  507.     return PLUGIN_CONTINUE
  508. }
  509.  
  510. stock fm_cs_get_current_weapon_ent(id)
  511. {
  512.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  513. }
  514.  
  515. stock fm_cs_get_weapon_ent_owner(ent)
  516. {
  517.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  518. }
  519.  
  520. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  521. {
  522.     set_pev(Player, pev_weaponanim, Sequence)
  523.    
  524.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  525.     write_byte(Sequence)
  526.     write_byte(pev(Player, pev_body))
  527.     message_end()
  528. }
  529.  
  530. public horsegun_ItemPostFrame(weapon_entity)
  531. {
  532.      new id = pev(weapon_entity, pev_owner)
  533.      if (!is_user_connected(id))
  534.           return HAM_IGNORED
  535.  
  536.      if (!g_has_horsegun[id])
  537.           return HAM_IGNORED
  538.  
  539.      static iClipExtra
  540.      
  541.      iClipExtra = get_pcvar_num(cvar_clip_horsegun)
  542.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  543.  
  544.      new iBpAmmo = cs_get_user_bpammo(id, CSW_MAC10)
  545.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  546.  
  547.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  548.  
  549.      if( fInReload && flNextAttack <= 0.0 )
  550.      {
  551.          new j = min(iClipExtra - iClip, iBpAmmo)
  552.    
  553.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  554.          cs_set_user_bpammo(id, CSW_MAC10, iBpAmmo-j)
  555.        
  556.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  557.          fInReload = 0
  558.      }
  559.      return HAM_IGNORED
  560. }
  561.  
  562. public horsegun_Reload(weapon_entity)
  563. {
  564.      new id = pev(weapon_entity, pev_owner)
  565.      if (!is_user_connected(id))
  566.           return HAM_IGNORED
  567.  
  568.      if (!g_has_horsegun[id])
  569.           return HAM_IGNORED
  570.  
  571.      static iClipExtra
  572.  
  573.      if(g_has_horsegun[id])
  574.           iClipExtra = get_pcvar_num(cvar_clip_horsegun)
  575.  
  576.      g_horsegun_TmpClip[id] = -1
  577.  
  578.      new iBpAmmo = cs_get_user_bpammo(id, CSW_MAC10)
  579.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  580.  
  581.      if (iBpAmmo <= 0)
  582.           return HAM_SUPERCEDE
  583.  
  584.      if (iClip >= iClipExtra)
  585.           return HAM_SUPERCEDE
  586.  
  587.      g_horsegun_TmpClip[id] = iClip
  588.  
  589.      return HAM_IGNORED
  590. }
  591.  
  592. public horsegun_Reload_Post(weapon_entity)
  593. {
  594.     new id = pev(weapon_entity, pev_owner)
  595.     if (!is_user_connected(id))
  596.         return HAM_IGNORED
  597.  
  598.     if (!g_has_horsegun[id])
  599.         return HAM_IGNORED
  600.  
  601.     if (g_horsegun_TmpClip[id] == -1)
  602.         return HAM_IGNORED
  603.  
  604.     set_pdata_int(weapon_entity, m_iClip, g_horsegun_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  605.  
  606.     set_pdata_float(weapon_entity, m_flTimeWeaponIdle, horsegun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  607.  
  608.     set_pdata_float(id, m_flNextAttack, horsegun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  609.  
  610.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  611.  
  612.     UTIL_PlayWeaponAnimation(id, horsegun_RELOAD)
  613.  
  614.     return HAM_IGNORED
  615. }
  616.  
  617. stock drop_weapons(id, dropwhat)
  618. {
  619.      static weapons[32], num, i, weaponid
  620.      num = 0
  621.      get_user_weapons(id, weapons, num)
  622.      
  623.      for (i = 0; i < num; i++)
  624.      {
  625.           weaponid = weapons[i]
  626.          
  627.           if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  628.           {
  629.                static wname[32]
  630.                get_weaponname(weaponid, wname, sizeof wname - 1)
  631.                engclient_cmd(id, "drop", wname)
  632.           }
  633.      }
  634. }
He who fails to plan is planning to fail

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#3

Post by Luxurious » 5 years ago

can u tell me what was problem ?
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 5 years ago

1. You was missing these includes: 2. You don't add:
    1. public ze_select_item_post(player, itemid)
    2. {
    3.     if (itemid != g_itemid_horsegun)
    4.         return
    5.    
    6.     give_horsegun(player)
    7. }
3. You forget to edit zp_user_humanized_post(id) to ze_user_humanized(id)

4. Forget to change every zp_get_user_zombie to ze_is_user_zombie

5. Extra is to replace client_disconnect(id) with client_disconnected(id)

I think this was all you missed.
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 1 guest