[ZE] Extra Item Convert

Unpaid Requests, Public Plugins
Post Reply
User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 2 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

[ZE] Extra Item Convert

#1

Post by tmv » 2 Months Ago

I Converted this ZP Extra Item to a ZE. Please check if I have done this correctly and no bug will occur in my server. Next problem is When i converted the extra item to ZE all of them have no recoil . how can i fix it?

Code: Select all

#include <amxmodx>
#include <engine>
#include <fakemeta_util>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <zombie_escape>

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

#define Reload_Time	1.0
#define Reload_Time7	1.4
#define CROW_Time7	1.5
#define Normal_Time7	3.3

#define	CSW_CROW7	CSW_M249
#define	weapon_crow7	"weapon_m249"
#define	oldevent_crow7	"events/m249.sc"
#define	oldmodel_crow7 	"models/w_m249.mdl"

#define CROW7_V_Model 	"models/v_crow7.mdl"
#define CROW7_P_Model 	"models/p_crow7.mdl"
#define CROW7_W_Model 	"models/w_crow7.mdl"
#define C7_Fire_Sound 	"weapons/crow7-1.wav"

#define	CROW7_NAME "CROW-7"
#define	CROW7_COST	22
#define CROW7_CLIP 100
#define CROW7_AMMO 200
#define CROW7_RECOIL 1.0
#define CROW7_DAMAGE 1.0

new mode[33]
enum
{
	reloading = 0,
	normal,
	crow
}

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

//CROW-7
new g_has_crow7[33], g_event_crow7, g_crow7_zoom[33], Float:g_flNextUseTime[33]

new g_isprimary, Float:recoil[33], g_crow7
new g_clip_ammo[33], g_clip[33], oldweap[33]

public plugin_init()
{
	register_plugin("[Weapon]: CROW Weapons [Beta Version]", "1.0", "YunusReyiz")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	
	register_forward(FM_SetModel, "SetModel")
	register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "PlaybackEvent")
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
	RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
	
	RegisterHam(Ham_Item_AddToPlayer, weapon_crow7, "AddToPlayer")
	
	RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload7")
	RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload_Post7", 1)
	
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack7")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack_Post7", 1)
	
	RegisterHam(Ham_Item_PostFrame, weapon_crow7, "ItemPostFrame7")
	
	RegisterHam(Ham_Item_Holster, weapon_crow7, "HolsterPost", 1)
	
	g_crow7 = ze_register_item(CROW7_NAME, CROW7_COST, ZE_TEAM_HUMAN)
	register_forward(FM_CmdStart, "CmdStart")
}

public plugin_precache()
{	
	precache_model(CROW7_V_Model)
	precache_model(CROW7_P_Model)
	precache_model(CROW7_W_Model)
	precache_sound(C7_Fire_Sound)
	
	register_forward(FM_PrecacheEvent, "PrecacheEvent_Post", 1)
}

public ze_select_item_post(id, itemid)
{
	if(itemid == g_crow7) 
		give_crow7(id)
}

public ze_user_humanized_post(id)
{
	client_connect(id)
}
public ze_user_infected(id, iInfector)
{
	client_connect(id)
}


public TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
{
	if(!is_user_alive(attacker))
		return

	new g_currentweapon = get_user_weapon(attacker)

	if((g_currentweapon != CSW_CROW7) 
	|| (g_currentweapon == CSW_CROW7 && !g_has_crow7[attacker])) return;
	static Float:flEnd[3]
	get_tr2(ptr, TR_vecEndPos, flEnd)
	
	if(ent)
	{
		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(ent)
		message_end()
	}
	else
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		write_coord_f(flEnd[0])
		write_coord_f(flEnd[1])
		write_coord_f(flEnd[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		message_end()
	}
	if(g_has_crow7[attacker])
	{
		SetHamParamFloat(3, Damage * CROW7_DAMAGE)
	}
	
	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(attacker)
	write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
	message_end()
}

public PrecacheEvent_Post(type, const name[])
{
	if (equal(oldevent_crow7, name)) g_event_crow7 = get_orig_retval()
}

public client_connect(id)
{
	g_crow7_zoom[id] = 0
	g_has_crow7[id] = 0
}

public CmdStart(id, uc_handle, seed)
{
	if(!g_has_crow7[id])
		return

	if(!is_user_alive(id))
		return
		
	new iButtons = get_uc(uc_handle, UC_Buttons)

	if((iButtons & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
	{
		new szClip, szAmmo
		new szWeapID = get_user_weapon(id, szClip, szAmmo)
		
		if(szWeapID == CSW_CROW7 && g_has_crow7[id] && !g_crow7_zoom[id] == true)
		{
			g_crow7_zoom[id] = 1
			cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
			emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
		}
		else if(szWeapID == CSW_CROW7 && g_has_crow7[id] && g_crow7_zoom[id])
		{
				g_crow7_zoom[id] = false
				cs_set_user_zoom(id, CS_RESET_ZOOM, 0)	
		}
	}
}

public SetModel(ent, model[])
{
	if(!is_valid_ent(ent))
		return FMRES_IGNORED
	
	static szcn[33]
	entity_get_string(ent, EV_SZ_classname, szcn, charsmax(szcn))
		
	if(!equal(szcn, "weaponbox"))
		return FMRES_IGNORED
	
	static own
	
	own = entity_get_edict(ent, EV_ENT_owner)
	//CROW-7 w_model
	if(equal(model, oldmodel_crow7))
	{
		static id
		
		id = find_ent_by_owner(-1, weapon_crow7, ent)
	
		if(!is_valid_ent(id))
			return FMRES_IGNORED
	
		if(g_has_crow7[own])
		{
			entity_set_int(id, EV_INT_impulse, 3315784)
			
			g_has_crow7[own] = false
			
			entity_set_model(ent, CROW7_W_Model)
			
			return FMRES_SUPERCEDE
		}
	}

	return FMRES_IGNORED
}

//Added CROW-7
public give_crow7(id)
{
	new iWep2 = give_item(id, weapon_crow7)
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, CROW7_CLIP)
		cs_set_user_bpammo (id, CSW_CROW7, CROW7_AMMO)	
		set_anim(id, 6)
		set_pdata_float(id, 83, 1.0, 5)
	}
	g_has_crow7[id] = true
}

public AddToPlayer(ent, id)
{
	if(!is_valid_ent(ent) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(ent, EV_INT_impulse) == 3315784)
	{
		g_has_crow7[id] = true
		
		entity_set_int(ent, EV_INT_impulse, 0)
	}

	return HAM_IGNORED
}

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

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_CROW7:
		{
			if (ze_is_user_zombie(id))
				return
			if(g_has_crow7[id])
			{
				set_pev(id, pev_viewmodel2, CROW7_V_Model)
				set_pev(id, pev_weaponmodel2, CROW7_P_Model)
				if(oldweap[id] != CSW_CROW7) 
				{
					set_anim(id, 6)
					set_pdata_float(id, 83, 1.0, 5)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

public UpdateClientData_Post(id, SendWeapons, CD_Handle)
{
	//if(!is_user_alive(id) || (get_user_weapon(id) != CSW_CROW1 || !g_has_crow1[id]))
	if(!is_user_alive(id) 
	|| ((get_user_weapon(id) != CSW_CROW7) 
	|| (get_user_weapon(id) == CSW_CROW7 && !g_has_crow7[id])))
		return FMRES_IGNORED
	
	set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
	return FMRES_HANDLED
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_event_crow7) || !g_isprimary)
		return FMRES_IGNORED
	if (!(1 <= invoker <= get_maxplayers()))
	return FMRES_IGNORED

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

//CROW-7 PrimaryAttack and Post

public PrimaryAttack7(id)
{
	new ent = get_pdata_cbase(id, 41, 4)
	
	if (!g_has_crow7[ent])
		return
	
	g_isprimary = 1
	
	g_clip_ammo[ent] = cs_get_weapon_ammo(id)

}

public PrimaryAttack_Post7(id)
{
	g_isprimary = 0
	new ent = get_pdata_cbase(id, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(ent, szClip, szAmmo)
	
	if(!is_user_alive(ent))
		return
		
	if(g_has_crow7[ent])
	{
		if (!g_clip_ammo[ent])
			return
		
		new Float:push[3]
		pev(ent,pev_punchangle,push)
		xs_vec_sub(push,recoil[ent],push)
		
		xs_vec_mul_scalar(push,CROW7_RECOIL,push)
		xs_vec_add(push,recoil[ent],push)
		set_pev(ent,pev_punchangle,push)
		
		emit_sound(ent, CHAN_WEAPON, C7_Fire_Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		set_anim(ent, 1)
	}
}

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

public ItemPostFrame7(wpn, uc_handle) 
{
	new id = pev(wpn, pev_owner)
	if (!is_user_connected(id))
		return HAM_IGNORED

	if (!g_has_crow7[id])
		return HAM_IGNORED

	static iClipExtra
     
	iClipExtra = CROW7_CLIP
	new Float:flNextAttack = get_pdata_float(id, 83, 5)

	new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
	new iClip = get_pdata_int(wpn, 51, 4)

	new fInReload = get_pdata_int(wpn, 54, 4)
	
	if( fInReload && flNextAttack <= 0.0 )
	{	if(mode[id] == reloading && get_gametime() - Reload_Time && /*get_uc(uc_handle, UC_Buttons) & IN_RELOAD &&*/ (pev(id, pev_oldbuttons) & IN_RELOAD))
		{
			set_pdata_float(wpn, 48, CROW_Time7, 4)
			mode[id] = crow
			set_anim(id, 4)
			set_pdata_float(id, 83, CROW_Time7, 5)
			set_pdata_int(wpn, 51, g_clip[id], 4)

		}
		else if(mode[id] == reloading || get_gametime() - Reload_Time && !(pev(id, pev_oldbuttons) & IN_RELOAD))
		{
			set_pdata_float(wpn, 48, Normal_Time7, 4)

			mode[id] = normal
			set_anim(id, 5)
			set_pdata_float(id, 83, Normal_Time7, 5)
			set_pdata_int(wpn, 51, g_clip[id], 4)
		}
		new j = min(iClipExtra - iClip, iBpAmmo)

		set_pdata_int(wpn, 51, iClip + j, 4)
		cs_set_user_bpammo(id, CSW_CROW7, iBpAmmo-j)
		
		set_pdata_int(wpn, 54, 0, 4)

		fInReload = 0
		
	}
	return HAM_IGNORED
}

public Reload7(wpn) 
{
	new id = pev(wpn, pev_owner)
	if (!is_user_connected(id))
		return HAM_IGNORED

	if (!g_has_crow7[id])
		return HAM_IGNORED

	static iClipExtra

	iClipExtra = CROW7_CLIP

	g_clip[id] = -1
	
	new iClip = get_pdata_int(wpn, 51, 4)
	new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
		
	if (iBpAmmo <= 0)
		return HAM_SUPERCEDE

	if (iClip >= iClipExtra)
		return HAM_SUPERCEDE

	g_clip[id] = iClip

	return HAM_IGNORED
}

public Reload_Post7(wpn) 
{
	new id = pev(wpn, pev_owner)
	if (!is_user_connected(id))
		return HAM_IGNORED

	if (!g_has_crow7[id])
		return HAM_IGNORED

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

	mode[id] = reloading
	g_crow7_zoom[id] = 0
	cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
	
	set_pdata_float(wpn, 48, Reload_Time7, 4)
	set_pdata_float(id, 83, Reload_Time7, 5)

	set_pdata_int(wpn, 51, g_clip[id], 4)
	set_pdata_int(wpn, 54, 1, 4)

	if(mode[id] == reloading) set_anim(id, 3)

	return HAM_IGNORED
}

public HolsterPost(wpn)
{
	static id
	id = get_pdata_cbase(wpn, 41, 4)
	
	g_flNextUseTime[id] = 0.0

	if(!g_has_crow7[id])
		return;

	if(g_has_crow7[id])
	{
		g_crow7_zoom[id] = 0
		cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
	}
}
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_crow7)
        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
}

//Plugin Coded by YunusReyiz..
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#2

Post by Muhammet20 » 2 Months Ago

have you tested in ZP before convert it?
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 2 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#3

Post by tmv » 2 Months Ago

No I haven't

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#4

Post by Raheem » 2 Months Ago

You may need to disable recoil code, to remove:
    1.         new Float:push[3]
    2.         pev(id,pev_punchangle,push)
    3.         xs_vec_sub(push,recoil[id],push)
    4.        
    5.         xs_vec_mul_scalar(push,CROW7_RECOIL,push)
    6.         xs_vec_add(push,recoil[id],push)
    7.         set_pev(id,pev_punchangle,push)
And code is fine, Try:
    1. #include <zombie_escape>
    2. #include <engine>
    3. #include <fakemeta_util>
    4. #include <fun>
    5. #include <xs>
    6. #include <cstrike>
    7.  
    8. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    9.  
    10. #define Reload_Time 1.0
    11. #define Reload_Time7    1.4
    12. #define CROW_Time7  1.5
    13. #define Normal_Time7    3.3
    14.  
    15. #define CSW_CROW7   CSW_M249
    16. #define weapon_crow7    "weapon_m249"
    17. #define oldevent_crow7  "events/m249.sc"
    18. #define oldmodel_crow7  "models/w_m249.mdl"
    19.  
    20. #define CROW7_V_Model   "models/v_crow7.mdl"
    21. #define CROW7_P_Model   "models/p_crow7.mdl"
    22. #define CROW7_W_Model   "models/w_crow7.mdl"
    23. #define C7_Fire_Sound   "weapons/crow7-1.wav"
    24.  
    25. #define CROW7_NAME "CROW-7"
    26. #define CROW7_COST  22
    27. #define CROW7_CLIP 100
    28. #define CROW7_AMMO 200
    29. #define CROW7_RECOIL 1.0
    30. #define CROW7_DAMAGE 1.0
    31.  
    32. new mode[33]
    33. enum
    34. {
    35.     reloading = 0,
    36.     normal,
    37.     crow
    38. }
    39.  
    40. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    41.  
    42. //CROW-7
    43. new g_has_crow7[33], g_event_crow7, g_crow7_zoom[33], Float:g_flNextUseTime[33]
    44.  
    45. new g_isprimary, Float:recoil[33], g_crow7
    46. new g_clip_ammo[33], g_clip[33], oldweap[33]
    47.  
    48. public plugin_init()
    49. {
    50.     register_plugin("[Weapon]: CROW Weapons [Beta Version]", "1.0", "YunusReyiz")
    51.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    52.    
    53.     register_forward(FM_SetModel, "SetModel")
    54.     register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
    55.     register_forward(FM_PlaybackEvent, "PlaybackEvent")
    56.    
    57.     RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
    58.     RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
    59.    
    60.     RegisterHam(Ham_Item_AddToPlayer, weapon_crow7, "AddToPlayer")
    61.    
    62.     RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload7")
    63.     RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload_Post7", 1)
    64.    
    65.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack7")
    66.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack_Post7", 1)
    67.    
    68.     RegisterHam(Ham_Item_PostFrame, weapon_crow7, "ItemPostFrame7")
    69.    
    70.     RegisterHam(Ham_Item_Holster, weapon_crow7, "HolsterPost", 1)
    71.    
    72.     g_crow7 = ze_register_item(CROW7_NAME, CROW7_COST, ZE_TEAM_HUMAN)
    73.     register_forward(FM_CmdStart, "CmdStart")
    74. }
    75.  
    76. public plugin_precache()
    77. {  
    78.     precache_model(CROW7_V_Model)
    79.     precache_model(CROW7_P_Model)
    80.     precache_model(CROW7_W_Model)
    81.     precache_sound(C7_Fire_Sound)
    82.    
    83.     register_forward(FM_PrecacheEvent, "PrecacheEvent_Post", 1)
    84. }
    85.  
    86. public ze_select_item_post(id, itemid)
    87. {
    88.     if(itemid == g_crow7)
    89.         give_crow7(id)
    90. }
    91.  
    92. public ze_user_humanized_post(id)
    93. {
    94.     client_connect(id)
    95. }
    96. public ze_user_infected(id, iInfector)
    97. {
    98.     client_connect(id)
    99. }
    100.  
    101. public TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
    102. {
    103.     if(!is_user_alive(attacker))
    104.         return
    105.  
    106.     new g_currentweapon = get_user_weapon(attacker)
    107.  
    108.     if((g_currentweapon != CSW_CROW7)
    109.     || (g_currentweapon == CSW_CROW7 && !g_has_crow7[attacker])) return;
    110.     static Float:flEnd[3]
    111.     get_tr2(ptr, TR_vecEndPos, flEnd)
    112.    
    113.     if(ent)
    114.     {
    115.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    116.         write_byte(TE_DECAL)
    117.         write_coord_f(flEnd[0])
    118.         write_coord_f(flEnd[1])
    119.         write_coord_f(flEnd[2])
    120.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    121.         write_short(ent)
    122.         message_end()
    123.     }
    124.     else
    125.     {
    126.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    127.         write_byte(TE_WORLDDECAL)
    128.         write_coord_f(flEnd[0])
    129.         write_coord_f(flEnd[1])
    130.         write_coord_f(flEnd[2])
    131.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    132.         message_end()
    133.     }
    134.     if(g_has_crow7[attacker])
    135.     {
    136.         SetHamParamFloat(3, Damage * CROW7_DAMAGE)
    137.     }
    138.    
    139.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    140.     write_byte(TE_GUNSHOTDECAL)
    141.     write_coord_f(flEnd[0])
    142.     write_coord_f(flEnd[1])
    143.     write_coord_f(flEnd[2])
    144.     write_short(attacker)
    145.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    146.     message_end()
    147. }
    148.  
    149. public PrecacheEvent_Post(type, const name[])
    150. {
    151.     if (equal(oldevent_crow7, name)) g_event_crow7 = get_orig_retval()
    152. }
    153.  
    154. public client_connect(id)
    155. {
    156.     g_crow7_zoom[id] = 0
    157.     g_has_crow7[id] = 0
    158. }
    159.  
    160. public CmdStart(id, uc_handle, seed)
    161. {
    162.     if(!g_has_crow7[id])
    163.         return
    164.  
    165.     if(!is_user_alive(id))
    166.         return
    167.        
    168.     new iButtons = get_uc(uc_handle, UC_Buttons)
    169.  
    170.     if((iButtons & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
    171.     {
    172.         new szClip, szAmmo
    173.         new szWeapID = get_user_weapon(id, szClip, szAmmo)
    174.        
    175.         if(szWeapID == CSW_CROW7 && g_has_crow7[id] && !g_crow7_zoom[id] == true)
    176.         {
    177.             g_crow7_zoom[id] = 1
    178.             cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
    179.             emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
    180.         }
    181.         else if(szWeapID == CSW_CROW7 && g_has_crow7[id] && g_crow7_zoom[id])
    182.         {
    183.                 g_crow7_zoom[id] = false
    184.                 cs_set_user_zoom(id, CS_RESET_ZOOM, 0) 
    185.         }
    186.     }
    187. }
    188.  
    189. public SetModel(ent, model[])
    190. {
    191.     if(!is_valid_ent(ent))
    192.         return FMRES_IGNORED
    193.    
    194.     static szcn[33]
    195.     entity_get_string(ent, EV_SZ_classname, szcn, charsmax(szcn))
    196.        
    197.     if(!equal(szcn, "weaponbox"))
    198.         return FMRES_IGNORED
    199.    
    200.     static own
    201.    
    202.     own = entity_get_edict(ent, EV_ENT_owner)
    203.     //CROW-7 w_model
    204.     if(equal(model, oldmodel_crow7))
    205.     {
    206.         static id
    207.        
    208.         id = find_ent_by_owner(-1, weapon_crow7, ent)
    209.    
    210.         if(!is_valid_ent(id))
    211.             return FMRES_IGNORED
    212.    
    213.         if(g_has_crow7[own])
    214.         {
    215.             entity_set_int(id, EV_INT_impulse, 3315784)
    216.            
    217.             g_has_crow7[own] = false
    218.            
    219.             entity_set_model(ent, CROW7_W_Model)
    220.            
    221.             return FMRES_SUPERCEDE
    222.         }
    223.     }
    224.  
    225.     return FMRES_IGNORED
    226. }
    227.  
    228. //Added CROW-7
    229. public give_crow7(id)
    230. {
    231.     new iWep2 = give_item(id, weapon_crow7)
    232.     if( iWep2 > 0 )
    233.     {
    234.         cs_set_weapon_ammo(iWep2, CROW7_CLIP)
    235.         cs_set_user_bpammo (id, CSW_CROW7, CROW7_AMMO) 
    236.         set_anim(id, 6)
    237.         set_pdata_float(id, 83, 1.0, 5)
    238.     }
    239.     g_has_crow7[id] = true
    240. }
    241.  
    242. public AddToPlayer(ent, id)
    243. {
    244.     if(!is_valid_ent(ent) || !is_user_connected(id))
    245.         return HAM_IGNORED
    246.    
    247.     if(entity_get_int(ent, EV_INT_impulse) == 3315784)
    248.     {
    249.         g_has_crow7[id] = true
    250.        
    251.         entity_set_int(ent, EV_INT_impulse, 0)
    252.     }
    253.  
    254.     return HAM_IGNORED
    255. }
    256.  
    257. public CurrentWeapon(id) replace_weapon_models(id, read_data(2))
    258.  
    259. replace_weapon_models(id, weaponid)
    260. {
    261.     switch (weaponid)
    262.     {
    263.         case CSW_CROW7:
    264.         {
    265.             if (ze_is_user_zombie(id))
    266.                 return
    267.             if(g_has_crow7[id])
    268.             {
    269.                 set_pev(id, pev_viewmodel2, CROW7_V_Model)
    270.                 set_pev(id, pev_weaponmodel2, CROW7_P_Model)
    271.                 if(oldweap[id] != CSW_CROW7)
    272.                 {
    273.                     set_anim(id, 6)
    274.                     set_pdata_float(id, 83, 1.0, 5)
    275.                 }
    276.             }
    277.         }
    278.     }
    279.     oldweap[id] = weaponid
    280. }
    281.  
    282. public UpdateClientData_Post(id, SendWeapons, CD_Handle)
    283. {
    284.     //if(!is_user_alive(id) || (get_user_weapon(id) != CSW_CROW1 || !g_has_crow1[id]))
    285.     if(!is_user_alive(id)
    286.     || ((get_user_weapon(id) != CSW_CROW7)
    287.     || (get_user_weapon(id) == CSW_CROW7 && !g_has_crow7[id])))
    288.         return FMRES_IGNORED
    289.    
    290.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    291.     return FMRES_HANDLED
    292. }
    293.  
    294. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    295. {
    296.     if ((eventid != g_event_crow7) || !g_isprimary)
    297.         return FMRES_IGNORED
    298.     if (!(1 <= invoker <= get_maxplayers()))
    299.     return FMRES_IGNORED
    300.  
    301.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    302.     return FMRES_SUPERCEDE
    303. }
    304.  
    305. //CROW-7 PrimaryAttack and Post
    306.  
    307. public PrimaryAttack7(id)
    308. {
    309.     new ent = get_pdata_cbase(id, 41, 4)
    310.    
    311.     if (!g_has_crow7[ent])
    312.         return
    313.    
    314.     g_isprimary = 1
    315.    
    316.     g_clip_ammo[ent] = cs_get_weapon_ammo(id)
    317.  
    318. }
    319.  
    320. public PrimaryAttack_Post7(ent)
    321. {
    322.     g_isprimary = 0
    323.     new id = get_pdata_cbase(ent, 41, 4)
    324.    
    325.     new szClip, szAmmo
    326.     get_user_weapon(id, szClip, szAmmo)
    327.    
    328.     if(!is_user_alive(id))
    329.         return
    330.        
    331.     if(g_has_crow7[id])
    332.     {
    333.         if (!g_clip_ammo[id])
    334.             return
    335.        
    336.         /*new Float:push[3]
    337.         pev(id,pev_punchangle,push)
    338.         xs_vec_sub(push,recoil[id],push)
    339.        
    340.         xs_vec_mul_scalar(push,CROW7_RECOIL,push)
    341.         xs_vec_add(push,recoil[id],push)
    342.         set_pev(id,pev_punchangle,push)*/
    343.        
    344.         emit_sound(id, CHAN_WEAPON, C7_Fire_Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    345.         set_anim(id, 1)
    346.     }
    347. }
    348.  
    349. stock set_anim(const Player, const Sequence)
    350. {
    351.     set_pev(Player, pev_weaponanim, Sequence)
    352.    
    353.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    354.     write_byte(Sequence)
    355.     write_byte(pev(Player, pev_body))
    356.     message_end()
    357. }
    358.  
    359. public ItemPostFrame7(wpn, uc_handle)
    360. {
    361.     new id = pev(wpn, pev_owner)
    362.     if (!is_user_connected(id))
    363.         return HAM_IGNORED
    364.  
    365.     if (!g_has_crow7[id])
    366.         return HAM_IGNORED
    367.  
    368.     static iClipExtra
    369.      
    370.     iClipExtra = CROW7_CLIP
    371.     new Float:flNextAttack = get_pdata_float(id, 83, 5)
    372.  
    373.     new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
    374.     new iClip = get_pdata_int(wpn, 51, 4)
    375.  
    376.     new fInReload = get_pdata_int(wpn, 54, 4)
    377.    
    378.     if( fInReload && flNextAttack <= 0.0 )
    379.     {   if(mode[id] == reloading && get_gametime() - Reload_Time && /*get_uc(uc_handle, UC_Buttons) & IN_RELOAD &&*/ (pev(id, pev_oldbuttons) & IN_RELOAD))
    380.         {
    381.             set_pdata_float(wpn, 48, CROW_Time7, 4)
    382.             mode[id] = crow
    383.             set_anim(id, 4)
    384.             set_pdata_float(id, 83, CROW_Time7, 5)
    385.             set_pdata_int(wpn, 51, g_clip[id], 4)
    386.  
    387.         }
    388.         else if(mode[id] == reloading || get_gametime() - Reload_Time && !(pev(id, pev_oldbuttons) & IN_RELOAD))
    389.         {
    390.             set_pdata_float(wpn, 48, Normal_Time7, 4)
    391.  
    392.             mode[id] = normal
    393.             set_anim(id, 5)
    394.             set_pdata_float(id, 83, Normal_Time7, 5)
    395.             set_pdata_int(wpn, 51, g_clip[id], 4)
    396.         }
    397.         new j = min(iClipExtra - iClip, iBpAmmo)
    398.  
    399.         set_pdata_int(wpn, 51, iClip + j, 4)
    400.         cs_set_user_bpammo(id, CSW_CROW7, iBpAmmo-j)
    401.        
    402.         set_pdata_int(wpn, 54, 0, 4)
    403.  
    404.         fInReload = 0
    405.        
    406.     }
    407.     return HAM_IGNORED
    408. }
    409.  
    410. public Reload7(wpn)
    411. {
    412.     new id = pev(wpn, pev_owner)
    413.     if (!is_user_connected(id))
    414.         return HAM_IGNORED
    415.  
    416.     if (!g_has_crow7[id])
    417.         return HAM_IGNORED
    418.  
    419.     static iClipExtra
    420.  
    421.     iClipExtra = CROW7_CLIP
    422.  
    423.     g_clip[id] = -1
    424.    
    425.     new iClip = get_pdata_int(wpn, 51, 4)
    426.     new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
    427.        
    428.     if (iBpAmmo <= 0)
    429.         return HAM_SUPERCEDE
    430.  
    431.     if (iClip >= iClipExtra)
    432.         return HAM_SUPERCEDE
    433.  
    434.     g_clip[id] = iClip
    435.  
    436.     return HAM_IGNORED
    437. }
    438.  
    439. public Reload_Post7(wpn)
    440. {
    441.     new id = pev(wpn, pev_owner)
    442.     if (!is_user_connected(id))
    443.         return HAM_IGNORED
    444.  
    445.     if (!g_has_crow7[id])
    446.         return HAM_IGNORED
    447.  
    448.     if (g_clip[id] == -1)
    449.         return HAM_IGNORED
    450.  
    451.     mode[id] = reloading
    452.     g_crow7_zoom[id] = 0
    453.     cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
    454.    
    455.     set_pdata_float(wpn, 48, Reload_Time7, 4)
    456.     set_pdata_float(id, 83, Reload_Time7, 5)
    457.  
    458.     set_pdata_int(wpn, 51, g_clip[id], 4)
    459.     set_pdata_int(wpn, 54, 1, 4)
    460.  
    461.     if(mode[id] == reloading) set_anim(id, 3)
    462.  
    463.     return HAM_IGNORED
    464. }
    465.  
    466. public HolsterPost(wpn)
    467. {
    468.     static id
    469.     id = get_pdata_cbase(wpn, 41, 4)
    470.    
    471.     g_flNextUseTime[id] = 0.0
    472.  
    473.     if(!g_has_crow7[id])
    474.         return;
    475.  
    476.     if(g_has_crow7[id])
    477.     {
    478.         g_crow7_zoom[id] = 0
    479.         cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
    480.     }
    481. }
    482. public ze_select_item_pre(id, itemid)
    483. {
    484.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    485.     if (itemid != g_crow7)
    486.         return ZE_ITEM_AVAILABLE
    487.    
    488.     // Available for Humans only, So don't show it for zombies
    489.     if (ze_is_user_zombie(id))
    490.         return ZE_ITEM_DONT_SHOW
    491.    
    492.     return ZE_ITEM_AVAILABLE
    493. }
You don't know? Learn and you will know.

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 2 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#5

Post by tmv » 2 Months Ago

I tested it and it is still no recoil

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#6

Post by Raheem » 2 Months Ago

When you disable this item the recoil for weapons backs normally?
You don't know? Learn and you will know.

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 2 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#7

Post by tmv » 2 Months Ago

No other guns are ok only this gun doesn't have recoil

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#8

Post by Raheem » 2 Months Ago

I did not get you, your problem is that this item does not have recoil? And other extra-items are OK, right?
You don't know? Learn and you will know.

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 2 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#9

Post by tmv » 2 Months Ago

Yeah that's right

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#10

Post by Raheem » 2 Months Ago

You don't describe your problem right from beginning, Try:
    1. #include <zombie_escape>
    2. #include <engine>
    3. #include <fakemeta_util>
    4. #include <fun>
    5. #include <xs>
    6. #include <cstrike>
    7.  
    8. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    9.  
    10. #define Reload_Time 1.0
    11. #define Reload_Time7    1.4
    12. #define CROW_Time7  1.5
    13. #define Normal_Time7    3.3
    14.  
    15. #define CSW_CROW7   CSW_M249
    16. #define weapon_crow7    "weapon_m249"
    17. #define oldevent_crow7  "events/m249.sc"
    18. #define oldmodel_crow7  "models/w_m249.mdl"
    19.  
    20. #define CROW7_V_Model   "models/v_crow7.mdl"
    21. #define CROW7_P_Model   "models/p_crow7.mdl"
    22. #define CROW7_W_Model   "models/w_crow7.mdl"
    23. #define C7_Fire_Sound   "weapons/crow7-1.wav"
    24.  
    25. #define CROW7_NAME "CROW-7"
    26. #define CROW7_COST  22
    27. #define CROW7_CLIP 100
    28. #define CROW7_AMMO 200
    29. #define CROW7_RECOIL 1.5
    30. #define CROW7_DAMAGE 1.0
    31.  
    32. new mode[33]
    33. enum
    34. {
    35.     reloading = 0,
    36.     normal,
    37.     crow
    38. }
    39.  
    40. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    41.  
    42. //CROW-7
    43. new g_has_crow7[33], g_event_crow7, g_crow7_zoom[33], Float:g_flNextUseTime[33]
    44.  
    45. new g_isprimary, g_crow7
    46. new g_clip_ammo[33], g_clip[33], oldweap[33]
    47.  
    48. new Float:cl_pushangle[33][3]
    49.  
    50. public plugin_init()
    51. {
    52.     register_plugin("[Weapon]: CROW Weapons [Beta Version]", "1.0", "YunusReyiz")
    53.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    54.    
    55.     register_forward(FM_SetModel, "SetModel")
    56.     register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
    57.     register_forward(FM_PlaybackEvent, "PlaybackEvent")
    58.    
    59.     RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
    60.     RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
    61.    
    62.     RegisterHam(Ham_Item_AddToPlayer, weapon_crow7, "AddToPlayer")
    63.    
    64.     RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload7")
    65.     RegisterHam(Ham_Weapon_Reload, weapon_crow7, "Reload_Post7", 1)
    66.    
    67.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack7")
    68.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_crow7, "PrimaryAttack_Post7", 1)
    69.    
    70.     RegisterHam(Ham_Item_PostFrame, weapon_crow7, "ItemPostFrame7")
    71.    
    72.     RegisterHam(Ham_Item_Holster, weapon_crow7, "HolsterPost", 1)
    73.    
    74.     g_crow7 = ze_register_item(CROW7_NAME, CROW7_COST, ZE_TEAM_HUMAN)
    75.     register_forward(FM_CmdStart, "CmdStart")
    76. }
    77.  
    78. public plugin_precache()
    79. {  
    80.     precache_model(CROW7_V_Model)
    81.     precache_model(CROW7_P_Model)
    82.     precache_model(CROW7_W_Model)
    83.     precache_sound(C7_Fire_Sound)
    84.    
    85.     register_forward(FM_PrecacheEvent, "PrecacheEvent_Post", 1)
    86. }
    87.  
    88. public ze_select_item_pre(id, itemid)
    89. {
    90.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    91.     if (itemid != g_crow7)
    92.         return ZE_ITEM_AVAILABLE
    93.    
    94.     // Available for Humans only, So don't show it for zombies
    95.     if (ze_is_user_zombie(id))
    96.         return ZE_ITEM_DONT_SHOW
    97.    
    98.     return ZE_ITEM_AVAILABLE
    99. }
    100.  
    101. public ze_select_item_post(id, itemid)
    102. {
    103.     if(itemid == g_crow7)
    104.         give_crow7(id)
    105. }
    106.  
    107. public ze_user_humanized_post(id)
    108. {
    109.     client_connect(id)
    110. }
    111. public ze_user_infected(id, iInfector)
    112. {
    113.     client_connect(id)
    114. }
    115.  
    116. public TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
    117. {
    118.     if(!is_user_alive(attacker))
    119.         return
    120.  
    121.     new g_currentweapon = get_user_weapon(attacker)
    122.  
    123.     if((g_currentweapon != CSW_CROW7)
    124.     || (g_currentweapon == CSW_CROW7 && !g_has_crow7[attacker])) return;
    125.     static Float:flEnd[3]
    126.     get_tr2(ptr, TR_vecEndPos, flEnd)
    127.    
    128.     if(ent)
    129.     {
    130.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    131.         write_byte(TE_DECAL)
    132.         write_coord_f(flEnd[0])
    133.         write_coord_f(flEnd[1])
    134.         write_coord_f(flEnd[2])
    135.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    136.         write_short(ent)
    137.         message_end()
    138.     }
    139.     else
    140.     {
    141.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    142.         write_byte(TE_WORLDDECAL)
    143.         write_coord_f(flEnd[0])
    144.         write_coord_f(flEnd[1])
    145.         write_coord_f(flEnd[2])
    146.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    147.         message_end()
    148.     }
    149.     if(g_has_crow7[attacker])
    150.     {
    151.         SetHamParamFloat(3, Damage * CROW7_DAMAGE)
    152.     }
    153.    
    154.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    155.     write_byte(TE_GUNSHOTDECAL)
    156.     write_coord_f(flEnd[0])
    157.     write_coord_f(flEnd[1])
    158.     write_coord_f(flEnd[2])
    159.     write_short(attacker)
    160.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    161.     message_end()
    162. }
    163.  
    164. public PrecacheEvent_Post(type, const name[])
    165. {
    166.     if (equal(oldevent_crow7, name)) g_event_crow7 = get_orig_retval()
    167. }
    168.  
    169. public client_connect(id)
    170. {
    171.     g_crow7_zoom[id] = 0
    172.     g_has_crow7[id] = 0
    173. }
    174.  
    175. public CmdStart(id, uc_handle, seed)
    176. {
    177.     if(!g_has_crow7[id])
    178.         return
    179.  
    180.     if(!is_user_alive(id))
    181.         return
    182.        
    183.     new iButtons = get_uc(uc_handle, UC_Buttons)
    184.  
    185.     if((iButtons & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
    186.     {
    187.         new szClip, szAmmo
    188.         new szWeapID = get_user_weapon(id, szClip, szAmmo)
    189.        
    190.         if(szWeapID == CSW_CROW7 && g_has_crow7[id] && !g_crow7_zoom[id] == true)
    191.         {
    192.             g_crow7_zoom[id] = 1
    193.             cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
    194.             emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
    195.         }
    196.         else if(szWeapID == CSW_CROW7 && g_has_crow7[id] && g_crow7_zoom[id])
    197.         {
    198.                 g_crow7_zoom[id] = false
    199.                 cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
    200.         }
    201.     }
    202. }
    203.  
    204. public SetModel(ent, model[])
    205. {
    206.     if(!is_valid_ent(ent))
    207.         return FMRES_IGNORED
    208.    
    209.     static szcn[33]
    210.     entity_get_string(ent, EV_SZ_classname, szcn, charsmax(szcn))
    211.        
    212.     if(!equal(szcn, "weaponbox"))
    213.         return FMRES_IGNORED
    214.    
    215.     static own
    216.    
    217.     own = entity_get_edict(ent, EV_ENT_owner)
    218.     //CROW-7 w_model
    219.     if(equal(model, oldmodel_crow7))
    220.     {
    221.         static id
    222.        
    223.         id = find_ent_by_owner(-1, weapon_crow7, ent)
    224.    
    225.         if(!is_valid_ent(id))
    226.             return FMRES_IGNORED
    227.    
    228.         if(g_has_crow7[own])
    229.         {
    230.             entity_set_int(id, EV_INT_impulse, 3315784)
    231.            
    232.             g_has_crow7[own] = false
    233.            
    234.             entity_set_model(ent, CROW7_W_Model)
    235.            
    236.             return FMRES_SUPERCEDE
    237.         }
    238.     }
    239.  
    240.     return FMRES_IGNORED
    241. }
    242.  
    243. //Added CROW-7
    244. public give_crow7(id)
    245. {
    246.     new iWep2 = give_item(id, weapon_crow7)
    247.     if( iWep2 > 0 )
    248.     {
    249.         cs_set_weapon_ammo(iWep2, CROW7_CLIP)
    250.         cs_set_user_bpammo (id, CSW_CROW7, CROW7_AMMO)
    251.         set_anim(id, 6)
    252.         set_pdata_float(id, 83, 1.0, 5)
    253.     }
    254.     g_has_crow7[id] = true
    255. }
    256.  
    257. public AddToPlayer(ent, id)
    258. {
    259.     if(!is_valid_ent(ent) || !is_user_connected(id))
    260.         return HAM_IGNORED
    261.    
    262.     if(entity_get_int(ent, EV_INT_impulse) == 3315784)
    263.     {
    264.         g_has_crow7[id] = true
    265.        
    266.         entity_set_int(ent, EV_INT_impulse, 0)
    267.     }
    268.  
    269.     return HAM_IGNORED
    270. }
    271.  
    272. public CurrentWeapon(id) replace_weapon_models(id, read_data(2))
    273.  
    274. replace_weapon_models(id, weaponid)
    275. {
    276.     switch (weaponid)
    277.     {
    278.         case CSW_CROW7:
    279.         {
    280.             if (ze_is_user_zombie(id))
    281.                 return
    282.             if(g_has_crow7[id])
    283.             {
    284.                 set_pev(id, pev_viewmodel2, CROW7_V_Model)
    285.                 set_pev(id, pev_weaponmodel2, CROW7_P_Model)
    286.                 if(oldweap[id] != CSW_CROW7)
    287.                 {
    288.                     set_anim(id, 6)
    289.                     set_pdata_float(id, 83, 1.0, 5)
    290.                 }
    291.             }
    292.         }
    293.     }
    294.     oldweap[id] = weaponid
    295. }
    296.  
    297. public UpdateClientData_Post(id, SendWeapons, CD_Handle)
    298. {
    299.     //if(!is_user_alive(id) || (get_user_weapon(id) != CSW_CROW1 || !g_has_crow1[id]))
    300.     if(!is_user_alive(id)
    301.     || ((get_user_weapon(id) != CSW_CROW7)
    302.     || (get_user_weapon(id) == CSW_CROW7 && !g_has_crow7[id])))
    303.         return FMRES_IGNORED
    304.    
    305.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    306.     return FMRES_HANDLED
    307. }
    308.  
    309. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    310. {
    311.     if ((eventid != g_event_crow7) || !g_isprimary)
    312.         return FMRES_IGNORED
    313.     if (!(1 <= invoker <= get_maxplayers()))
    314.     return FMRES_IGNORED
    315.  
    316.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    317.     return FMRES_SUPERCEDE
    318. }
    319.  
    320. //CROW-7 PrimaryAttack and Post
    321. public PrimaryAttack7(ent)
    322. {
    323.     new id = pev(ent, pev_owner)
    324.    
    325.     if (!g_has_crow7[id])
    326.         return
    327.    
    328.     g_isprimary = 1
    329.    
    330.     g_clip_ammo[id] = cs_get_weapon_ammo(ent)
    331.    
    332.     pev(id, pev_punchangle, cl_pushangle[id])
    333. }
    334.  
    335. public PrimaryAttack_Post7(ent)
    336. {
    337.     g_isprimary = 0
    338.    
    339.     new id = pev(ent, pev_owner)
    340.    
    341.     new szClip, szAmmo
    342.     get_user_weapon(id, szClip, szAmmo)
    343.    
    344.     if(!is_user_alive(id))
    345.         return
    346.        
    347.     if(g_has_crow7[id])
    348.     {
    349.         if (!g_clip_ammo[id])
    350.             return
    351.        
    352.         new Float:push[3]
    353.         pev(id, pev_punchangle, push)
    354.         xs_vec_sub(push, cl_pushangle[id], push)
    355.        
    356.         xs_vec_mul_scalar(push, CROW7_RECOIL,push)
    357.         xs_vec_add(push,cl_pushangle[id],push)
    358.         set_pev(id,pev_punchangle,push)
    359.        
    360.         emit_sound(id, CHAN_WEAPON, C7_Fire_Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    361.         set_anim(id, 1)
    362.     }
    363. }
    364.  
    365. stock set_anim(const Player, const Sequence)
    366. {
    367.     set_pev(Player, pev_weaponanim, Sequence)
    368.    
    369.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    370.     write_byte(Sequence)
    371.     write_byte(pev(Player, pev_body))
    372.     message_end()
    373. }
    374.  
    375. public ItemPostFrame7(wpn, uc_handle)
    376. {
    377.     new id = pev(wpn, pev_owner)
    378.     if (!is_user_connected(id))
    379.         return HAM_IGNORED
    380.  
    381.     if (!g_has_crow7[id])
    382.         return HAM_IGNORED
    383.  
    384.     static iClipExtra
    385.      
    386.     iClipExtra = CROW7_CLIP
    387.     new Float:flNextAttack = get_pdata_float(id, 83, 5)
    388.  
    389.     new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
    390.     new iClip = get_pdata_int(wpn, 51, 4)
    391.  
    392.     new fInReload = get_pdata_int(wpn, 54, 4)
    393.    
    394.     if( fInReload && flNextAttack <= 0.0 )
    395.     {   if(mode[id] == reloading && get_gametime() - Reload_Time && /*get_uc(uc_handle, UC_Buttons) & IN_RELOAD &&*/ (pev(id, pev_oldbuttons) & IN_RELOAD))
    396.         {
    397.             set_pdata_float(wpn, 48, CROW_Time7, 4)
    398.             mode[id] = crow
    399.             set_anim(id, 4)
    400.             set_pdata_float(id, 83, CROW_Time7, 5)
    401.             set_pdata_int(wpn, 51, g_clip[id], 4)
    402.  
    403.         }
    404.         else if(mode[id] == reloading || get_gametime() - Reload_Time && !(pev(id, pev_oldbuttons) & IN_RELOAD))
    405.         {
    406.             set_pdata_float(wpn, 48, Normal_Time7, 4)
    407.  
    408.             mode[id] = normal
    409.             set_anim(id, 5)
    410.             set_pdata_float(id, 83, Normal_Time7, 5)
    411.             set_pdata_int(wpn, 51, g_clip[id], 4)
    412.         }
    413.         new j = min(iClipExtra - iClip, iBpAmmo)
    414.  
    415.         set_pdata_int(wpn, 51, iClip + j, 4)
    416.         cs_set_user_bpammo(id, CSW_CROW7, iBpAmmo-j)
    417.        
    418.         set_pdata_int(wpn, 54, 0, 4)
    419.  
    420.         fInReload = 0
    421.        
    422.     }
    423.     return HAM_IGNORED
    424. }
    425.  
    426. public Reload7(wpn)
    427. {
    428.     new id = pev(wpn, pev_owner)
    429.     if (!is_user_connected(id))
    430.         return HAM_IGNORED
    431.  
    432.     if (!g_has_crow7[id])
    433.         return HAM_IGNORED
    434.  
    435.     static iClipExtra
    436.  
    437.     iClipExtra = CROW7_CLIP
    438.  
    439.     g_clip[id] = -1
    440.    
    441.     new iClip = get_pdata_int(wpn, 51, 4)
    442.     new iBpAmmo = cs_get_user_bpammo(id, CSW_CROW7)
    443.        
    444.     if (iBpAmmo <= 0)
    445.         return HAM_SUPERCEDE
    446.  
    447.     if (iClip >= iClipExtra)
    448.         return HAM_SUPERCEDE
    449.  
    450.     g_clip[id] = iClip
    451.  
    452.     return HAM_IGNORED
    453. }
    454.  
    455. public Reload_Post7(wpn)
    456. {
    457.     new id = pev(wpn, pev_owner)
    458.     if (!is_user_connected(id))
    459.         return HAM_IGNORED
    460.  
    461.     if (!g_has_crow7[id])
    462.         return HAM_IGNORED
    463.  
    464.     if (g_clip[id] == -1)
    465.         return HAM_IGNORED
    466.  
    467.     mode[id] = reloading
    468.     g_crow7_zoom[id] = 0
    469.     cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
    470.    
    471.     set_pdata_float(wpn, 48, Reload_Time7, 4)
    472.     set_pdata_float(id, 83, Reload_Time7, 5)
    473.  
    474.     set_pdata_int(wpn, 51, g_clip[id], 4)
    475.     set_pdata_int(wpn, 54, 1, 4)
    476.  
    477.     if(mode[id] == reloading) set_anim(id, 3)
    478.  
    479.     return HAM_IGNORED
    480. }
    481.  
    482. public HolsterPost(wpn)
    483. {
    484.     static id
    485.     id = get_pdata_cbase(wpn, 41, 4)
    486.    
    487.     g_flNextUseTime[id] = 0.0
    488.  
    489.     if(!g_has_crow7[id])
    490.         return;
    491.  
    492.     if(g_has_crow7[id])
    493.     {
    494.         g_crow7_zoom[id] = 0
    495.         cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
    496.     }
    497. }
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests