Resolved Pls convert it to ze

Unpaid Requests, Public Plugins
Post Reply
OxiCorm
Member
Member
Posts: 33
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

Pls convert it to ze

#1

Post by OxiCorm » 2 Years Ago

Pls some one convert this item rail cannon to ze and thank you

Code: Select all

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

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define RAILCANNON_WEAPONKEY 756144798
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define SMOKE_CLASS "smokess"

#define ENABLE_KNOCKBACK 1

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

#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif

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

#define RAILCANNON_DRAW			7

#define TASK_SOUND 2573+10
#define TASK_SETRUM2 2573+20

new gmsgWeaponList, sTrail

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

new const Fire_Sounds[] = "weapons/railcanon-1.wav"
new const MuzzleFlash[] = "sprites/muzzleflash19.spr"

//////////// Change Here For Customize //////////////////////////

const Float:cvar_recoil_railcannon = 0.65
const cvar_clip_railcannon = 24
const cvar_railcannon_ammo = 90

const Float:damage_mode1 = 20.0
const Float:damage_mode2 = 35.0
const Float:damage_mode3 = 60.0

/////////////////////////////////////////////////////////////////
new RAILCANNON_V_MODEL[64] = "models/v_railcannon.mdl"
new RAILCANNON_P_MODEL[64] = "models/p_railcannon.mdl"
new RAILCANNON_W_MODEL[64] = "models/w_railcannon.mdl"

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

new g_has_railcannon[33], g_Ham_Bot

new g_MaxPlayers, g_orig_event_railcannon, g_IsInPrimaryAttack, g_MuzzleFlash_SprId, g_rail, g_KnockBack
new Float:cl_pushangle[33][3], m_iBlood[2], zz[33], udah[33]
new g_clip_ammo[33], oldweap[33], g_reload[33], railcannon_mode[33], Float:StartOrigin2[3], g_SpecialAmmo[33]
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_mp5navy", "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("Rail Cannon", "1.0", "m4m3ts")
	register_cvar("rail_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	register_think(SMOKE_CLASS, "fw_Fire_smoke")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_m3", "fw_RAILCANNON_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_m3", "fw_RAIL_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload_Post", 1)
	RegisterHam(Ham_Weapon_WeaponIdle, "weapon_m3", "fw_railcannonidleanim", 1)
	
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	
	register_forward(FM_CmdStart, "fw_CmdStart")
	register_forward(FM_SetModel, "fw_SetModel")
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
	register_forward(FM_TraceLine,"fw_traceline",1)
	
	gmsgWeaponList = get_user_msgid("WeaponList")
	
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
	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)
	
	g_rail = zp_register_extra_item("Rail Cannon", 20, ZP_TEAM_HUMAN)
	g_KnockBack = ENABLE_KNOCKBACK
	g_MaxPlayers = get_maxplayers()
}

public plugin_precache()
{
	precache_model(RAILCANNON_V_MODEL)
	precache_model(RAILCANNON_P_MODEL)
	precache_model(RAILCANNON_W_MODEL)
	precache_sound(Fire_Sounds)	
		
	sTrail = precache_model("sprites/laserbeam.spr")
	
	precache_sound("weapons/railcanon_clipin.wav")
	precache_sound("weapons/railcanon_chage1_start.wav")
	precache_sound("weapons/railcanon_chage3_loop.wav")
	precache_sound("weapons/railcanon_draw.wav")
	precache_sound("weapons/railcanon_clipout.wav")
	precache_sound("weapons/railcanon-2.wav")
	
	g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
	precache_generic("sprites/weapon_railcannon.txt")
	
	precache_generic("sprites/640hud112.spr")
	precache_generic("sprites/640hud13.spr")
		
	register_clcmd("weapon_railcannon", "weapon_hook")	
					
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	precache_model("sprites/wall_puff1.spr")

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

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

public client_putinserver(id)
{
	if(!g_Ham_Bot && is_user_bot(id))
	{
		g_Ham_Bot = 1
		set_task(0.1, "Do_RegisterHam_Bot", id)
	}
}

public Do_RegisterHam_Bot(id)
{
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
}

public zp_extra_item_selected(id, itemid)
{
	if(itemid == g_rail) give_railcannon(id)
}

public zp_user_infected_post(id)
{
	update_specialammo(id, g_SpecialAmmo[id], 0)
	g_has_railcannon[id] = false
	g_SpecialAmmo[id] = 0
}

public fw_PlayerKilled(id)
{
	g_has_railcannon[id] = false
}

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_M3 || !g_has_railcannon[iAttacker])
		return
	
	if(railcannon_mode[iAttacker] == 3) SetHamParamFloat(3, 60.0)
	if(railcannon_mode[iAttacker] == 2) SetHamParamFloat(3, 35.0)
	if(railcannon_mode[iAttacker] == 1) SetHamParamFloat(3, 20.0)
	
	static Float:flEnd[3], Float:test[3], Float:myOrigin[3]
	
	pev(iAttacker, pev_origin, myOrigin)
	get_tr2(ptr, TR_vecEndPos, flEnd)
		
	if(!is_user_alive(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()

		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()
		
		fm_get_aim_origin(iAttacker, test)
		if(railcannon_mode[iAttacker] == 3) fake_smokes(iAttacker, test)
	}
	
	if(railcannon_mode[iAttacker] == 2)
	{
		get_position(iAttacker, 20.0, 0.0, 10.0, StartOrigin2)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMPOINTS)
		engfunc(EngFunc_WriteCoord, StartOrigin2[0])
		engfunc(EngFunc_WriteCoord, StartOrigin2[1])
		engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
		engfunc(EngFunc_WriteCoord, flEnd[0])
		engfunc(EngFunc_WriteCoord, flEnd[1])
		engfunc(EngFunc_WriteCoord, flEnd[2])
		write_short(sTrail)
		write_byte(0) // start frame
		write_byte(0) // framerate
		write_byte(5) // life
		write_byte(5) // line width
		write_byte(0) // amplitude
		write_byte(220)
		write_byte(88)
		write_byte(0) // blue
		write_byte(255) // brightness
		write_byte(0) // speed
		message_end()
	}
	
	if(railcannon_mode[iAttacker] == 3)
	{
		get_position(iAttacker, 20.0, 5.0, 5.0, StartOrigin2)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMPOINTS)
		engfunc(EngFunc_WriteCoord, StartOrigin2[0])
		engfunc(EngFunc_WriteCoord, StartOrigin2[1])
		engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
		engfunc(EngFunc_WriteCoord, flEnd[0])
		engfunc(EngFunc_WriteCoord, flEnd[1])
		engfunc(EngFunc_WriteCoord, flEnd[2])
		write_short(sTrail)
		write_byte(0) // start frame
		write_byte(0) // framerate
		write_byte(8) // life
		write_byte(8) // line width
		write_byte(0) // amplitude
		write_byte(220)
		write_byte(88)
		write_byte(0) // blue
		write_byte(50) // brightness
		write_byte(0) // speed
		message_end()
		
		if(!is_user_alive(iEnt))
			return
		
		if(zp_get_user_zombie(iEnt) && g_KnockBack == 1) knockback(iEnt, myOrigin, 42.0, 2)
	}
	
}

public fake_smokes(id, Float:Origin[3])
{
	new ent_test; ent_test = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
	
	engfunc(EngFunc_SetModel, ent_test, "sprites/wall_puff1.spr")
	entity_set_string(ent_test, EV_SZ_classname, SMOKE_CLASS)
	set_pev(ent_test, pev_nextthink, get_gametime() + 0.04)
	set_pev(ent_test, pev_movetype, MOVETYPE_NONE)
	set_pev(ent_test, pev_rendermode, kRenderTransAdd)
	set_pev(ent_test, pev_renderamt, 20.0)
	set_pev(ent_test, pev_scale, 1.0)
	set_pev(ent_test, pev_origin, Origin)
	set_pev(ent_test, pev_frame, 0.0)
	set_pev(ent_test, pev_iuser2, get_user_team(id))

	set_pev(ent_test, pev_solid, SOLID_NOT)
	dllfunc(DLLFunc_Spawn, ent_test)
}

public fw_Fire_smoke(iEnt)
{
	if(!pev_valid(iEnt)) 
		return
	
	new Float:fFrame
	pev(iEnt, pev_frame, fFrame)

	// effect exp
	fFrame += 1.0

	set_pev(iEnt, pev_frame, fFrame)
	set_pev(iEnt, pev_scale, 1.0)
	set_pev(iEnt, pev_nextthink, get_gametime() + 0.02)
	
	if(fFrame > 30.0) engfunc(EngFunc_RemoveEntity, iEnt)
}

public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id,ptr)
{
	if(!is_user_alive(id))
		return HAM_IGNORED	
	if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
		return HAM_IGNORED
	if(railcannon_mode[id] != 3)
		return HAM_IGNORED
	
	// get crosshair aim
	static Float:aim[3];
	get_aim(id,v1,aim);
	
	// do another trace to this spot
	new trace = create_tr2();
	engfunc(EngFunc_TraceLine,v1,aim,noMonsters,id,trace);
	
	// copy ints
	set_tr2(ptr,TR_AllSolid,get_tr2(trace,TR_AllSolid));
	set_tr2(ptr,TR_StartSolid,get_tr2(trace,TR_StartSolid));
	set_tr2(ptr,TR_InOpen,get_tr2(trace,TR_InOpen));
	set_tr2(ptr,TR_InWater,get_tr2(trace,TR_InWater));
	set_tr2(ptr,TR_pHit,get_tr2(trace,TR_pHit));
	set_tr2(ptr,TR_iHitgroup,get_tr2(trace,TR_iHitgroup));

	// copy floats
	get_tr2(trace,TR_flFraction,aim[0]);
	set_tr2(ptr,TR_flFraction,aim[0]);
	get_tr2(trace,TR_flPlaneDist,aim[0]);
	set_tr2(ptr,TR_flPlaneDist,aim[0]);
	
	// copy vecs
	get_tr2(trace,TR_vecEndPos,aim);
	set_tr2(ptr,TR_vecEndPos,aim);
	get_tr2(trace,TR_vecPlaneNormal,aim);
	set_tr2(ptr,TR_vecPlaneNormal,aim);

	// get rid of new trace
	free_tr2(trace);

	return FMRES_IGNORED;
}

get_aim(id,Float:source[3],Float:ret[3])
{
	static Float:vAngle[3], Float:pAngle[3], Float:dir[3], Float:temp[3];

	// get aiming direction from forward global based on view angle and punch angle
	pev(id,pev_v_angle,vAngle);
	pev(id,pev_punchangle,pAngle);
	xs_vec_add(vAngle,pAngle,temp);
	engfunc(EngFunc_MakeVectors,temp);
	global_get(glb_v_forward,dir);
	
	/* vecEnd = vecSrc + vecDir * flDistance; */
	xs_vec_mul_scalar(dir,8192.0,temp);
	xs_vec_add(source,temp,ret);
}

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

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

public client_disconnect(id)
{
	g_has_railcannon[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_m3.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_m3", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_railcannon[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, RAILCANNON_WEAPONKEY)
			
			g_has_railcannon[iOwner] = false
			
			entity_set_model(entity, RAILCANNON_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public give_railcannon(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_m3")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, cvar_clip_railcannon)
		cs_set_user_bpammo (id, CSW_M3, cvar_railcannon_ammo)
		UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
		set_weapons_timeidle(id, CSW_M3, 1.0)
		set_player_nextattackx(id, 1.0)
		g_clip_ammo[id] = cs_get_weapon_ammo(iWep2)
	}
	g_has_railcannon[id] = true
	g_SpecialAmmo[id] = 0
	udah[id] = 0
	zz[id] = 0
	railcannon_mode[id] = 1
	update_specialammo(id, g_SpecialAmmo[id], g_SpecialAmmo[id] > 0 ? 1 : 0)
	message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
	write_string("weapon_railcannon")
	write_byte(5)
	write_byte(32)
	write_byte(-1)
	write_byte(-1)
	write_byte(0)
	write_byte(5)
	write_byte(21)
	write_byte(0)
	message_end()
}

public fw_RAILCANNON_AddToPlayer(railcannon, id)
{
	if(!is_valid_ent(railcannon) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(railcannon, EV_INT_WEAPONKEY) == RAILCANNON_WEAPONKEY)
	{
		g_has_railcannon[id] = true
		
		message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
		write_string("weapon_railcannon")
		write_byte(5)
		write_byte(32)
		write_byte(-1)
		write_byte(-1)
		write_byte(0)
		write_byte(5)
		write_byte(21)
		write_byte(0)
		message_end()
		
		entity_set_int(railcannon, EV_INT_WEAPONKEY, 0)
		update_specialammo(id, g_SpecialAmmo[id], 0)
		g_SpecialAmmo[id] = 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)
	
	update_specialammo(owner, g_SpecialAmmo[owner], 0)
	g_SpecialAmmo[owner] = 0
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
	if( read_data(2) != CSW_M3 ) {
		if( g_reload[id] ) {
			g_reload[id] = 0
			remove_task( id + 1331 )
		}
	}
	replace_weapon_models(id, read_data(2))
}

replace_weapon_models(id, weaponid)
{
	switch (weaponid)
	{
		case CSW_M3:
		{
			if(g_has_railcannon[id])
			{
				set_pev(id, pev_viewmodel2, RAILCANNON_V_MODEL)
				set_pev(id, pev_weaponmodel2, RAILCANNON_P_MODEL)
				if(oldweap[id] != CSW_M3) 
				{
					set_weapons_timeidle(id, CSW_M3, 1.0)
					set_player_nextattackx(id, 1.0)
					UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
					udah[id] = 0
					zz[id] = 0
					railcannon_mode[id] = 1
					remove_task(id+TASK_SOUND)
					remove_task(id)

					message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
					write_string("weapon_railcannon")
					write_byte(5)
					write_byte(32)
					write_byte(-1)
					write_byte(-1)
					write_byte(0)
					write_byte(5)
					write_byte(CSW_M3)
					message_end()
				}
			}
		}
	}
	oldweap[id] = weaponid
}

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

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

public fw_RAIL_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_railcannon[Player])
	{
		if (!g_clip_ammo[Player] && railcannon_mode[Player] == 1)
			return
		
		g_reload[Player] = 0
		remove_task( Player + 1331 )
		new Float:push[3]
		pev(Player,pev_punchangle,push)
		xs_vec_sub(push,cl_pushangle[Player],push)
		xs_vec_mul_scalar(push,cvar_recoil_railcannon,push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		UTIL_PlayWeaponAnimation(Player,random_num(4,5))
		set_weapons_timeidle(Player, CSW_M3, 0.3)
		set_player_nextattackx(Player, 0.3)
		g_clip_ammo[Player] --
		
		if(railcannon_mode[Player] == 3) emit_sound(Player, CHAN_WEAPON, "weapons/railcanon-2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		else emit_sound(Player, CHAN_WEAPON, Fire_Sounds, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		
		railcannon_mode[Player] = 1
	}
}

public Make_Muzzleflash(id)
{
	static Float:Origin[3], TE_FLAG
	get_position(id, 32.0, 6.0, -15.0, Origin)
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_MuzzleFlash_SprId)
	write_byte(2)
	write_byte(30)
	write_byte(TE_FLAG)
	message_end()
}

public fw_CmdStart(id, uc_handle, seed) 
{
	new ammo, clip, weapon = get_user_weapon(id, clip, ammo)
	if (!g_has_railcannon[id] || weapon != CSW_M3 || !is_user_alive(id))
		return
	
	static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
		
	if(!pev_valid(ent))
		return
		
	static CurButton
	CurButton = get_uc(uc_handle, UC_Buttons)
	
	if(CurButton & IN_ATTACK)
	{
		new wpn = fm_get_user_weapon_entity(id, get_user_weapon(id))
		
		new Id = pev( wpn, pev_owner ), clip, bpammo
		get_user_weapon( Id, clip, bpammo )
		if( g_has_railcannon[ Id ] ) {
		if( clip >= 2 ) {
			if( g_reload[Id] ) {
				remove_task( Id + 1331 )
				g_reload[Id] = 0
			}
		}
		else if( clip == 1 )
		{
			if(get_pdata_float(Id, 83, 4) <= 0.3)
			{
				if( g_reload[Id] ) {
				remove_task( Id + 1331 )
				g_reload[Id] = 0
			}
			}
		}
	}
	}
	
	else if(CurButton & IN_ATTACK2)
	{
		if(!zz[id] && get_pdata_float(id, 83, 4) <= 0.0 && g_clip_ammo[id] >= 1)
		{
			set_weapons_timeidle(id, CSW_M3, 200.0)
			set_player_nextattackx(id, 200.0)
			UTIL_PlayWeaponAnimation(id, 1)
			emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage1_start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
			set_task(0.6, "charge_idle2", id)
			zz[id] = 1
			udah[id] = 0
			railcannon_mode[id] = 2
			
			update_specialammo(id, g_SpecialAmmo[id], 0)
			g_SpecialAmmo[id] ++
			update_specialammo(id, g_SpecialAmmo[id], 1)
			
			new weapon = find_ent_by_owner( -1, "weapon_m3", id )
			cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
			g_clip_ammo[id] --
		}
	}
	
	else if(!(pev(id, pev_oldbuttons) & IN_ATTACK) && zz[id])
	{
		zz[id] = 0
		if(udah[id])
		{
			if(g_clip_ammo[id] >= 1)
			{
				ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
				set_weapons_timeidle(id, CSW_M3, 1.1)
				set_player_nextattackx(id, 1.1)
				udah[id] = 0
				remove_task(id+TASK_SOUND)
				
				update_specialammo(id, g_SpecialAmmo[id], 0)
				g_SpecialAmmo[id] = 0
				
				new weapon = find_ent_by_owner( -1, "weapon_m3", id )
				cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
				g_clip_ammo[id] ++
			}
			else
			{
				new weapon = find_ent_by_owner( -1, "weapon_m3", id )
				cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
				g_clip_ammo[id] ++
				
				ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
				set_weapons_timeidle(id, CSW_M3, 1.1)
				set_player_nextattackx(id, 1.1)
				udah[id] = 0
				remove_task(id+TASK_SOUND)
				
				update_specialammo(id, g_SpecialAmmo[id], 0)
				g_SpecialAmmo[id] = 0
			}
		}
	}
}

public charge_idle2(id)
{
	if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
		return
	if(zz[id])
	{
		if(g_clip_ammo[id] >= 1)
		{
			UTIL_PlayWeaponAnimation(id, 2)
			set_weapons_timeidle(id, CSW_M3, 200.0)
			set_player_nextattackx(id, 200.0)
			set_task(0.6, "charge_idle3", id)
			
			update_specialammo(id, g_SpecialAmmo[id], 0)
			g_SpecialAmmo[id] ++
			update_specialammo(id, g_SpecialAmmo[id], 1)
			
			new weapon = find_ent_by_owner( -1, "weapon_m3", id )
			cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
			g_clip_ammo[id] --
		}
		else
		{
			static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
		
			if(!pev_valid(ent))
				return
			
			new weapon = find_ent_by_owner( -1, "weapon_m3", id )
			cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
			g_clip_ammo[id] ++
			
			ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
			set_weapons_timeidle(id, CSW_M3, 1.1)
			set_player_nextattackx(id, 1.1)
			
			update_specialammo(id, g_SpecialAmmo[id], 0)
			g_SpecialAmmo[id] = 0
		}
	}
	else
	{
		static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
		
		if(!pev_valid(ent))
			return
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
		set_weapons_timeidle(id, CSW_M3, 1.1)
		set_player_nextattackx(id, 1.1)
		
		update_specialammo(id, g_SpecialAmmo[id], 0)
		g_SpecialAmmo[id] = 0
		
		new weapon = find_ent_by_owner( -1, "weapon_m3", id )
		cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
		g_clip_ammo[id] ++
	}
}

public charge_idle3(id)
{
	if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
		return
	if(zz[id])
	{
		if(g_clip_ammo[id] >= 1)
		{
			UTIL_PlayWeaponAnimation(id, 3)
			emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
			set_task(0.794, "play_sound", id+TASK_SOUND,_,_,"b")
			udah[id] = 1
			railcannon_mode[id] = 3
			set_weapons_timeidle(id, CSW_M3, 200.0)
			set_player_nextattackx(id, 200.0)
			
			update_specialammo(id, g_SpecialAmmo[id], 0)
			g_SpecialAmmo[id] ++
			update_specialammo(id, g_SpecialAmmo[id], 1)
			
			new weapon = find_ent_by_owner( -1, "weapon_m3", id )
			cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
			g_clip_ammo[id] --
		}
		else
		{
			static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
		
			if(!pev_valid(ent))
				return
			new weapon = find_ent_by_owner( -1, "weapon_m3", id )
			cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
			g_clip_ammo[id] ++
			
			ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
			set_weapons_timeidle(id, CSW_M3, 1.1)
			set_player_nextattackx(id, 1.1)
			
			update_specialammo(id, g_SpecialAmmo[id], 0)
			g_SpecialAmmo[id] = 0
		}
	}
	else
	{
		static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
		
		if(!pev_valid(ent))
			return
		ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
		set_weapons_timeidle(id, CSW_M3, 1.1)
		set_player_nextattackx(id, 1.1)
		
		update_specialammo(id, g_SpecialAmmo[id], 0)
		g_SpecialAmmo[id] = 0
		
		new weapon = find_ent_by_owner( -1, "weapon_m3", id )
		cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
		g_clip_ammo[id] ++
	}
}

public play_sound(id)
{
	id -= TASK_SOUND
	
	if(!is_user_alive(id) || get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
		return
	
	emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}

public fw_railcannonidleanim(Weapon)
{
	new id = get_pdata_cbase(Weapon, 41, 4)

	if(!is_user_alive(id) || !g_has_railcannon[id] || get_user_weapon(id) != CSW_M3)
		return HAM_IGNORED;
	
	if(railcannon_mode[id] == 1 && get_pdata_float(Weapon, 48, 4) <= 0.25)
	{
		UTIL_PlayWeaponAnimation(id, 0)
		set_pdata_float(Weapon, 48, 20.0, 4)
		return HAM_SUPERCEDE;
	}
	
	if(railcannon_mode[id] == 3 && get_pdata_float(Weapon, 48, 4) <= 0.01)
	{
		UTIL_PlayWeaponAnimation(id, 3)
		set_pdata_float(Weapon, 48, 1.7, 4)
		return HAM_SUPERCEDE;
	}

	return HAM_IGNORED;
}

public update_specialammo(id, Ammo, On)
{
	static AmmoSprites[33]
	format(AmmoSprites, sizeof(AmmoSprites), "number_%d", Ammo)
  	
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("StatusIcon"), {0,0,0}, id)
	write_byte(On)
	write_string(AmmoSprites)
	write_byte(42) // red
	write_byte(255) // green
	write_byte(42) // blue
	message_end()
}

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_railcannon) || !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 RAILCANNON_Reload( wpn ) {
	if(railcannon_mode[pev( wpn, pev_owner )] == 3)
	      return HAM_SUPERCEDE
		  
	if( g_has_railcannon[ pev( wpn, pev_owner ) ] ) {
		RAILCANNON_Reload_Post( wpn )
		return HAM_SUPERCEDE
	}
	return HAM_IGNORED
}

public RAILCANNON_Reload_Post(weapon) {
	new id = pev( weapon, pev_owner )
	if(railcannon_mode[id] == 3 || g_reload[id])
	      return HAM_SUPERCEDE
	new clip, bpammo
	get_user_weapon(id, clip, bpammo )
	if( g_has_railcannon[ id ] && clip < cvar_clip_railcannon && bpammo > 0 ) {
		if(!task_exists( id+1331 )) set_task( 0.1, "reload", id+1331 )
		}
	return HAM_IGNORED
}

public reload( id ) {
	id -= 1331
	set_weapons_timeidle(id, CSW_M3, 3.0)
	set_player_nextattackx(id, 3.0)
	UTIL_PlayWeaponAnimation(id, 6)
	g_reload[id] = 1
	set_task(3.0, "isi", id)
}

public isi(id)
{
	if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
		return
	
	if(!g_reload[id])
		return
	
	new clip, pluru, pengurang, bpammo, weapon = find_ent_by_owner( -1, "weapon_m3", id )
	get_user_weapon(id, clip, bpammo )
	pengurang = cvar_clip_railcannon - clip
	pluru = bpammo - pengurang
	cs_set_user_bpammo( id, CSW_M3, pluru )
	
	if(bpammo <= pengurang) cs_set_weapon_ammo( weapon, clip + bpammo)
	else cs_set_weapon_ammo( weapon, cvar_clip_railcannon)
	
	g_clip_ammo[id] = cvar_clip_railcannon
}

stock knockback(ent, Float:VicOrigin[3], Float:speed, type)
{
	static Float:fl_Velocity[3]
	static Float:EntOrigin[3]
	static Float:EntVelocity[3]
	
	pev(ent, pev_velocity, EntVelocity)
	pev(ent, pev_origin, EntOrigin)
	static Float:distance_f
	distance_f = get_distance_f(EntOrigin, VicOrigin)
	
	static Float:fl_Time; fl_Time = distance_f / speed
	
	if(type == 1)
	{
		fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time		
		} else if(type == 2) {
		fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
	}
	
	xs_vec_add(EntVelocity, fl_Velocity, fl_Velocity)
	set_pev(ent, pev_velocity, fl_Velocity)
}

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

stock fm_set_weapon_ammo(entity, amount)
{
	set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}

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

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

stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
{ 
	new Float:vfEnd[3], viEnd[3] 
	get_user_origin(id, viEnd, 3)  
	IVecFVec(viEnd, vfEnd) 
	
	new Float:fOrigin[3], Float:fAngle[3]
	
	pev(id, pev_origin, fOrigin) 
	pev(id, pev_view_ofs, fAngle)
	
	xs_vec_add(fOrigin, fAngle, fOrigin) 
	
	new Float:fAttack[3]
	
	xs_vec_sub(vfEnd, fOrigin, fAttack)
	xs_vec_sub(vfEnd, fOrigin, fAttack) 
	
	new Float:fRate
	
	fRate = fDis / vector_length(fAttack)
	xs_vec_mul_scalar(fAttack, fRate, fAttack)
	
	xs_vec_add(fOrigin, fAttack, output)
}

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

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
	static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(id, pev_origin, vOrigin)
	pev(id, pev_view_ofs, vUp) //for player
	xs_vec_add(vOrigin, vUp, vOrigin)
	pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
	
	angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
	angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
	
	vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}


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

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#2

Post by johnnysins2000 » 2 Years Ago

OK bro When I will come to Pc I will convert It
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#3

Post by johnnysins2000 » 2 Years Ago

Code:
    1. #include <zombie_escape>
    2. #include <fakemeta_util>
    3. #include <xs>
    4. #include <cstrike>
    5.  
    6. #define ENG_NULLENT     -1
    7. #define EV_INT_WEAPONKEY    EV_INT_impulse
    8. #define RAILCANNON_WEAPONKEY 756144798
    9. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
    10.  
    11. #define SMOKE_CLASS "smokess"
    12.  
    13. #define ENABLE_KNOCKBACK 1
    14.  
    15. const USE_STOPPED = 0
    16. const OFFSET_ACTIVE_ITEM = 373
    17. const OFFSET_WEAPONOWNER = 41
    18. const OFFSET_LINUX = 5
    19. const OFFSET_LINUX_WEAPONS = 4
    20.  
    21. #if cellbits == 32
    22. const OFFSET_CLIPAMMO = 51
    23. #else
    24. const OFFSET_CLIPAMMO = 65
    25. #endif
    26.  
    27. #define WEAP_LINUX_XTRA_OFF     4
    28. #define m_fKnown                    44
    29. #define m_flNextPrimaryAttack       46
    30. #define m_flNextSecondaryAttack         47
    31. #define m_flTimeWeaponIdle          48
    32. #define m_iClip                 51
    33. #define m_fInReload             54
    34. #define m_fInSpecialReload          55
    35. #define PLAYER_LINUX_XTRA_OFF   5
    36. #define m_flNextAttack              83
    37.  
    38. #define RAILCANNON_DRAW         7
    39.  
    40. #define TASK_SOUND 2573+10
    41. #define TASK_SETRUM2 2573+20
    42.  
    43. new gmsgWeaponList, sTrail
    44.  
    45. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    46.  
    47. new const Fire_Sounds[] = "weapons/railcanon-1.wav"
    48. new const MuzzleFlash[] = "sprites/muzzleflash19.spr"
    49.  
    50. //////////// Change Here For Customize //////////////////////////
    51.  
    52. const Float:cvar_recoil_railcannon = 0.65
    53. const cvar_clip_railcannon = 24
    54. const cvar_railcannon_ammo = 90
    55.  
    56. const Float:damage_mode1 = 20.0
    57. const Float:damage_mode2 = 35.0
    58. const Float:damage_mode3 = 60.0
    59.  
    60. /////////////////////////////////////////////////////////////////
    61. new RAILCANNON_V_MODEL[64] = "models/v_railcannon.mdl"
    62. new RAILCANNON_P_MODEL[64] = "models/p_railcannon.mdl"
    63. new RAILCANNON_W_MODEL[64] = "models/w_railcannon.mdl"
    64.  
    65. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    66.  
    67. new g_has_railcannon[33], g_Ham_Bot
    68.  
    69. new g_MaxPlayers, g_orig_event_railcannon, g_IsInPrimaryAttack, g_MuzzleFlash_SprId, g_iItemID, g_KnockBack
    70. new Float:cl_pushangle[33][3], m_iBlood[2], zz[33], udah[33]
    71. new g_clip_ammo[33], oldweap[33], g_reload[33], railcannon_mode[33], Float:StartOrigin2[3], g_SpecialAmmo[33]
    72. const PRIMARY_WEAPONS_BIT_SUM =
    73. (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<<
    74. 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)
    75. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
    76.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
    77.             "weapon_mp5navy", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
    78.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
    79.             "weapon_ak47", "weapon_knife", "weapon_p90" }
    80.  
    81. public plugin_init()
    82. {
    83.     register_plugin("Rail Cannon", "1.0", "m4m3ts")
    84.     register_cvar("rail_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
    85.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    86.     register_think(SMOKE_CLASS, "fw_Fire_smoke")
    87.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m3", "fw_RAILCANNON_AddToPlayer")
    88.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
    89.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
    90.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
    91.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
    92.     g_iItemID = ze_register_item("Rail Cannon", 20)
    93.    
    94.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
    95.         if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
    96.    
    97.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack")
    98.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack_Post", 1)
    99.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload")
    100.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload_Post", 1)
    101.     RegisterHam(Ham_Weapon_WeaponIdle, "weapon_m3", "fw_railcannonidleanim", 1)
    102.    
    103.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
    104.    
    105.     register_forward(FM_CmdStart, "fw_CmdStart")
    106.     register_forward(FM_SetModel, "fw_SetModel")
    107.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    108.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
    109.     register_forward(FM_TraceLine,"fw_traceline",1)
    110.    
    111.     gmsgWeaponList = get_user_msgid("WeaponList")
    112.    
    113.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
    114.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
    115.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
    116.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
    117.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
    118.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
    119.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
    120.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
    121.    
    122.     g_KnockBack = ENABLE_KNOCKBACK
    123.     g_MaxPlayers = get_maxplayers()
    124. }
    125.  
    126. public plugin_precache()
    127. {
    128.     precache_model(RAILCANNON_V_MODEL)
    129.     precache_model(RAILCANNON_P_MODEL)
    130.     precache_model(RAILCANNON_W_MODEL)
    131.     precache_sound(Fire_Sounds)
    132.        
    133.     sTrail = precache_model("sprites/laserbeam.spr")
    134.    
    135.     precache_sound("weapons/railcanon_clipin.wav")
    136.     precache_sound("weapons/railcanon_chage1_start.wav")
    137.     precache_sound("weapons/railcanon_chage3_loop.wav")
    138.     precache_sound("weapons/railcanon_draw.wav")
    139.     precache_sound("weapons/railcanon_clipout.wav")
    140.     precache_sound("weapons/railcanon-2.wav")
    141.    
    142.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
    143.     precache_generic("sprites/weapon_railcannon.txt")
    144.    
    145.     precache_generic("sprites/640hud112.spr")
    146.     precache_generic("sprites/640hud13.spr")
    147.        
    148.     register_clcmd("weapon_railcannon", "weapon_hook") 
    149.                    
    150.     m_iBlood[0] = precache_model("sprites/blood.spr")
    151.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    152.     precache_model("sprites/wall_puff1.spr")
    153.  
    154.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
    155. }
    156.  
    157. public weapon_hook(id)
    158. {
    159.     engclient_cmd(id, "weapon_m3")
    160.     return PLUGIN_HANDLED
    161. }
    162.  
    163. public client_putinserver(id)
    164. {
    165.     if(!g_Ham_Bot && is_user_bot(id))
    166.     {
    167.         g_Ham_Bot = 1
    168.         set_task(0.1, "Do_RegisterHam_Bot", id)
    169.     }
    170. }
    171.  
    172. public Do_RegisterHam_Bot(id)
    173. {
    174.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
    175.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
    176. }
    177.  
    178. public ze_select_item_pre(id, itemid)
    179. {
    180.     // This not our item?
    181.     if (itemid != g_iItemID)
    182.         return ZE_ITEM_AVAILABLE
    183.    
    184.     // Available for Humans only, So don't show it for zombies
    185.     if (ze_is_user_zombie(id))
    186.         return ZE_ITEM_DONT_SHOW
    187.    
    188.     // Finally return that it's available
    189.     return ZE_ITEM_AVAILABLE
    190. }
    191.  
    192. public ze_select_item_post(id, itemid)
    193. {
    194.     // This is not our item, Block it here and don't execute the blew code
    195.     if (itemid != g_iItemID)
    196.         return
    197.    
    198.     give_railcannon(id)
    199. }
    200.  
    201. public ze_user_infected(id)
    202. {
    203.     update_specialammo(id, g_SpecialAmmo[id], 0)
    204.     g_has_railcannon[id] = false
    205.     g_SpecialAmmo[id] = 0
    206. }
    207.  
    208. public fw_PlayerKilled(id)
    209. {
    210.     g_has_railcannon[id] = false
    211. }
    212.  
    213. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
    214. {
    215.     if(!is_user_alive(iAttacker))
    216.         return
    217.  
    218.     new g_currentweapon = get_user_weapon(iAttacker)
    219.  
    220.     if(g_currentweapon != CSW_M3 || !g_has_railcannon[iAttacker])
    221.         return
    222.    
    223.     if(railcannon_mode[iAttacker] == 3) SetHamParamFloat(3, 60.0)
    224.     if(railcannon_mode[iAttacker] == 2) SetHamParamFloat(3, 35.0)
    225.     if(railcannon_mode[iAttacker] == 1) SetHamParamFloat(3, 20.0)
    226.    
    227.     static Float:flEnd[3], Float:test[3], Float:myOrigin[3]
    228.    
    229.     pev(iAttacker, pev_origin, myOrigin)
    230.     get_tr2(ptr, TR_vecEndPos, flEnd)
    231.        
    232.     if(!is_user_alive(iEnt))
    233.     {
    234.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    235.         write_byte(TE_DECAL)
    236.         write_coord_f(flEnd[0])
    237.         write_coord_f(flEnd[1])
    238.         write_coord_f(flEnd[2])
    239.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    240.         write_short(iEnt)
    241.         message_end()
    242.  
    243.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    244.         write_byte(TE_WORLDDECAL)
    245.         write_coord_f(flEnd[0])
    246.         write_coord_f(flEnd[1])
    247.         write_coord_f(flEnd[2])
    248.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    249.         message_end()
    250.        
    251.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    252.         write_byte(TE_GUNSHOTDECAL)
    253.         write_coord_f(flEnd[0])
    254.         write_coord_f(flEnd[1])
    255.         write_coord_f(flEnd[2])
    256.         write_short(iAttacker)
    257.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    258.         message_end()
    259.        
    260.         fm_get_aim_origin(iAttacker, test)
    261.         if(railcannon_mode[iAttacker] == 3) fake_smokes(iAttacker, test)
    262.     }
    263.    
    264.     if(railcannon_mode[iAttacker] == 2)
    265.     {
    266.         get_position(iAttacker, 20.0, 0.0, 10.0, StartOrigin2)
    267.        
    268.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    269.         write_byte(TE_BEAMPOINTS)
    270.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    271.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    272.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    273.         engfunc(EngFunc_WriteCoord, flEnd[0])
    274.         engfunc(EngFunc_WriteCoord, flEnd[1])
    275.         engfunc(EngFunc_WriteCoord, flEnd[2])
    276.         write_short(sTrail)
    277.         write_byte(0) // start frame
    278.         write_byte(0) // framerate
    279.         write_byte(5) // life
    280.         write_byte(5) // line width
    281.         write_byte(0) // amplitude
    282.         write_byte(220)
    283.         write_byte(88)
    284.         write_byte(0) // blue
    285.         write_byte(255) // brightness
    286.         write_byte(0) // speed
    287.         message_end()
    288.     }
    289.    
    290.     if(railcannon_mode[iAttacker] == 3)
    291.     {
    292.         get_position(iAttacker, 20.0, 5.0, 5.0, StartOrigin2)
    293.        
    294.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    295.         write_byte(TE_BEAMPOINTS)
    296.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    297.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    298.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    299.         engfunc(EngFunc_WriteCoord, flEnd[0])
    300.         engfunc(EngFunc_WriteCoord, flEnd[1])
    301.         engfunc(EngFunc_WriteCoord, flEnd[2])
    302.         write_short(sTrail)
    303.         write_byte(0) // start frame
    304.         write_byte(0) // framerate
    305.         write_byte(8) // life
    306.         write_byte(8) // line width
    307.         write_byte(0) // amplitude
    308.         write_byte(220)
    309.         write_byte(88)
    310.         write_byte(0) // blue
    311.         write_byte(50) // brightness
    312.         write_byte(0) // speed
    313.         message_end()
    314.        
    315.         if(!is_user_alive(iEnt))
    316.             return
    317.        
    318.         if(ze_is_user_zombie(iEnt) && g_KnockBack == 1) knockback(iEnt, myOrigin, 42.0, 2)
    319.     }
    320.    
    321. }
    322.  
    323. public fake_smokes(id, Float:Origin[3])
    324. {
    325.     new ent_test; ent_test = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
    326.    
    327.     engfunc(EngFunc_SetModel, ent_test, "sprites/wall_puff1.spr")
    328.     entity_set_string(ent_test, EV_SZ_classname, SMOKE_CLASS)
    329.     set_pev(ent_test, pev_nextthink, get_gametime() + 0.04)
    330.     set_pev(ent_test, pev_movetype, MOVETYPE_NONE)
    331.     set_pev(ent_test, pev_rendermode, kRenderTransAdd)
    332.     set_pev(ent_test, pev_renderamt, 20.0)
    333.     set_pev(ent_test, pev_scale, 1.0)
    334.     set_pev(ent_test, pev_origin, Origin)
    335.     set_pev(ent_test, pev_frame, 0.0)
    336.     set_pev(ent_test, pev_iuser2, get_user_team(id))
    337.  
    338.     set_pev(ent_test, pev_solid, SOLID_NOT)
    339.     dllfunc(DLLFunc_Spawn, ent_test)
    340. }
    341.  
    342. public fw_Fire_smoke(iEnt)
    343. {
    344.     if(!pev_valid(iEnt))
    345.         return
    346.    
    347.     new Float:fFrame
    348.     pev(iEnt, pev_frame, fFrame)
    349.  
    350.     // effect exp
    351.     fFrame += 1.0
    352.  
    353.     set_pev(iEnt, pev_frame, fFrame)
    354.     set_pev(iEnt, pev_scale, 1.0)
    355.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.02)
    356.    
    357.     if(fFrame > 30.0) engfunc(EngFunc_RemoveEntity, iEnt)
    358. }
    359.  
    360. public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id,ptr)
    361. {
    362.     if(!is_user_alive(id))
    363.         return HAM_IGNORED 
    364.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    365.         return HAM_IGNORED
    366.     if(railcannon_mode[id] != 3)
    367.         return HAM_IGNORED
    368.    
    369.     // get crosshair aim
    370.     static Float:aim[3];
    371.     get_aim(id,v1,aim);
    372.    
    373.     // do another trace to this spot
    374.     new trace = create_tr2();
    375.     engfunc(EngFunc_TraceLine,v1,aim,noMonsters,id,trace);
    376.    
    377.     // copy ints
    378.     set_tr2(ptr,TR_AllSolid,get_tr2(trace,TR_AllSolid));
    379.     set_tr2(ptr,TR_StartSolid,get_tr2(trace,TR_StartSolid));
    380.     set_tr2(ptr,TR_InOpen,get_tr2(trace,TR_InOpen));
    381.     set_tr2(ptr,TR_InWater,get_tr2(trace,TR_InWater));
    382.     set_tr2(ptr,TR_pHit,get_tr2(trace,TR_pHit));
    383.     set_tr2(ptr,TR_iHitgroup,get_tr2(trace,TR_iHitgroup));
    384.  
    385.     // copy floats
    386.     get_tr2(trace,TR_flFraction,aim[0]);
    387.     set_tr2(ptr,TR_flFraction,aim[0]);
    388.     get_tr2(trace,TR_flPlaneDist,aim[0]);
    389.     set_tr2(ptr,TR_flPlaneDist,aim[0]);
    390.    
    391.     // copy vecs
    392.     get_tr2(trace,TR_vecEndPos,aim);
    393.     set_tr2(ptr,TR_vecEndPos,aim);
    394.     get_tr2(trace,TR_vecPlaneNormal,aim);
    395.     set_tr2(ptr,TR_vecPlaneNormal,aim);
    396.  
    397.     // get rid of new trace
    398.     free_tr2(trace);
    399.  
    400.     return FMRES_IGNORED;
    401. }
    402.  
    403. get_aim(id,Float:source[3],Float:ret[3])
    404. {
    405.     static Float:vAngle[3], Float:pAngle[3], Float:dir[3], Float:temp[3];
    406.  
    407.     // get aiming direction from forward global based on view angle and punch angle
    408.     pev(id,pev_v_angle,vAngle);
    409.     pev(id,pev_punchangle,pAngle);
    410.     xs_vec_add(vAngle,pAngle,temp);
    411.     engfunc(EngFunc_MakeVectors,temp);
    412.     global_get(glb_v_forward,dir);
    413.    
    414.     /* vecEnd = vecSrc + vecDir * flDistance; */
    415.     xs_vec_mul_scalar(dir,8192.0,temp);
    416.     xs_vec_add(source,temp,ret);
    417. }
    418.  
    419. public fwPrecacheEvent_Post(type, const name[])
    420. {
    421.     if (equal("events/m3.sc", name))
    422.     {
    423.         g_orig_event_railcannon = get_orig_retval()
    424.         return FMRES_HANDLED
    425.     }
    426.     return FMRES_IGNORED
    427. }
    428.  
    429. public client_connect(id)
    430. {
    431.     g_has_railcannon[id] = false
    432. }
    433.  
    434. public client_disconnect(id)
    435. {
    436.     g_has_railcannon[id] = false
    437. }
    438.  
    439. public fw_SetModel(entity, model[])
    440. {
    441.     if(!is_valid_ent(entity))
    442.         return FMRES_IGNORED
    443.    
    444.     static szClassName[33]
    445.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    446.        
    447.     if(!equal(szClassName, "weaponbox"))
    448.         return FMRES_IGNORED
    449.    
    450.     static iOwner
    451.    
    452.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    453.    
    454.     if(equal(model, "models/w_m3.mdl"))
    455.     {
    456.         static iStoredAugID
    457.        
    458.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_m3", entity)
    459.    
    460.         if(!is_valid_ent(iStoredAugID))
    461.             return FMRES_IGNORED
    462.    
    463.         if(g_has_railcannon[iOwner])
    464.         {
    465.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, RAILCANNON_WEAPONKEY)
    466.            
    467.             g_has_railcannon[iOwner] = false
    468.            
    469.             entity_set_model(entity, RAILCANNON_W_MODEL)
    470.            
    471.             return FMRES_SUPERCEDE
    472.         }
    473.     }
    474.     return FMRES_IGNORED
    475. }
    476.  
    477. public give_railcannon(id)
    478. {
    479.     drop_weapons(id, 1)
    480.     new iWep2 = give_item(id,"weapon_m3")
    481.     if( iWep2 > 0 )
    482.     {
    483.         cs_set_weapon_ammo(iWep2, cvar_clip_railcannon)
    484.         cs_set_user_bpammo (id, CSW_M3, cvar_railcannon_ammo)
    485.         UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    486.         set_weapons_timeidle(id, CSW_M3, 1.0)
    487.         set_player_nextattackx(id, 1.0)
    488.         g_clip_ammo[id] = cs_get_weapon_ammo(iWep2)
    489.     }
    490.     g_has_railcannon[id] = true
    491.     g_SpecialAmmo[id] = 0
    492.     udah[id] = 0
    493.     zz[id] = 0
    494.     railcannon_mode[id] = 1
    495.     update_specialammo(id, g_SpecialAmmo[id], g_SpecialAmmo[id] > 0 ? 1 : 0)
    496.     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    497.     write_string("weapon_railcannon")
    498.     write_byte(5)
    499.     write_byte(32)
    500.     write_byte(-1)
    501.     write_byte(-1)
    502.     write_byte(0)
    503.     write_byte(5)
    504.     write_byte(21)
    505.     write_byte(0)
    506.     message_end()
    507. }
    508.  
    509. public fw_RAILCANNON_AddToPlayer(railcannon, id)
    510. {
    511.     if(!is_valid_ent(railcannon) || !is_user_connected(id))
    512.         return HAM_IGNORED
    513.    
    514.     if(entity_get_int(railcannon, EV_INT_WEAPONKEY) == RAILCANNON_WEAPONKEY)
    515.     {
    516.         g_has_railcannon[id] = true
    517.        
    518.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    519.         write_string("weapon_railcannon")
    520.         write_byte(5)
    521.         write_byte(32)
    522.         write_byte(-1)
    523.         write_byte(-1)
    524.         write_byte(0)
    525.         write_byte(5)
    526.         write_byte(21)
    527.         write_byte(0)
    528.         message_end()
    529.        
    530.         entity_set_int(railcannon, EV_INT_WEAPONKEY, 0)
    531.         update_specialammo(id, g_SpecialAmmo[id], 0)
    532.         g_SpecialAmmo[id] = 0
    533.  
    534.         return HAM_HANDLED
    535.     }
    536.     return HAM_IGNORED
    537. }
    538.  
    539. public fw_UseStationary_Post(entity, caller, activator, use_type)
    540. {
    541.     if (use_type == USE_STOPPED && is_user_connected(caller))
    542.         replace_weapon_models(caller, get_user_weapon(caller))
    543. }
    544.  
    545. public fw_Item_Deploy_Post(weapon_ent)
    546. {
    547.     static owner
    548.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
    549.    
    550.     static weaponid
    551.     weaponid = cs_get_weapon_id(weapon_ent)
    552.    
    553.     update_specialammo(owner, g_SpecialAmmo[owner], 0)
    554.     g_SpecialAmmo[owner] = 0
    555.    
    556.     replace_weapon_models(owner, weaponid)
    557. }
    558.  
    559. public CurrentWeapon(id)
    560. {
    561.     if( read_data(2) != CSW_M3 ) {
    562.         if( g_reload[id] ) {
    563.             g_reload[id] = 0
    564.             remove_task( id + 1331 )
    565.         }
    566.     }
    567.     replace_weapon_models(id, read_data(2))
    568. }
    569.  
    570. replace_weapon_models(id, weaponid)
    571. {
    572.     switch (weaponid)
    573.     {
    574.         case CSW_M3:
    575.         {
    576.             if(g_has_railcannon[id])
    577.             {
    578.                 set_pev(id, pev_viewmodel2, RAILCANNON_V_MODEL)
    579.                 set_pev(id, pev_weaponmodel2, RAILCANNON_P_MODEL)
    580.                 if(oldweap[id] != CSW_M3)
    581.                 {
    582.                     set_weapons_timeidle(id, CSW_M3, 1.0)
    583.                     set_player_nextattackx(id, 1.0)
    584.                     UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    585.                     udah[id] = 0
    586.                     zz[id] = 0
    587.                     railcannon_mode[id] = 1
    588.                     remove_task(id+TASK_SOUND)
    589.                     remove_task(id)
    590.  
    591.                     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    592.                     write_string("weapon_railcannon")
    593.                     write_byte(5)
    594.                     write_byte(32)
    595.                     write_byte(-1)
    596.                     write_byte(-1)
    597.                     write_byte(0)
    598.                     write_byte(5)
    599.                     write_byte(CSW_M3)
    600.                     message_end()
    601.                 }
    602.             }
    603.         }
    604.     }
    605.     oldweap[id] = weaponid
    606. }
    607.  
    608. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
    609. {
    610.     if(!is_user_alive(Player) || get_user_weapon(Player) != CSW_M3 || !g_has_railcannon[Player])
    611.         return FMRES_IGNORED
    612.    
    613.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    614.     return FMRES_HANDLED
    615. }
    616.  
    617. public fw_RAIL_PrimaryAttack(Weapon)
    618. {
    619.     new Player = get_pdata_cbase(Weapon, 41, 4)
    620.    
    621.     if (!g_has_railcannon[Player])
    622.         return
    623.    
    624.     g_IsInPrimaryAttack = 1
    625.     pev(Player,pev_punchangle,cl_pushangle[Player])
    626.    
    627.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
    628.     if(g_clip_ammo[Player]) Make_Muzzleflash(Player)
    629. }
    630.  
    631. public fw_RAIL_PrimaryAttack_Post(Weapon)
    632. {
    633.     g_IsInPrimaryAttack = 0
    634.     new Player = get_pdata_cbase(Weapon, 41, 4)
    635.    
    636.     new szClip, szAmmo
    637.     get_user_weapon(Player, szClip, szAmmo)
    638.    
    639.     if(!is_user_alive(Player))
    640.         return
    641.  
    642.     if(g_has_railcannon[Player])
    643.     {
    644.         if (!g_clip_ammo[Player] && railcannon_mode[Player] == 1)
    645.             return
    646.        
    647.         g_reload[Player] = 0
    648.         remove_task( Player + 1331 )
    649.         new Float:push[3]
    650.         pev(Player,pev_punchangle,push)
    651.         xs_vec_sub(push,cl_pushangle[Player],push)
    652.         xs_vec_mul_scalar(push,cvar_recoil_railcannon,push)
    653.         xs_vec_add(push,cl_pushangle[Player],push)
    654.         set_pev(Player,pev_punchangle,push)
    655.        
    656.         UTIL_PlayWeaponAnimation(Player,random_num(4,5))
    657.         set_weapons_timeidle(Player, CSW_M3, 0.3)
    658.         set_player_nextattackx(Player, 0.3)
    659.         g_clip_ammo[Player] --
    660.        
    661.         if(railcannon_mode[Player] == 3) emit_sound(Player, CHAN_WEAPON, "weapons/railcanon-2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    662.         else emit_sound(Player, CHAN_WEAPON, Fire_Sounds, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    663.        
    664.         railcannon_mode[Player] = 1
    665.     }
    666. }
    667.  
    668. public Make_Muzzleflash(id)
    669. {
    670.     static Float:Origin[3], TE_FLAG
    671.     get_position(id, 32.0, 6.0, -15.0, Origin)
    672.    
    673.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    674.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
    675.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
    676.    
    677.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
    678.     write_byte(TE_EXPLOSION)
    679.     engfunc(EngFunc_WriteCoord, Origin[0])
    680.     engfunc(EngFunc_WriteCoord, Origin[1])
    681.     engfunc(EngFunc_WriteCoord, Origin[2])
    682.     write_short(g_MuzzleFlash_SprId)
    683.     write_byte(2)
    684.     write_byte(30)
    685.     write_byte(TE_FLAG)
    686.     message_end()
    687. }
    688.  
    689. public fw_CmdStart(id, uc_handle, seed)
    690. {
    691.     new ammo, clip, weapon = get_user_weapon(id, clip, ammo)
    692.     if (!g_has_railcannon[id] || weapon != CSW_M3 || !is_user_alive(id))
    693.         return
    694.    
    695.     static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    696.        
    697.     if(!pev_valid(ent))
    698.         return
    699.        
    700.     static CurButton
    701.     CurButton = get_uc(uc_handle, UC_Buttons)
    702.    
    703.     if(CurButton & IN_ATTACK)
    704.     {
    705.         new wpn = fm_get_user_weapon_entity(id, get_user_weapon(id))
    706.        
    707.         new Id = pev( wpn, pev_owner ), clip, bpammo
    708.         get_user_weapon( Id, clip, bpammo )
    709.         if( g_has_railcannon[ Id ] ) {
    710.         if( clip >= 2 ) {
    711.             if( g_reload[Id] ) {
    712.                 remove_task( Id + 1331 )
    713.                 g_reload[Id] = 0
    714.             }
    715.         }
    716.         else if( clip == 1 )
    717.         {
    718.             if(get_pdata_float(Id, 83, 4) <= 0.3)
    719.             {
    720.                 if( g_reload[Id] ) {
    721.                 remove_task( Id + 1331 )
    722.                 g_reload[Id] = 0
    723.             }
    724.             }
    725.         }
    726.     }
    727.     }
    728.    
    729.     else if(CurButton & IN_ATTACK2)
    730.     {
    731.         if(!zz[id] && get_pdata_float(id, 83, 4) <= 0.0 && g_clip_ammo[id] >= 1)
    732.         {
    733.             set_weapons_timeidle(id, CSW_M3, 200.0)
    734.             set_player_nextattackx(id, 200.0)
    735.             UTIL_PlayWeaponAnimation(id, 1)
    736.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage1_start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    737.             set_task(0.6, "charge_idle2", id)
    738.             zz[id] = 1
    739.             udah[id] = 0
    740.             railcannon_mode[id] = 2
    741.            
    742.             update_specialammo(id, g_SpecialAmmo[id], 0)
    743.             g_SpecialAmmo[id] ++
    744.             update_specialammo(id, g_SpecialAmmo[id], 1)
    745.            
    746.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    747.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    748.             g_clip_ammo[id] --
    749.         }
    750.     }
    751.    
    752.     else if(!(pev(id, pev_oldbuttons) & IN_ATTACK) && zz[id])
    753.     {
    754.         zz[id] = 0
    755.         if(udah[id])
    756.         {
    757.             if(g_clip_ammo[id] >= 1)
    758.             {
    759.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    760.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    761.                 set_player_nextattackx(id, 1.1)
    762.                 udah[id] = 0
    763.                 remove_task(id+TASK_SOUND)
    764.                
    765.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    766.                 g_SpecialAmmo[id] = 0
    767.                
    768.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    769.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    770.                 g_clip_ammo[id] ++
    771.             }
    772.             else
    773.             {
    774.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    775.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    776.                 g_clip_ammo[id] ++
    777.                
    778.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    779.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    780.                 set_player_nextattackx(id, 1.1)
    781.                 udah[id] = 0
    782.                 remove_task(id+TASK_SOUND)
    783.                
    784.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    785.                 g_SpecialAmmo[id] = 0
    786.             }
    787.         }
    788.     }
    789. }
    790.  
    791. public charge_idle2(id)
    792. {
    793.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    794.         return
    795.     if(zz[id])
    796.     {
    797.         if(g_clip_ammo[id] >= 1)
    798.         {
    799.             UTIL_PlayWeaponAnimation(id, 2)
    800.             set_weapons_timeidle(id, CSW_M3, 200.0)
    801.             set_player_nextattackx(id, 200.0)
    802.             set_task(0.6, "charge_idle3", id)
    803.            
    804.             update_specialammo(id, g_SpecialAmmo[id], 0)
    805.             g_SpecialAmmo[id] ++
    806.             update_specialammo(id, g_SpecialAmmo[id], 1)
    807.            
    808.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    809.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    810.             g_clip_ammo[id] --
    811.         }
    812.         else
    813.         {
    814.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    815.        
    816.             if(!pev_valid(ent))
    817.                 return
    818.            
    819.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    820.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    821.             g_clip_ammo[id] ++
    822.            
    823.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    824.             set_weapons_timeidle(id, CSW_M3, 1.1)
    825.             set_player_nextattackx(id, 1.1)
    826.            
    827.             update_specialammo(id, g_SpecialAmmo[id], 0)
    828.             g_SpecialAmmo[id] = 0
    829.         }
    830.     }
    831.     else
    832.     {
    833.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    834.        
    835.         if(!pev_valid(ent))
    836.             return
    837.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    838.         set_weapons_timeidle(id, CSW_M3, 1.1)
    839.         set_player_nextattackx(id, 1.1)
    840.        
    841.         update_specialammo(id, g_SpecialAmmo[id], 0)
    842.         g_SpecialAmmo[id] = 0
    843.        
    844.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    845.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    846.         g_clip_ammo[id] ++
    847.     }
    848. }
    849.  
    850. public charge_idle3(id)
    851. {
    852.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    853.         return
    854.     if(zz[id])
    855.     {
    856.         if(g_clip_ammo[id] >= 1)
    857.         {
    858.             UTIL_PlayWeaponAnimation(id, 3)
    859.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    860.             set_task(0.794, "play_sound", id+TASK_SOUND,_,_,"b")
    861.             udah[id] = 1
    862.             railcannon_mode[id] = 3
    863.             set_weapons_timeidle(id, CSW_M3, 200.0)
    864.             set_player_nextattackx(id, 200.0)
    865.            
    866.             update_specialammo(id, g_SpecialAmmo[id], 0)
    867.             g_SpecialAmmo[id] ++
    868.             update_specialammo(id, g_SpecialAmmo[id], 1)
    869.            
    870.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    871.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    872.             g_clip_ammo[id] --
    873.         }
    874.         else
    875.         {
    876.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    877.        
    878.             if(!pev_valid(ent))
    879.                 return
    880.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    881.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    882.             g_clip_ammo[id] ++
    883.            
    884.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    885.             set_weapons_timeidle(id, CSW_M3, 1.1)
    886.             set_player_nextattackx(id, 1.1)
    887.            
    888.             update_specialammo(id, g_SpecialAmmo[id], 0)
    889.             g_SpecialAmmo[id] = 0
    890.         }
    891.     }
    892.     else
    893.     {
    894.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    895.        
    896.         if(!pev_valid(ent))
    897.             return
    898.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    899.         set_weapons_timeidle(id, CSW_M3, 1.1)
    900.         set_player_nextattackx(id, 1.1)
    901.        
    902.         update_specialammo(id, g_SpecialAmmo[id], 0)
    903.         g_SpecialAmmo[id] = 0
    904.        
    905.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    906.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    907.         g_clip_ammo[id] ++
    908.     }
    909. }
    910.  
    911. public play_sound(id)
    912. {
    913.     id -= TASK_SOUND
    914.    
    915.     if(!is_user_alive(id) || get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    916.         return
    917.    
    918.     emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    919. }
    920.  
    921. public fw_railcannonidleanim(Weapon)
    922. {
    923.     new id = get_pdata_cbase(Weapon, 41, 4)
    924.  
    925.     if(!is_user_alive(id) || !g_has_railcannon[id] || get_user_weapon(id) != CSW_M3)
    926.         return HAM_IGNORED;
    927.    
    928.     if(railcannon_mode[id] == 1 && get_pdata_float(Weapon, 48, 4) <= 0.25)
    929.     {
    930.         UTIL_PlayWeaponAnimation(id, 0)
    931.         set_pdata_float(Weapon, 48, 20.0, 4)
    932.         return HAM_SUPERCEDE;
    933.     }
    934.    
    935.     if(railcannon_mode[id] == 3 && get_pdata_float(Weapon, 48, 4) <= 0.01)
    936.     {
    937.         UTIL_PlayWeaponAnimation(id, 3)
    938.         set_pdata_float(Weapon, 48, 1.7, 4)
    939.         return HAM_SUPERCEDE;
    940.     }
    941.  
    942.     return HAM_IGNORED;
    943. }
    944.  
    945. public update_specialammo(id, Ammo, On)
    946. {
    947.     static AmmoSprites[33]
    948.     format(AmmoSprites, sizeof(AmmoSprites), "number_%d", Ammo)
    949.    
    950.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("StatusIcon"), {0,0,0}, id)
    951.     write_byte(On)
    952.     write_string(AmmoSprites)
    953.     write_byte(42) // red
    954.     write_byte(255) // green
    955.     write_byte(42) // blue
    956.     message_end()
    957. }
    958.  
    959. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    960. {
    961.     if ((eventid != g_orig_event_railcannon) || !g_IsInPrimaryAttack)
    962.         return FMRES_IGNORED
    963.        
    964.     if (!(1 <= invoker <= g_MaxPlayers))
    965.         return FMRES_IGNORED
    966.  
    967.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    968.     return FMRES_SUPERCEDE
    969. }
    970.  
    971. public RAILCANNON_Reload( wpn ) {
    972.     if(railcannon_mode[pev( wpn, pev_owner )] == 3)
    973.           return HAM_SUPERCEDE
    974.          
    975.     if( g_has_railcannon[ pev( wpn, pev_owner ) ] ) {
    976.         RAILCANNON_Reload_Post( wpn )
    977.         return HAM_SUPERCEDE
    978.     }
    979.     return HAM_IGNORED
    980. }
    981.  
    982. public RAILCANNON_Reload_Post(weapon) {
    983.     new id = pev( weapon, pev_owner )
    984.     if(railcannon_mode[id] == 3 || g_reload[id])
    985.           return HAM_SUPERCEDE
    986.     new clip, bpammo
    987.     get_user_weapon(id, clip, bpammo )
    988.     if( g_has_railcannon[ id ] && clip < cvar_clip_railcannon && bpammo > 0 ) {
    989.         if(!task_exists( id+1331 )) set_task( 0.1, "reload", id+1331 )
    990.         }
    991.     return HAM_IGNORED
    992. }
    993.  
    994. public reload( id ) {
    995.     id -= 1331
    996.     set_weapons_timeidle(id, CSW_M3, 3.0)
    997.     set_player_nextattackx(id, 3.0)
    998.     UTIL_PlayWeaponAnimation(id, 6)
    999.     g_reload[id] = 1
    1000.     set_task(3.0, "isi", id)
    1001. }
    1002.  
    1003. public isi(id)
    1004. {
    1005.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    1006.         return
    1007.    
    1008.     if(!g_reload[id])
    1009.         return
    1010.    
    1011.     new clip, pluru, pengurang, bpammo, weapon = find_ent_by_owner( -1, "weapon_m3", id )
    1012.     get_user_weapon(id, clip, bpammo )
    1013.     pengurang = cvar_clip_railcannon - clip
    1014.     pluru = bpammo - pengurang
    1015.     cs_set_user_bpammo( id, CSW_M3, pluru )
    1016.    
    1017.     if(bpammo <= pengurang) cs_set_weapon_ammo( weapon, clip + bpammo)
    1018.     else cs_set_weapon_ammo( weapon, cvar_clip_railcannon)
    1019.    
    1020.     g_clip_ammo[id] = cvar_clip_railcannon
    1021. }
    1022.  
    1023. stock knockback(ent, Float:VicOrigin[3], Float:speed, type)
    1024. {
    1025.     static Float:fl_Velocity[3]
    1026.     static Float:EntOrigin[3]
    1027.     static Float:EntVelocity[3]
    1028.    
    1029.     pev(ent, pev_velocity, EntVelocity)
    1030.     pev(ent, pev_origin, EntOrigin)
    1031.     static Float:distance_f
    1032.     distance_f = get_distance_f(EntOrigin, VicOrigin)
    1033.    
    1034.     static Float:fl_Time; fl_Time = distance_f / speed
    1035.    
    1036.     if(type == 1)
    1037.     {
    1038.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
    1039.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
    1040.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time       
    1041.         } else if(type == 2) {
    1042.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
    1043.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
    1044.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
    1045.     }
    1046.    
    1047.     xs_vec_add(EntVelocity, fl_Velocity, fl_Velocity)
    1048.     set_pev(ent, pev_velocity, fl_Velocity)
    1049. }
    1050.  
    1051. stock fm_cs_get_current_weapon_ent(id)
    1052. {
    1053.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
    1054. }
    1055.  
    1056. stock fm_set_weapon_ammo(entity, amount)
    1057. {
    1058.     set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
    1059. }
    1060.  
    1061. stock fm_cs_get_weapon_ent_owner(ent)
    1062. {
    1063.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
    1064. }
    1065.  
    1066. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
    1067. {
    1068.     set_pev(Player, pev_weaponanim, Sequence)
    1069.    
    1070.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    1071.     write_byte(Sequence)
    1072.     write_byte(pev(Player, pev_body))
    1073.     message_end()
    1074. }
    1075.  
    1076. stock set_player_nextattackx(id, Float:nexttime)
    1077. {
    1078.     if(!is_user_alive(id))
    1079.         return
    1080.        
    1081.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
    1082. }
    1083.  
    1084. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
    1085. {
    1086.     new Float:vfEnd[3], viEnd[3]
    1087.     get_user_origin(id, viEnd, 3)  
    1088.     IVecFVec(viEnd, vfEnd)
    1089.    
    1090.     new Float:fOrigin[3], Float:fAngle[3]
    1091.    
    1092.     pev(id, pev_origin, fOrigin)
    1093.     pev(id, pev_view_ofs, fAngle)
    1094.    
    1095.     xs_vec_add(fOrigin, fAngle, fOrigin)
    1096.    
    1097.     new Float:fAttack[3]
    1098.    
    1099.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1100.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1101.    
    1102.     new Float:fRate
    1103.    
    1104.     fRate = fDis / vector_length(fAttack)
    1105.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
    1106.    
    1107.     xs_vec_add(fOrigin, fAttack, output)
    1108. }
    1109.  
    1110. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
    1111. {
    1112.     if(!is_user_alive(id))
    1113.         return
    1114.        
    1115.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
    1116.     if(!pev_valid(entwpn))
    1117.         return
    1118.        
    1119.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1120.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1121.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, WEAP_LINUX_XTRA_OFF)
    1122. }
    1123.  
    1124. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
    1125. {
    1126.     new_velocity[0] = origin2[0] - origin1[0]
    1127.     new_velocity[1] = origin2[1] - origin1[1]
    1128.     new_velocity[2] = origin2[2] - origin1[2]
    1129.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    1130.     new_velocity[0] *= num
    1131.     new_velocity[1] *= num
    1132.     new_velocity[2] *= num
    1133.    
    1134.     return 1;
    1135. }
    1136.  
    1137. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
    1138. {
    1139.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    1140.    
    1141.     pev(id, pev_origin, vOrigin)
    1142.     pev(id, pev_view_ofs, vUp) //for player
    1143.     xs_vec_add(vOrigin, vUp, vOrigin)
    1144.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
    1145.    
    1146.     angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
    1147.     angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
    1148.     angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
    1149.    
    1150.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    1151.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    1152.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
    1153. }
    1154.  
    1155.  
    1156. stock drop_weapons(id, dropwhat)
    1157. {
    1158.     static weapons[32], num, i, weaponid
    1159.     num = 0
    1160.     get_user_weapons(id, weapons, num)
    1161.      
    1162.     for (i = 0; i < num; i++)
    1163.     {
    1164.         weaponid = weapons[i]
    1165.          
    1166.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    1167.         {
    1168.             static wname[32]
    1169.             get_weaponname(weaponid, wname, sizeof wname - 1)
    1170.             engclient_cmd(id, "drop", wname)
    1171.         }
    1172.     }
    1173. }

Try this Bro ... And Test it and then report here
Nobody Is That Busy If They Make Time :roll:

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

#4

Post by Raheem » 2 Years Ago

johnnysins2000 wrote:
2 Years Ago
Code:
    1. #include <zombie_escape>
    2. #include <fakemeta_util>
    3. #include <xs>
    4. #include <cstrike>
    5.  
    6. #define ENG_NULLENT     -1
    7. #define EV_INT_WEAPONKEY    EV_INT_impulse
    8. #define RAILCANNON_WEAPONKEY 756144798
    9. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
    10.  
    11. #define SMOKE_CLASS "smokess"
    12.  
    13. #define ENABLE_KNOCKBACK 1
    14.  
    15. const USE_STOPPED = 0
    16. const OFFSET_ACTIVE_ITEM = 373
    17. const OFFSET_WEAPONOWNER = 41
    18. const OFFSET_LINUX = 5
    19. const OFFSET_LINUX_WEAPONS = 4
    20.  
    21. #if cellbits == 32
    22. const OFFSET_CLIPAMMO = 51
    23. #else
    24. const OFFSET_CLIPAMMO = 65
    25. #endif
    26.  
    27. #define WEAP_LINUX_XTRA_OFF     4
    28. #define m_fKnown                    44
    29. #define m_flNextPrimaryAttack       46
    30. #define m_flNextSecondaryAttack         47
    31. #define m_flTimeWeaponIdle          48
    32. #define m_iClip                 51
    33. #define m_fInReload             54
    34. #define m_fInSpecialReload          55
    35. #define PLAYER_LINUX_XTRA_OFF   5
    36. #define m_flNextAttack              83
    37.  
    38. #define RAILCANNON_DRAW         7
    39.  
    40. #define TASK_SOUND 2573+10
    41. #define TASK_SETRUM2 2573+20
    42.  
    43. new gmsgWeaponList, sTrail
    44.  
    45. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    46.  
    47. new const Fire_Sounds[] = "weapons/railcanon-1.wav"
    48. new const MuzzleFlash[] = "sprites/muzzleflash19.spr"
    49.  
    50. //////////// Change Here For Customize //////////////////////////
    51.  
    52. const Float:cvar_recoil_railcannon = 0.65
    53. const cvar_clip_railcannon = 24
    54. const cvar_railcannon_ammo = 90
    55.  
    56. const Float:damage_mode1 = 20.0
    57. const Float:damage_mode2 = 35.0
    58. const Float:damage_mode3 = 60.0
    59.  
    60. /////////////////////////////////////////////////////////////////
    61. new RAILCANNON_V_MODEL[64] = "models/v_railcannon.mdl"
    62. new RAILCANNON_P_MODEL[64] = "models/p_railcannon.mdl"
    63. new RAILCANNON_W_MODEL[64] = "models/w_railcannon.mdl"
    64.  
    65. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    66.  
    67. new g_has_railcannon[33], g_Ham_Bot
    68.  
    69. new g_MaxPlayers, g_orig_event_railcannon, g_IsInPrimaryAttack, g_MuzzleFlash_SprId, g_iItemID, g_KnockBack
    70. new Float:cl_pushangle[33][3], m_iBlood[2], zz[33], udah[33]
    71. new g_clip_ammo[33], oldweap[33], g_reload[33], railcannon_mode[33], Float:StartOrigin2[3], g_SpecialAmmo[33]
    72. const PRIMARY_WEAPONS_BIT_SUM =
    73. (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<<
    74. 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)
    75. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
    76.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
    77.             "weapon_mp5navy", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
    78.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
    79.             "weapon_ak47", "weapon_knife", "weapon_p90" }
    80.  
    81. public plugin_init()
    82. {
    83.     register_plugin("Rail Cannon", "1.0", "m4m3ts")
    84.     register_cvar("rail_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
    85.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    86.     register_think(SMOKE_CLASS, "fw_Fire_smoke")
    87.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m3", "fw_RAILCANNON_AddToPlayer")
    88.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
    89.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
    90.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
    91.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
    92.     g_iItemID = ze_register_item("Rail Cannon", 20)
    93.    
    94.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
    95.         if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
    96.    
    97.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack")
    98.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack_Post", 1)
    99.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload")
    100.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload_Post", 1)
    101.     RegisterHam(Ham_Weapon_WeaponIdle, "weapon_m3", "fw_railcannonidleanim", 1)
    102.    
    103.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
    104.    
    105.     register_forward(FM_CmdStart, "fw_CmdStart")
    106.     register_forward(FM_SetModel, "fw_SetModel")
    107.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    108.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
    109.     register_forward(FM_TraceLine,"fw_traceline",1)
    110.    
    111.     gmsgWeaponList = get_user_msgid("WeaponList")
    112.    
    113.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
    114.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
    115.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
    116.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
    117.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
    118.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
    119.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
    120.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
    121.    
    122.     g_KnockBack = ENABLE_KNOCKBACK
    123.     g_MaxPlayers = get_maxplayers()
    124. }
    125.  
    126. public plugin_precache()
    127. {
    128.     precache_model(RAILCANNON_V_MODEL)
    129.     precache_model(RAILCANNON_P_MODEL)
    130.     precache_model(RAILCANNON_W_MODEL)
    131.     precache_sound(Fire_Sounds)
    132.        
    133.     sTrail = precache_model("sprites/laserbeam.spr")
    134.    
    135.     precache_sound("weapons/railcanon_clipin.wav")
    136.     precache_sound("weapons/railcanon_chage1_start.wav")
    137.     precache_sound("weapons/railcanon_chage3_loop.wav")
    138.     precache_sound("weapons/railcanon_draw.wav")
    139.     precache_sound("weapons/railcanon_clipout.wav")
    140.     precache_sound("weapons/railcanon-2.wav")
    141.    
    142.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
    143.     precache_generic("sprites/weapon_railcannon.txt")
    144.    
    145.     precache_generic("sprites/640hud112.spr")
    146.     precache_generic("sprites/640hud13.spr")
    147.        
    148.     register_clcmd("weapon_railcannon", "weapon_hook") 
    149.                    
    150.     m_iBlood[0] = precache_model("sprites/blood.spr")
    151.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    152.     precache_model("sprites/wall_puff1.spr")
    153.  
    154.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
    155. }
    156.  
    157. public weapon_hook(id)
    158. {
    159.     engclient_cmd(id, "weapon_m3")
    160.     return PLUGIN_HANDLED
    161. }
    162.  
    163. public client_putinserver(id)
    164. {
    165.     if(!g_Ham_Bot && is_user_bot(id))
    166.     {
    167.         g_Ham_Bot = 1
    168.         set_task(0.1, "Do_RegisterHam_Bot", id)
    169.     }
    170. }
    171.  
    172. public Do_RegisterHam_Bot(id)
    173. {
    174.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
    175.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
    176. }
    177.  
    178. public ze_select_item_pre(id, itemid)
    179. {
    180.     // This not our item?
    181.     if (itemid != g_iItemID)
    182.         return ZE_ITEM_AVAILABLE
    183.    
    184.     // Available for Humans only, So don't show it for zombies
    185.     if (ze_is_user_zombie(id))
    186.         return ZE_ITEM_DONT_SHOW
    187.    
    188.     // Finally return that it's available
    189.     return ZE_ITEM_AVAILABLE
    190. }
    191.  
    192. public ze_select_item_post(id, itemid)
    193. {
    194.     // This is not our item, Block it here and don't execute the blew code
    195.     if (itemid != g_iItemID)
    196.         return
    197.    
    198.     give_railcannon(id)
    199. }
    200.  
    201. public ze_user_infected(id)
    202. {
    203.     update_specialammo(id, g_SpecialAmmo[id], 0)
    204.     g_has_railcannon[id] = false
    205.     g_SpecialAmmo[id] = 0
    206. }
    207.  
    208. public fw_PlayerKilled(id)
    209. {
    210.     g_has_railcannon[id] = false
    211. }
    212.  
    213. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
    214. {
    215.     if(!is_user_alive(iAttacker))
    216.         return
    217.  
    218.     new g_currentweapon = get_user_weapon(iAttacker)
    219.  
    220.     if(g_currentweapon != CSW_M3 || !g_has_railcannon[iAttacker])
    221.         return
    222.    
    223.     if(railcannon_mode[iAttacker] == 3) SetHamParamFloat(3, 60.0)
    224.     if(railcannon_mode[iAttacker] == 2) SetHamParamFloat(3, 35.0)
    225.     if(railcannon_mode[iAttacker] == 1) SetHamParamFloat(3, 20.0)
    226.    
    227.     static Float:flEnd[3], Float:test[3], Float:myOrigin[3]
    228.    
    229.     pev(iAttacker, pev_origin, myOrigin)
    230.     get_tr2(ptr, TR_vecEndPos, flEnd)
    231.        
    232.     if(!is_user_alive(iEnt))
    233.     {
    234.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    235.         write_byte(TE_DECAL)
    236.         write_coord_f(flEnd[0])
    237.         write_coord_f(flEnd[1])
    238.         write_coord_f(flEnd[2])
    239.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    240.         write_short(iEnt)
    241.         message_end()
    242.  
    243.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    244.         write_byte(TE_WORLDDECAL)
    245.         write_coord_f(flEnd[0])
    246.         write_coord_f(flEnd[1])
    247.         write_coord_f(flEnd[2])
    248.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    249.         message_end()
    250.        
    251.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    252.         write_byte(TE_GUNSHOTDECAL)
    253.         write_coord_f(flEnd[0])
    254.         write_coord_f(flEnd[1])
    255.         write_coord_f(flEnd[2])
    256.         write_short(iAttacker)
    257.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    258.         message_end()
    259.        
    260.         fm_get_aim_origin(iAttacker, test)
    261.         if(railcannon_mode[iAttacker] == 3) fake_smokes(iAttacker, test)
    262.     }
    263.    
    264.     if(railcannon_mode[iAttacker] == 2)
    265.     {
    266.         get_position(iAttacker, 20.0, 0.0, 10.0, StartOrigin2)
    267.        
    268.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    269.         write_byte(TE_BEAMPOINTS)
    270.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    271.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    272.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    273.         engfunc(EngFunc_WriteCoord, flEnd[0])
    274.         engfunc(EngFunc_WriteCoord, flEnd[1])
    275.         engfunc(EngFunc_WriteCoord, flEnd[2])
    276.         write_short(sTrail)
    277.         write_byte(0) // start frame
    278.         write_byte(0) // framerate
    279.         write_byte(5) // life
    280.         write_byte(5) // line width
    281.         write_byte(0) // amplitude
    282.         write_byte(220)
    283.         write_byte(88)
    284.         write_byte(0) // blue
    285.         write_byte(255) // brightness
    286.         write_byte(0) // speed
    287.         message_end()
    288.     }
    289.    
    290.     if(railcannon_mode[iAttacker] == 3)
    291.     {
    292.         get_position(iAttacker, 20.0, 5.0, 5.0, StartOrigin2)
    293.        
    294.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    295.         write_byte(TE_BEAMPOINTS)
    296.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    297.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    298.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    299.         engfunc(EngFunc_WriteCoord, flEnd[0])
    300.         engfunc(EngFunc_WriteCoord, flEnd[1])
    301.         engfunc(EngFunc_WriteCoord, flEnd[2])
    302.         write_short(sTrail)
    303.         write_byte(0) // start frame
    304.         write_byte(0) // framerate
    305.         write_byte(8) // life
    306.         write_byte(8) // line width
    307.         write_byte(0) // amplitude
    308.         write_byte(220)
    309.         write_byte(88)
    310.         write_byte(0) // blue
    311.         write_byte(50) // brightness
    312.         write_byte(0) // speed
    313.         message_end()
    314.        
    315.         if(!is_user_alive(iEnt))
    316.             return
    317.        
    318.         if(ze_is_user_zombie(iEnt) && g_KnockBack == 1) knockback(iEnt, myOrigin, 42.0, 2)
    319.     }
    320.    
    321. }
    322.  
    323. public fake_smokes(id, Float:Origin[3])
    324. {
    325.     new ent_test; ent_test = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
    326.    
    327.     engfunc(EngFunc_SetModel, ent_test, "sprites/wall_puff1.spr")
    328.     entity_set_string(ent_test, EV_SZ_classname, SMOKE_CLASS)
    329.     set_pev(ent_test, pev_nextthink, get_gametime() + 0.04)
    330.     set_pev(ent_test, pev_movetype, MOVETYPE_NONE)
    331.     set_pev(ent_test, pev_rendermode, kRenderTransAdd)
    332.     set_pev(ent_test, pev_renderamt, 20.0)
    333.     set_pev(ent_test, pev_scale, 1.0)
    334.     set_pev(ent_test, pev_origin, Origin)
    335.     set_pev(ent_test, pev_frame, 0.0)
    336.     set_pev(ent_test, pev_iuser2, get_user_team(id))
    337.  
    338.     set_pev(ent_test, pev_solid, SOLID_NOT)
    339.     dllfunc(DLLFunc_Spawn, ent_test)
    340. }
    341.  
    342. public fw_Fire_smoke(iEnt)
    343. {
    344.     if(!pev_valid(iEnt))
    345.         return
    346.    
    347.     new Float:fFrame
    348.     pev(iEnt, pev_frame, fFrame)
    349.  
    350.     // effect exp
    351.     fFrame += 1.0
    352.  
    353.     set_pev(iEnt, pev_frame, fFrame)
    354.     set_pev(iEnt, pev_scale, 1.0)
    355.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.02)
    356.    
    357.     if(fFrame > 30.0) engfunc(EngFunc_RemoveEntity, iEnt)
    358. }
    359.  
    360. public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id,ptr)
    361. {
    362.     if(!is_user_alive(id))
    363.         return HAM_IGNORED 
    364.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    365.         return HAM_IGNORED
    366.     if(railcannon_mode[id] != 3)
    367.         return HAM_IGNORED
    368.    
    369.     // get crosshair aim
    370.     static Float:aim[3];
    371.     get_aim(id,v1,aim);
    372.    
    373.     // do another trace to this spot
    374.     new trace = create_tr2();
    375.     engfunc(EngFunc_TraceLine,v1,aim,noMonsters,id,trace);
    376.    
    377.     // copy ints
    378.     set_tr2(ptr,TR_AllSolid,get_tr2(trace,TR_AllSolid));
    379.     set_tr2(ptr,TR_StartSolid,get_tr2(trace,TR_StartSolid));
    380.     set_tr2(ptr,TR_InOpen,get_tr2(trace,TR_InOpen));
    381.     set_tr2(ptr,TR_InWater,get_tr2(trace,TR_InWater));
    382.     set_tr2(ptr,TR_pHit,get_tr2(trace,TR_pHit));
    383.     set_tr2(ptr,TR_iHitgroup,get_tr2(trace,TR_iHitgroup));
    384.  
    385.     // copy floats
    386.     get_tr2(trace,TR_flFraction,aim[0]);
    387.     set_tr2(ptr,TR_flFraction,aim[0]);
    388.     get_tr2(trace,TR_flPlaneDist,aim[0]);
    389.     set_tr2(ptr,TR_flPlaneDist,aim[0]);
    390.    
    391.     // copy vecs
    392.     get_tr2(trace,TR_vecEndPos,aim);
    393.     set_tr2(ptr,TR_vecEndPos,aim);
    394.     get_tr2(trace,TR_vecPlaneNormal,aim);
    395.     set_tr2(ptr,TR_vecPlaneNormal,aim);
    396.  
    397.     // get rid of new trace
    398.     free_tr2(trace);
    399.  
    400.     return FMRES_IGNORED;
    401. }
    402.  
    403. get_aim(id,Float:source[3],Float:ret[3])
    404. {
    405.     static Float:vAngle[3], Float:pAngle[3], Float:dir[3], Float:temp[3];
    406.  
    407.     // get aiming direction from forward global based on view angle and punch angle
    408.     pev(id,pev_v_angle,vAngle);
    409.     pev(id,pev_punchangle,pAngle);
    410.     xs_vec_add(vAngle,pAngle,temp);
    411.     engfunc(EngFunc_MakeVectors,temp);
    412.     global_get(glb_v_forward,dir);
    413.    
    414.     /* vecEnd = vecSrc + vecDir * flDistance; */
    415.     xs_vec_mul_scalar(dir,8192.0,temp);
    416.     xs_vec_add(source,temp,ret);
    417. }
    418.  
    419. public fwPrecacheEvent_Post(type, const name[])
    420. {
    421.     if (equal("events/m3.sc", name))
    422.     {
    423.         g_orig_event_railcannon = get_orig_retval()
    424.         return FMRES_HANDLED
    425.     }
    426.     return FMRES_IGNORED
    427. }
    428.  
    429. public client_connect(id)
    430. {
    431.     g_has_railcannon[id] = false
    432. }
    433.  
    434. public client_disconnect(id)
    435. {
    436.     g_has_railcannon[id] = false
    437. }
    438.  
    439. public fw_SetModel(entity, model[])
    440. {
    441.     if(!is_valid_ent(entity))
    442.         return FMRES_IGNORED
    443.    
    444.     static szClassName[33]
    445.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    446.        
    447.     if(!equal(szClassName, "weaponbox"))
    448.         return FMRES_IGNORED
    449.    
    450.     static iOwner
    451.    
    452.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    453.    
    454.     if(equal(model, "models/w_m3.mdl"))
    455.     {
    456.         static iStoredAugID
    457.        
    458.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_m3", entity)
    459.    
    460.         if(!is_valid_ent(iStoredAugID))
    461.             return FMRES_IGNORED
    462.    
    463.         if(g_has_railcannon[iOwner])
    464.         {
    465.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, RAILCANNON_WEAPONKEY)
    466.            
    467.             g_has_railcannon[iOwner] = false
    468.            
    469.             entity_set_model(entity, RAILCANNON_W_MODEL)
    470.            
    471.             return FMRES_SUPERCEDE
    472.         }
    473.     }
    474.     return FMRES_IGNORED
    475. }
    476.  
    477. public give_railcannon(id)
    478. {
    479.     drop_weapons(id, 1)
    480.     new iWep2 = give_item(id,"weapon_m3")
    481.     if( iWep2 > 0 )
    482.     {
    483.         cs_set_weapon_ammo(iWep2, cvar_clip_railcannon)
    484.         cs_set_user_bpammo (id, CSW_M3, cvar_railcannon_ammo)
    485.         UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    486.         set_weapons_timeidle(id, CSW_M3, 1.0)
    487.         set_player_nextattackx(id, 1.0)
    488.         g_clip_ammo[id] = cs_get_weapon_ammo(iWep2)
    489.     }
    490.     g_has_railcannon[id] = true
    491.     g_SpecialAmmo[id] = 0
    492.     udah[id] = 0
    493.     zz[id] = 0
    494.     railcannon_mode[id] = 1
    495.     update_specialammo(id, g_SpecialAmmo[id], g_SpecialAmmo[id] > 0 ? 1 : 0)
    496.     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    497.     write_string("weapon_railcannon")
    498.     write_byte(5)
    499.     write_byte(32)
    500.     write_byte(-1)
    501.     write_byte(-1)
    502.     write_byte(0)
    503.     write_byte(5)
    504.     write_byte(21)
    505.     write_byte(0)
    506.     message_end()
    507. }
    508.  
    509. public fw_RAILCANNON_AddToPlayer(railcannon, id)
    510. {
    511.     if(!is_valid_ent(railcannon) || !is_user_connected(id))
    512.         return HAM_IGNORED
    513.    
    514.     if(entity_get_int(railcannon, EV_INT_WEAPONKEY) == RAILCANNON_WEAPONKEY)
    515.     {
    516.         g_has_railcannon[id] = true
    517.        
    518.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    519.         write_string("weapon_railcannon")
    520.         write_byte(5)
    521.         write_byte(32)
    522.         write_byte(-1)
    523.         write_byte(-1)
    524.         write_byte(0)
    525.         write_byte(5)
    526.         write_byte(21)
    527.         write_byte(0)
    528.         message_end()
    529.        
    530.         entity_set_int(railcannon, EV_INT_WEAPONKEY, 0)
    531.         update_specialammo(id, g_SpecialAmmo[id], 0)
    532.         g_SpecialAmmo[id] = 0
    533.  
    534.         return HAM_HANDLED
    535.     }
    536.     return HAM_IGNORED
    537. }
    538.  
    539. public fw_UseStationary_Post(entity, caller, activator, use_type)
    540. {
    541.     if (use_type == USE_STOPPED && is_user_connected(caller))
    542.         replace_weapon_models(caller, get_user_weapon(caller))
    543. }
    544.  
    545. public fw_Item_Deploy_Post(weapon_ent)
    546. {
    547.     static owner
    548.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
    549.    
    550.     static weaponid
    551.     weaponid = cs_get_weapon_id(weapon_ent)
    552.    
    553.     update_specialammo(owner, g_SpecialAmmo[owner], 0)
    554.     g_SpecialAmmo[owner] = 0
    555.    
    556.     replace_weapon_models(owner, weaponid)
    557. }
    558.  
    559. public CurrentWeapon(id)
    560. {
    561.     if( read_data(2) != CSW_M3 ) {
    562.         if( g_reload[id] ) {
    563.             g_reload[id] = 0
    564.             remove_task( id + 1331 )
    565.         }
    566.     }
    567.     replace_weapon_models(id, read_data(2))
    568. }
    569.  
    570. replace_weapon_models(id, weaponid)
    571. {
    572.     switch (weaponid)
    573.     {
    574.         case CSW_M3:
    575.         {
    576.             if(g_has_railcannon[id])
    577.             {
    578.                 set_pev(id, pev_viewmodel2, RAILCANNON_V_MODEL)
    579.                 set_pev(id, pev_weaponmodel2, RAILCANNON_P_MODEL)
    580.                 if(oldweap[id] != CSW_M3)
    581.                 {
    582.                     set_weapons_timeidle(id, CSW_M3, 1.0)
    583.                     set_player_nextattackx(id, 1.0)
    584.                     UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    585.                     udah[id] = 0
    586.                     zz[id] = 0
    587.                     railcannon_mode[id] = 1
    588.                     remove_task(id+TASK_SOUND)
    589.                     remove_task(id)
    590.  
    591.                     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    592.                     write_string("weapon_railcannon")
    593.                     write_byte(5)
    594.                     write_byte(32)
    595.                     write_byte(-1)
    596.                     write_byte(-1)
    597.                     write_byte(0)
    598.                     write_byte(5)
    599.                     write_byte(CSW_M3)
    600.                     message_end()
    601.                 }
    602.             }
    603.         }
    604.     }
    605.     oldweap[id] = weaponid
    606. }
    607.  
    608. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
    609. {
    610.     if(!is_user_alive(Player) || get_user_weapon(Player) != CSW_M3 || !g_has_railcannon[Player])
    611.         return FMRES_IGNORED
    612.    
    613.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    614.     return FMRES_HANDLED
    615. }
    616.  
    617. public fw_RAIL_PrimaryAttack(Weapon)
    618. {
    619.     new Player = get_pdata_cbase(Weapon, 41, 4)
    620.    
    621.     if (!g_has_railcannon[Player])
    622.         return
    623.    
    624.     g_IsInPrimaryAttack = 1
    625.     pev(Player,pev_punchangle,cl_pushangle[Player])
    626.    
    627.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
    628.     if(g_clip_ammo[Player]) Make_Muzzleflash(Player)
    629. }
    630.  
    631. public fw_RAIL_PrimaryAttack_Post(Weapon)
    632. {
    633.     g_IsInPrimaryAttack = 0
    634.     new Player = get_pdata_cbase(Weapon, 41, 4)
    635.    
    636.     new szClip, szAmmo
    637.     get_user_weapon(Player, szClip, szAmmo)
    638.    
    639.     if(!is_user_alive(Player))
    640.         return
    641.  
    642.     if(g_has_railcannon[Player])
    643.     {
    644.         if (!g_clip_ammo[Player] && railcannon_mode[Player] == 1)
    645.             return
    646.        
    647.         g_reload[Player] = 0
    648.         remove_task( Player + 1331 )
    649.         new Float:push[3]
    650.         pev(Player,pev_punchangle,push)
    651.         xs_vec_sub(push,cl_pushangle[Player],push)
    652.         xs_vec_mul_scalar(push,cvar_recoil_railcannon,push)
    653.         xs_vec_add(push,cl_pushangle[Player],push)
    654.         set_pev(Player,pev_punchangle,push)
    655.        
    656.         UTIL_PlayWeaponAnimation(Player,random_num(4,5))
    657.         set_weapons_timeidle(Player, CSW_M3, 0.3)
    658.         set_player_nextattackx(Player, 0.3)
    659.         g_clip_ammo[Player] --
    660.        
    661.         if(railcannon_mode[Player] == 3) emit_sound(Player, CHAN_WEAPON, "weapons/railcanon-2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    662.         else emit_sound(Player, CHAN_WEAPON, Fire_Sounds, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    663.        
    664.         railcannon_mode[Player] = 1
    665.     }
    666. }
    667.  
    668. public Make_Muzzleflash(id)
    669. {
    670.     static Float:Origin[3], TE_FLAG
    671.     get_position(id, 32.0, 6.0, -15.0, Origin)
    672.    
    673.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    674.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
    675.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
    676.    
    677.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
    678.     write_byte(TE_EXPLOSION)
    679.     engfunc(EngFunc_WriteCoord, Origin[0])
    680.     engfunc(EngFunc_WriteCoord, Origin[1])
    681.     engfunc(EngFunc_WriteCoord, Origin[2])
    682.     write_short(g_MuzzleFlash_SprId)
    683.     write_byte(2)
    684.     write_byte(30)
    685.     write_byte(TE_FLAG)
    686.     message_end()
    687. }
    688.  
    689. public fw_CmdStart(id, uc_handle, seed)
    690. {
    691.     new ammo, clip, weapon = get_user_weapon(id, clip, ammo)
    692.     if (!g_has_railcannon[id] || weapon != CSW_M3 || !is_user_alive(id))
    693.         return
    694.    
    695.     static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    696.        
    697.     if(!pev_valid(ent))
    698.         return
    699.        
    700.     static CurButton
    701.     CurButton = get_uc(uc_handle, UC_Buttons)
    702.    
    703.     if(CurButton & IN_ATTACK)
    704.     {
    705.         new wpn = fm_get_user_weapon_entity(id, get_user_weapon(id))
    706.        
    707.         new Id = pev( wpn, pev_owner ), clip, bpammo
    708.         get_user_weapon( Id, clip, bpammo )
    709.         if( g_has_railcannon[ Id ] ) {
    710.         if( clip >= 2 ) {
    711.             if( g_reload[Id] ) {
    712.                 remove_task( Id + 1331 )
    713.                 g_reload[Id] = 0
    714.             }
    715.         }
    716.         else if( clip == 1 )
    717.         {
    718.             if(get_pdata_float(Id, 83, 4) <= 0.3)
    719.             {
    720.                 if( g_reload[Id] ) {
    721.                 remove_task( Id + 1331 )
    722.                 g_reload[Id] = 0
    723.             }
    724.             }
    725.         }
    726.     }
    727.     }
    728.    
    729.     else if(CurButton & IN_ATTACK2)
    730.     {
    731.         if(!zz[id] && get_pdata_float(id, 83, 4) <= 0.0 && g_clip_ammo[id] >= 1)
    732.         {
    733.             set_weapons_timeidle(id, CSW_M3, 200.0)
    734.             set_player_nextattackx(id, 200.0)
    735.             UTIL_PlayWeaponAnimation(id, 1)
    736.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage1_start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    737.             set_task(0.6, "charge_idle2", id)
    738.             zz[id] = 1
    739.             udah[id] = 0
    740.             railcannon_mode[id] = 2
    741.            
    742.             update_specialammo(id, g_SpecialAmmo[id], 0)
    743.             g_SpecialAmmo[id] ++
    744.             update_specialammo(id, g_SpecialAmmo[id], 1)
    745.            
    746.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    747.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    748.             g_clip_ammo[id] --
    749.         }
    750.     }
    751.    
    752.     else if(!(pev(id, pev_oldbuttons) & IN_ATTACK) && zz[id])
    753.     {
    754.         zz[id] = 0
    755.         if(udah[id])
    756.         {
    757.             if(g_clip_ammo[id] >= 1)
    758.             {
    759.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    760.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    761.                 set_player_nextattackx(id, 1.1)
    762.                 udah[id] = 0
    763.                 remove_task(id+TASK_SOUND)
    764.                
    765.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    766.                 g_SpecialAmmo[id] = 0
    767.                
    768.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    769.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    770.                 g_clip_ammo[id] ++
    771.             }
    772.             else
    773.             {
    774.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    775.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    776.                 g_clip_ammo[id] ++
    777.                
    778.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    779.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    780.                 set_player_nextattackx(id, 1.1)
    781.                 udah[id] = 0
    782.                 remove_task(id+TASK_SOUND)
    783.                
    784.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    785.                 g_SpecialAmmo[id] = 0
    786.             }
    787.         }
    788.     }
    789. }
    790.  
    791. public charge_idle2(id)
    792. {
    793.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    794.         return
    795.     if(zz[id])
    796.     {
    797.         if(g_clip_ammo[id] >= 1)
    798.         {
    799.             UTIL_PlayWeaponAnimation(id, 2)
    800.             set_weapons_timeidle(id, CSW_M3, 200.0)
    801.             set_player_nextattackx(id, 200.0)
    802.             set_task(0.6, "charge_idle3", id)
    803.            
    804.             update_specialammo(id, g_SpecialAmmo[id], 0)
    805.             g_SpecialAmmo[id] ++
    806.             update_specialammo(id, g_SpecialAmmo[id], 1)
    807.            
    808.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    809.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    810.             g_clip_ammo[id] --
    811.         }
    812.         else
    813.         {
    814.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    815.        
    816.             if(!pev_valid(ent))
    817.                 return
    818.            
    819.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    820.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    821.             g_clip_ammo[id] ++
    822.            
    823.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    824.             set_weapons_timeidle(id, CSW_M3, 1.1)
    825.             set_player_nextattackx(id, 1.1)
    826.            
    827.             update_specialammo(id, g_SpecialAmmo[id], 0)
    828.             g_SpecialAmmo[id] = 0
    829.         }
    830.     }
    831.     else
    832.     {
    833.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    834.        
    835.         if(!pev_valid(ent))
    836.             return
    837.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    838.         set_weapons_timeidle(id, CSW_M3, 1.1)
    839.         set_player_nextattackx(id, 1.1)
    840.        
    841.         update_specialammo(id, g_SpecialAmmo[id], 0)
    842.         g_SpecialAmmo[id] = 0
    843.        
    844.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    845.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    846.         g_clip_ammo[id] ++
    847.     }
    848. }
    849.  
    850. public charge_idle3(id)
    851. {
    852.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    853.         return
    854.     if(zz[id])
    855.     {
    856.         if(g_clip_ammo[id] >= 1)
    857.         {
    858.             UTIL_PlayWeaponAnimation(id, 3)
    859.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    860.             set_task(0.794, "play_sound", id+TASK_SOUND,_,_,"b")
    861.             udah[id] = 1
    862.             railcannon_mode[id] = 3
    863.             set_weapons_timeidle(id, CSW_M3, 200.0)
    864.             set_player_nextattackx(id, 200.0)
    865.            
    866.             update_specialammo(id, g_SpecialAmmo[id], 0)
    867.             g_SpecialAmmo[id] ++
    868.             update_specialammo(id, g_SpecialAmmo[id], 1)
    869.            
    870.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    871.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    872.             g_clip_ammo[id] --
    873.         }
    874.         else
    875.         {
    876.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    877.        
    878.             if(!pev_valid(ent))
    879.                 return
    880.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    881.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    882.             g_clip_ammo[id] ++
    883.            
    884.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    885.             set_weapons_timeidle(id, CSW_M3, 1.1)
    886.             set_player_nextattackx(id, 1.1)
    887.            
    888.             update_specialammo(id, g_SpecialAmmo[id], 0)
    889.             g_SpecialAmmo[id] = 0
    890.         }
    891.     }
    892.     else
    893.     {
    894.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    895.        
    896.         if(!pev_valid(ent))
    897.             return
    898.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    899.         set_weapons_timeidle(id, CSW_M3, 1.1)
    900.         set_player_nextattackx(id, 1.1)
    901.        
    902.         update_specialammo(id, g_SpecialAmmo[id], 0)
    903.         g_SpecialAmmo[id] = 0
    904.        
    905.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    906.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    907.         g_clip_ammo[id] ++
    908.     }
    909. }
    910.  
    911. public play_sound(id)
    912. {
    913.     id -= TASK_SOUND
    914.    
    915.     if(!is_user_alive(id) || get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    916.         return
    917.    
    918.     emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    919. }
    920.  
    921. public fw_railcannonidleanim(Weapon)
    922. {
    923.     new id = get_pdata_cbase(Weapon, 41, 4)
    924.  
    925.     if(!is_user_alive(id) || !g_has_railcannon[id] || get_user_weapon(id) != CSW_M3)
    926.         return HAM_IGNORED;
    927.    
    928.     if(railcannon_mode[id] == 1 && get_pdata_float(Weapon, 48, 4) <= 0.25)
    929.     {
    930.         UTIL_PlayWeaponAnimation(id, 0)
    931.         set_pdata_float(Weapon, 48, 20.0, 4)
    932.         return HAM_SUPERCEDE;
    933.     }
    934.    
    935.     if(railcannon_mode[id] == 3 && get_pdata_float(Weapon, 48, 4) <= 0.01)
    936.     {
    937.         UTIL_PlayWeaponAnimation(id, 3)
    938.         set_pdata_float(Weapon, 48, 1.7, 4)
    939.         return HAM_SUPERCEDE;
    940.     }
    941.  
    942.     return HAM_IGNORED;
    943. }
    944.  
    945. public update_specialammo(id, Ammo, On)
    946. {
    947.     static AmmoSprites[33]
    948.     format(AmmoSprites, sizeof(AmmoSprites), "number_%d", Ammo)
    949.    
    950.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("StatusIcon"), {0,0,0}, id)
    951.     write_byte(On)
    952.     write_string(AmmoSprites)
    953.     write_byte(42) // red
    954.     write_byte(255) // green
    955.     write_byte(42) // blue
    956.     message_end()
    957. }
    958.  
    959. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    960. {
    961.     if ((eventid != g_orig_event_railcannon) || !g_IsInPrimaryAttack)
    962.         return FMRES_IGNORED
    963.        
    964.     if (!(1 <= invoker <= g_MaxPlayers))
    965.         return FMRES_IGNORED
    966.  
    967.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    968.     return FMRES_SUPERCEDE
    969. }
    970.  
    971. public RAILCANNON_Reload( wpn ) {
    972.     if(railcannon_mode[pev( wpn, pev_owner )] == 3)
    973.           return HAM_SUPERCEDE
    974.          
    975.     if( g_has_railcannon[ pev( wpn, pev_owner ) ] ) {
    976.         RAILCANNON_Reload_Post( wpn )
    977.         return HAM_SUPERCEDE
    978.     }
    979.     return HAM_IGNORED
    980. }
    981.  
    982. public RAILCANNON_Reload_Post(weapon) {
    983.     new id = pev( weapon, pev_owner )
    984.     if(railcannon_mode[id] == 3 || g_reload[id])
    985.           return HAM_SUPERCEDE
    986.     new clip, bpammo
    987.     get_user_weapon(id, clip, bpammo )
    988.     if( g_has_railcannon[ id ] && clip < cvar_clip_railcannon && bpammo > 0 ) {
    989.         if(!task_exists( id+1331 )) set_task( 0.1, "reload", id+1331 )
    990.         }
    991.     return HAM_IGNORED
    992. }
    993.  
    994. public reload( id ) {
    995.     id -= 1331
    996.     set_weapons_timeidle(id, CSW_M3, 3.0)
    997.     set_player_nextattackx(id, 3.0)
    998.     UTIL_PlayWeaponAnimation(id, 6)
    999.     g_reload[id] = 1
    1000.     set_task(3.0, "isi", id)
    1001. }
    1002.  
    1003. public isi(id)
    1004. {
    1005.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    1006.         return
    1007.    
    1008.     if(!g_reload[id])
    1009.         return
    1010.    
    1011.     new clip, pluru, pengurang, bpammo, weapon = find_ent_by_owner( -1, "weapon_m3", id )
    1012.     get_user_weapon(id, clip, bpammo )
    1013.     pengurang = cvar_clip_railcannon - clip
    1014.     pluru = bpammo - pengurang
    1015.     cs_set_user_bpammo( id, CSW_M3, pluru )
    1016.    
    1017.     if(bpammo <= pengurang) cs_set_weapon_ammo( weapon, clip + bpammo)
    1018.     else cs_set_weapon_ammo( weapon, cvar_clip_railcannon)
    1019.    
    1020.     g_clip_ammo[id] = cvar_clip_railcannon
    1021. }
    1022.  
    1023. stock knockback(ent, Float:VicOrigin[3], Float:speed, type)
    1024. {
    1025.     static Float:fl_Velocity[3]
    1026.     static Float:EntOrigin[3]
    1027.     static Float:EntVelocity[3]
    1028.    
    1029.     pev(ent, pev_velocity, EntVelocity)
    1030.     pev(ent, pev_origin, EntOrigin)
    1031.     static Float:distance_f
    1032.     distance_f = get_distance_f(EntOrigin, VicOrigin)
    1033.    
    1034.     static Float:fl_Time; fl_Time = distance_f / speed
    1035.    
    1036.     if(type == 1)
    1037.     {
    1038.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
    1039.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
    1040.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time       
    1041.         } else if(type == 2) {
    1042.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
    1043.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
    1044.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
    1045.     }
    1046.    
    1047.     xs_vec_add(EntVelocity, fl_Velocity, fl_Velocity)
    1048.     set_pev(ent, pev_velocity, fl_Velocity)
    1049. }
    1050.  
    1051. stock fm_cs_get_current_weapon_ent(id)
    1052. {
    1053.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
    1054. }
    1055.  
    1056. stock fm_set_weapon_ammo(entity, amount)
    1057. {
    1058.     set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
    1059. }
    1060.  
    1061. stock fm_cs_get_weapon_ent_owner(ent)
    1062. {
    1063.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
    1064. }
    1065.  
    1066. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
    1067. {
    1068.     set_pev(Player, pev_weaponanim, Sequence)
    1069.    
    1070.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    1071.     write_byte(Sequence)
    1072.     write_byte(pev(Player, pev_body))
    1073.     message_end()
    1074. }
    1075.  
    1076. stock set_player_nextattackx(id, Float:nexttime)
    1077. {
    1078.     if(!is_user_alive(id))
    1079.         return
    1080.        
    1081.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
    1082. }
    1083.  
    1084. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
    1085. {
    1086.     new Float:vfEnd[3], viEnd[3]
    1087.     get_user_origin(id, viEnd, 3)  
    1088.     IVecFVec(viEnd, vfEnd)
    1089.    
    1090.     new Float:fOrigin[3], Float:fAngle[3]
    1091.    
    1092.     pev(id, pev_origin, fOrigin)
    1093.     pev(id, pev_view_ofs, fAngle)
    1094.    
    1095.     xs_vec_add(fOrigin, fAngle, fOrigin)
    1096.    
    1097.     new Float:fAttack[3]
    1098.    
    1099.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1100.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1101.    
    1102.     new Float:fRate
    1103.    
    1104.     fRate = fDis / vector_length(fAttack)
    1105.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
    1106.    
    1107.     xs_vec_add(fOrigin, fAttack, output)
    1108. }
    1109.  
    1110. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
    1111. {
    1112.     if(!is_user_alive(id))
    1113.         return
    1114.        
    1115.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
    1116.     if(!pev_valid(entwpn))
    1117.         return
    1118.        
    1119.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1120.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1121.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, WEAP_LINUX_XTRA_OFF)
    1122. }
    1123.  
    1124. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
    1125. {
    1126.     new_velocity[0] = origin2[0] - origin1[0]
    1127.     new_velocity[1] = origin2[1] - origin1[1]
    1128.     new_velocity[2] = origin2[2] - origin1[2]
    1129.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    1130.     new_velocity[0] *= num
    1131.     new_velocity[1] *= num
    1132.     new_velocity[2] *= num
    1133.    
    1134.     return 1;
    1135. }
    1136.  
    1137. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
    1138. {
    1139.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    1140.    
    1141.     pev(id, pev_origin, vOrigin)
    1142.     pev(id, pev_view_ofs, vUp) //for player
    1143.     xs_vec_add(vOrigin, vUp, vOrigin)
    1144.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
    1145.    
    1146.     angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
    1147.     angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
    1148.     angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
    1149.    
    1150.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    1151.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    1152.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
    1153. }
    1154.  
    1155.  
    1156. stock drop_weapons(id, dropwhat)
    1157. {
    1158.     static weapons[32], num, i, weaponid
    1159.     num = 0
    1160.     get_user_weapons(id, weapons, num)
    1161.      
    1162.     for (i = 0; i < num; i++)
    1163.     {
    1164.         weaponid = weapons[i]
    1165.          
    1166.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    1167.         {
    1168.             static wname[32]
    1169.             get_weaponname(weaponid, wname, sizeof wname - 1)
    1170.             engclient_cmd(id, "drop", wname)
    1171.         }
    1172.     }
    1173. }

Try this Bro ... And Test it and then report here
Bro can you post it in our extra-item section?
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#5

Post by johnnysins2000 » 2 Years Ago

Raheem wrote:
2 Years Ago
johnnysins2000 wrote:
2 Years Ago
Code:
    1. #include <zombie_escape>
    2. #include <fakemeta_util>
    3. #include <xs>
    4. #include <cstrike>
    5.  
    6. #define ENG_NULLENT     -1
    7. #define EV_INT_WEAPONKEY    EV_INT_impulse
    8. #define RAILCANNON_WEAPONKEY 756144798
    9. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
    10.  
    11. #define SMOKE_CLASS "smokess"
    12.  
    13. #define ENABLE_KNOCKBACK 1
    14.  
    15. const USE_STOPPED = 0
    16. const OFFSET_ACTIVE_ITEM = 373
    17. const OFFSET_WEAPONOWNER = 41
    18. const OFFSET_LINUX = 5
    19. const OFFSET_LINUX_WEAPONS = 4
    20.  
    21. #if cellbits == 32
    22. const OFFSET_CLIPAMMO = 51
    23. #else
    24. const OFFSET_CLIPAMMO = 65
    25. #endif
    26.  
    27. #define WEAP_LINUX_XTRA_OFF     4
    28. #define m_fKnown                    44
    29. #define m_flNextPrimaryAttack       46
    30. #define m_flNextSecondaryAttack         47
    31. #define m_flTimeWeaponIdle          48
    32. #define m_iClip                 51
    33. #define m_fInReload             54
    34. #define m_fInSpecialReload          55
    35. #define PLAYER_LINUX_XTRA_OFF   5
    36. #define m_flNextAttack              83
    37.  
    38. #define RAILCANNON_DRAW         7
    39.  
    40. #define TASK_SOUND 2573+10
    41. #define TASK_SETRUM2 2573+20
    42.  
    43. new gmsgWeaponList, sTrail
    44.  
    45. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
    46.  
    47. new const Fire_Sounds[] = "weapons/railcanon-1.wav"
    48. new const MuzzleFlash[] = "sprites/muzzleflash19.spr"
    49.  
    50. //////////// Change Here For Customize //////////////////////////
    51.  
    52. const Float:cvar_recoil_railcannon = 0.65
    53. const cvar_clip_railcannon = 24
    54. const cvar_railcannon_ammo = 90
    55.  
    56. const Float:damage_mode1 = 20.0
    57. const Float:damage_mode2 = 35.0
    58. const Float:damage_mode3 = 60.0
    59.  
    60. /////////////////////////////////////////////////////////////////
    61. new RAILCANNON_V_MODEL[64] = "models/v_railcannon.mdl"
    62. new RAILCANNON_P_MODEL[64] = "models/p_railcannon.mdl"
    63. new RAILCANNON_W_MODEL[64] = "models/w_railcannon.mdl"
    64.  
    65. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
    66.  
    67. new g_has_railcannon[33], g_Ham_Bot
    68.  
    69. new g_MaxPlayers, g_orig_event_railcannon, g_IsInPrimaryAttack, g_MuzzleFlash_SprId, g_iItemID, g_KnockBack
    70. new Float:cl_pushangle[33][3], m_iBlood[2], zz[33], udah[33]
    71. new g_clip_ammo[33], oldweap[33], g_reload[33], railcannon_mode[33], Float:StartOrigin2[3], g_SpecialAmmo[33]
    72. const PRIMARY_WEAPONS_BIT_SUM =
    73. (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<<
    74. 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)
    75. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
    76.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
    77.             "weapon_mp5navy", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
    78.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
    79.             "weapon_ak47", "weapon_knife", "weapon_p90" }
    80.  
    81. public plugin_init()
    82. {
    83.     register_plugin("Rail Cannon", "1.0", "m4m3ts")
    84.     register_cvar("rail_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
    85.     register_event("CurWeapon","CurrentWeapon","be","1=1")
    86.     register_think(SMOKE_CLASS, "fw_Fire_smoke")
    87.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m3", "fw_RAILCANNON_AddToPlayer")
    88.     RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
    89.     RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
    90.     RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
    91.     RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
    92.     g_iItemID = ze_register_item("Rail Cannon", 20)
    93.    
    94.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
    95.         if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
    96.    
    97.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack")
    98.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m3", "fw_RAIL_PrimaryAttack_Post", 1)
    99.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload")
    100.     RegisterHam(Ham_Weapon_Reload, "weapon_m3", "RAILCANNON_Reload_Post", 1)
    101.     RegisterHam(Ham_Weapon_WeaponIdle, "weapon_m3", "fw_railcannonidleanim", 1)
    102.    
    103.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
    104.    
    105.     register_forward(FM_CmdStart, "fw_CmdStart")
    106.     register_forward(FM_SetModel, "fw_SetModel")
    107.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    108.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
    109.     register_forward(FM_TraceLine,"fw_traceline",1)
    110.    
    111.     gmsgWeaponList = get_user_msgid("WeaponList")
    112.    
    113.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
    114.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
    115.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
    116.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
    117.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
    118.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
    119.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
    120.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
    121.    
    122.     g_KnockBack = ENABLE_KNOCKBACK
    123.     g_MaxPlayers = get_maxplayers()
    124. }
    125.  
    126. public plugin_precache()
    127. {
    128.     precache_model(RAILCANNON_V_MODEL)
    129.     precache_model(RAILCANNON_P_MODEL)
    130.     precache_model(RAILCANNON_W_MODEL)
    131.     precache_sound(Fire_Sounds)
    132.        
    133.     sTrail = precache_model("sprites/laserbeam.spr")
    134.    
    135.     precache_sound("weapons/railcanon_clipin.wav")
    136.     precache_sound("weapons/railcanon_chage1_start.wav")
    137.     precache_sound("weapons/railcanon_chage3_loop.wav")
    138.     precache_sound("weapons/railcanon_draw.wav")
    139.     precache_sound("weapons/railcanon_clipout.wav")
    140.     precache_sound("weapons/railcanon-2.wav")
    141.    
    142.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
    143.     precache_generic("sprites/weapon_railcannon.txt")
    144.    
    145.     precache_generic("sprites/640hud112.spr")
    146.     precache_generic("sprites/640hud13.spr")
    147.        
    148.     register_clcmd("weapon_railcannon", "weapon_hook") 
    149.                    
    150.     m_iBlood[0] = precache_model("sprites/blood.spr")
    151.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    152.     precache_model("sprites/wall_puff1.spr")
    153.  
    154.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
    155. }
    156.  
    157. public weapon_hook(id)
    158. {
    159.     engclient_cmd(id, "weapon_m3")
    160.     return PLUGIN_HANDLED
    161. }
    162.  
    163. public client_putinserver(id)
    164. {
    165.     if(!g_Ham_Bot && is_user_bot(id))
    166.     {
    167.         g_Ham_Bot = 1
    168.         set_task(0.1, "Do_RegisterHam_Bot", id)
    169.     }
    170. }
    171.  
    172. public Do_RegisterHam_Bot(id)
    173. {
    174.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
    175.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
    176. }
    177.  
    178. public ze_select_item_pre(id, itemid)
    179. {
    180.     // This not our item?
    181.     if (itemid != g_iItemID)
    182.         return ZE_ITEM_AVAILABLE
    183.    
    184.     // Available for Humans only, So don't show it for zombies
    185.     if (ze_is_user_zombie(id))
    186.         return ZE_ITEM_DONT_SHOW
    187.    
    188.     // Finally return that it's available
    189.     return ZE_ITEM_AVAILABLE
    190. }
    191.  
    192. public ze_select_item_post(id, itemid)
    193. {
    194.     // This is not our item, Block it here and don't execute the blew code
    195.     if (itemid != g_iItemID)
    196.         return
    197.    
    198.     give_railcannon(id)
    199. }
    200.  
    201. public ze_user_infected(id)
    202. {
    203.     update_specialammo(id, g_SpecialAmmo[id], 0)
    204.     g_has_railcannon[id] = false
    205.     g_SpecialAmmo[id] = 0
    206. }
    207.  
    208. public fw_PlayerKilled(id)
    209. {
    210.     g_has_railcannon[id] = false
    211. }
    212.  
    213. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
    214. {
    215.     if(!is_user_alive(iAttacker))
    216.         return
    217.  
    218.     new g_currentweapon = get_user_weapon(iAttacker)
    219.  
    220.     if(g_currentweapon != CSW_M3 || !g_has_railcannon[iAttacker])
    221.         return
    222.    
    223.     if(railcannon_mode[iAttacker] == 3) SetHamParamFloat(3, 60.0)
    224.     if(railcannon_mode[iAttacker] == 2) SetHamParamFloat(3, 35.0)
    225.     if(railcannon_mode[iAttacker] == 1) SetHamParamFloat(3, 20.0)
    226.    
    227.     static Float:flEnd[3], Float:test[3], Float:myOrigin[3]
    228.    
    229.     pev(iAttacker, pev_origin, myOrigin)
    230.     get_tr2(ptr, TR_vecEndPos, flEnd)
    231.        
    232.     if(!is_user_alive(iEnt))
    233.     {
    234.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    235.         write_byte(TE_DECAL)
    236.         write_coord_f(flEnd[0])
    237.         write_coord_f(flEnd[1])
    238.         write_coord_f(flEnd[2])
    239.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    240.         write_short(iEnt)
    241.         message_end()
    242.  
    243.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    244.         write_byte(TE_WORLDDECAL)
    245.         write_coord_f(flEnd[0])
    246.         write_coord_f(flEnd[1])
    247.         write_coord_f(flEnd[2])
    248.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    249.         message_end()
    250.        
    251.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    252.         write_byte(TE_GUNSHOTDECAL)
    253.         write_coord_f(flEnd[0])
    254.         write_coord_f(flEnd[1])
    255.         write_coord_f(flEnd[2])
    256.         write_short(iAttacker)
    257.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    258.         message_end()
    259.        
    260.         fm_get_aim_origin(iAttacker, test)
    261.         if(railcannon_mode[iAttacker] == 3) fake_smokes(iAttacker, test)
    262.     }
    263.    
    264.     if(railcannon_mode[iAttacker] == 2)
    265.     {
    266.         get_position(iAttacker, 20.0, 0.0, 10.0, StartOrigin2)
    267.        
    268.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    269.         write_byte(TE_BEAMPOINTS)
    270.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    271.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    272.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    273.         engfunc(EngFunc_WriteCoord, flEnd[0])
    274.         engfunc(EngFunc_WriteCoord, flEnd[1])
    275.         engfunc(EngFunc_WriteCoord, flEnd[2])
    276.         write_short(sTrail)
    277.         write_byte(0) // start frame
    278.         write_byte(0) // framerate
    279.         write_byte(5) // life
    280.         write_byte(5) // line width
    281.         write_byte(0) // amplitude
    282.         write_byte(220)
    283.         write_byte(88)
    284.         write_byte(0) // blue
    285.         write_byte(255) // brightness
    286.         write_byte(0) // speed
    287.         message_end()
    288.     }
    289.    
    290.     if(railcannon_mode[iAttacker] == 3)
    291.     {
    292.         get_position(iAttacker, 20.0, 5.0, 5.0, StartOrigin2)
    293.        
    294.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    295.         write_byte(TE_BEAMPOINTS)
    296.         engfunc(EngFunc_WriteCoord, StartOrigin2[0])
    297.         engfunc(EngFunc_WriteCoord, StartOrigin2[1])
    298.         engfunc(EngFunc_WriteCoord, StartOrigin2[2] - 10.0)
    299.         engfunc(EngFunc_WriteCoord, flEnd[0])
    300.         engfunc(EngFunc_WriteCoord, flEnd[1])
    301.         engfunc(EngFunc_WriteCoord, flEnd[2])
    302.         write_short(sTrail)
    303.         write_byte(0) // start frame
    304.         write_byte(0) // framerate
    305.         write_byte(8) // life
    306.         write_byte(8) // line width
    307.         write_byte(0) // amplitude
    308.         write_byte(220)
    309.         write_byte(88)
    310.         write_byte(0) // blue
    311.         write_byte(50) // brightness
    312.         write_byte(0) // speed
    313.         message_end()
    314.        
    315.         if(!is_user_alive(iEnt))
    316.             return
    317.        
    318.         if(ze_is_user_zombie(iEnt) && g_KnockBack == 1) knockback(iEnt, myOrigin, 42.0, 2)
    319.     }
    320.    
    321. }
    322.  
    323. public fake_smokes(id, Float:Origin[3])
    324. {
    325.     new ent_test; ent_test = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
    326.    
    327.     engfunc(EngFunc_SetModel, ent_test, "sprites/wall_puff1.spr")
    328.     entity_set_string(ent_test, EV_SZ_classname, SMOKE_CLASS)
    329.     set_pev(ent_test, pev_nextthink, get_gametime() + 0.04)
    330.     set_pev(ent_test, pev_movetype, MOVETYPE_NONE)
    331.     set_pev(ent_test, pev_rendermode, kRenderTransAdd)
    332.     set_pev(ent_test, pev_renderamt, 20.0)
    333.     set_pev(ent_test, pev_scale, 1.0)
    334.     set_pev(ent_test, pev_origin, Origin)
    335.     set_pev(ent_test, pev_frame, 0.0)
    336.     set_pev(ent_test, pev_iuser2, get_user_team(id))
    337.  
    338.     set_pev(ent_test, pev_solid, SOLID_NOT)
    339.     dllfunc(DLLFunc_Spawn, ent_test)
    340. }
    341.  
    342. public fw_Fire_smoke(iEnt)
    343. {
    344.     if(!pev_valid(iEnt))
    345.         return
    346.    
    347.     new Float:fFrame
    348.     pev(iEnt, pev_frame, fFrame)
    349.  
    350.     // effect exp
    351.     fFrame += 1.0
    352.  
    353.     set_pev(iEnt, pev_frame, fFrame)
    354.     set_pev(iEnt, pev_scale, 1.0)
    355.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.02)
    356.    
    357.     if(fFrame > 30.0) engfunc(EngFunc_RemoveEntity, iEnt)
    358. }
    359.  
    360. public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id,ptr)
    361. {
    362.     if(!is_user_alive(id))
    363.         return HAM_IGNORED 
    364.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    365.         return HAM_IGNORED
    366.     if(railcannon_mode[id] != 3)
    367.         return HAM_IGNORED
    368.    
    369.     // get crosshair aim
    370.     static Float:aim[3];
    371.     get_aim(id,v1,aim);
    372.    
    373.     // do another trace to this spot
    374.     new trace = create_tr2();
    375.     engfunc(EngFunc_TraceLine,v1,aim,noMonsters,id,trace);
    376.    
    377.     // copy ints
    378.     set_tr2(ptr,TR_AllSolid,get_tr2(trace,TR_AllSolid));
    379.     set_tr2(ptr,TR_StartSolid,get_tr2(trace,TR_StartSolid));
    380.     set_tr2(ptr,TR_InOpen,get_tr2(trace,TR_InOpen));
    381.     set_tr2(ptr,TR_InWater,get_tr2(trace,TR_InWater));
    382.     set_tr2(ptr,TR_pHit,get_tr2(trace,TR_pHit));
    383.     set_tr2(ptr,TR_iHitgroup,get_tr2(trace,TR_iHitgroup));
    384.  
    385.     // copy floats
    386.     get_tr2(trace,TR_flFraction,aim[0]);
    387.     set_tr2(ptr,TR_flFraction,aim[0]);
    388.     get_tr2(trace,TR_flPlaneDist,aim[0]);
    389.     set_tr2(ptr,TR_flPlaneDist,aim[0]);
    390.    
    391.     // copy vecs
    392.     get_tr2(trace,TR_vecEndPos,aim);
    393.     set_tr2(ptr,TR_vecEndPos,aim);
    394.     get_tr2(trace,TR_vecPlaneNormal,aim);
    395.     set_tr2(ptr,TR_vecPlaneNormal,aim);
    396.  
    397.     // get rid of new trace
    398.     free_tr2(trace);
    399.  
    400.     return FMRES_IGNORED;
    401. }
    402.  
    403. get_aim(id,Float:source[3],Float:ret[3])
    404. {
    405.     static Float:vAngle[3], Float:pAngle[3], Float:dir[3], Float:temp[3];
    406.  
    407.     // get aiming direction from forward global based on view angle and punch angle
    408.     pev(id,pev_v_angle,vAngle);
    409.     pev(id,pev_punchangle,pAngle);
    410.     xs_vec_add(vAngle,pAngle,temp);
    411.     engfunc(EngFunc_MakeVectors,temp);
    412.     global_get(glb_v_forward,dir);
    413.    
    414.     /* vecEnd = vecSrc + vecDir * flDistance; */
    415.     xs_vec_mul_scalar(dir,8192.0,temp);
    416.     xs_vec_add(source,temp,ret);
    417. }
    418.  
    419. public fwPrecacheEvent_Post(type, const name[])
    420. {
    421.     if (equal("events/m3.sc", name))
    422.     {
    423.         g_orig_event_railcannon = get_orig_retval()
    424.         return FMRES_HANDLED
    425.     }
    426.     return FMRES_IGNORED
    427. }
    428.  
    429. public client_connect(id)
    430. {
    431.     g_has_railcannon[id] = false
    432. }
    433.  
    434. public client_disconnect(id)
    435. {
    436.     g_has_railcannon[id] = false
    437. }
    438.  
    439. public fw_SetModel(entity, model[])
    440. {
    441.     if(!is_valid_ent(entity))
    442.         return FMRES_IGNORED
    443.    
    444.     static szClassName[33]
    445.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    446.        
    447.     if(!equal(szClassName, "weaponbox"))
    448.         return FMRES_IGNORED
    449.    
    450.     static iOwner
    451.    
    452.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    453.    
    454.     if(equal(model, "models/w_m3.mdl"))
    455.     {
    456.         static iStoredAugID
    457.        
    458.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_m3", entity)
    459.    
    460.         if(!is_valid_ent(iStoredAugID))
    461.             return FMRES_IGNORED
    462.    
    463.         if(g_has_railcannon[iOwner])
    464.         {
    465.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, RAILCANNON_WEAPONKEY)
    466.            
    467.             g_has_railcannon[iOwner] = false
    468.            
    469.             entity_set_model(entity, RAILCANNON_W_MODEL)
    470.            
    471.             return FMRES_SUPERCEDE
    472.         }
    473.     }
    474.     return FMRES_IGNORED
    475. }
    476.  
    477. public give_railcannon(id)
    478. {
    479.     drop_weapons(id, 1)
    480.     new iWep2 = give_item(id,"weapon_m3")
    481.     if( iWep2 > 0 )
    482.     {
    483.         cs_set_weapon_ammo(iWep2, cvar_clip_railcannon)
    484.         cs_set_user_bpammo (id, CSW_M3, cvar_railcannon_ammo)
    485.         UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    486.         set_weapons_timeidle(id, CSW_M3, 1.0)
    487.         set_player_nextattackx(id, 1.0)
    488.         g_clip_ammo[id] = cs_get_weapon_ammo(iWep2)
    489.     }
    490.     g_has_railcannon[id] = true
    491.     g_SpecialAmmo[id] = 0
    492.     udah[id] = 0
    493.     zz[id] = 0
    494.     railcannon_mode[id] = 1
    495.     update_specialammo(id, g_SpecialAmmo[id], g_SpecialAmmo[id] > 0 ? 1 : 0)
    496.     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    497.     write_string("weapon_railcannon")
    498.     write_byte(5)
    499.     write_byte(32)
    500.     write_byte(-1)
    501.     write_byte(-1)
    502.     write_byte(0)
    503.     write_byte(5)
    504.     write_byte(21)
    505.     write_byte(0)
    506.     message_end()
    507. }
    508.  
    509. public fw_RAILCANNON_AddToPlayer(railcannon, id)
    510. {
    511.     if(!is_valid_ent(railcannon) || !is_user_connected(id))
    512.         return HAM_IGNORED
    513.    
    514.     if(entity_get_int(railcannon, EV_INT_WEAPONKEY) == RAILCANNON_WEAPONKEY)
    515.     {
    516.         g_has_railcannon[id] = true
    517.        
    518.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    519.         write_string("weapon_railcannon")
    520.         write_byte(5)
    521.         write_byte(32)
    522.         write_byte(-1)
    523.         write_byte(-1)
    524.         write_byte(0)
    525.         write_byte(5)
    526.         write_byte(21)
    527.         write_byte(0)
    528.         message_end()
    529.        
    530.         entity_set_int(railcannon, EV_INT_WEAPONKEY, 0)
    531.         update_specialammo(id, g_SpecialAmmo[id], 0)
    532.         g_SpecialAmmo[id] = 0
    533.  
    534.         return HAM_HANDLED
    535.     }
    536.     return HAM_IGNORED
    537. }
    538.  
    539. public fw_UseStationary_Post(entity, caller, activator, use_type)
    540. {
    541.     if (use_type == USE_STOPPED && is_user_connected(caller))
    542.         replace_weapon_models(caller, get_user_weapon(caller))
    543. }
    544.  
    545. public fw_Item_Deploy_Post(weapon_ent)
    546. {
    547.     static owner
    548.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
    549.    
    550.     static weaponid
    551.     weaponid = cs_get_weapon_id(weapon_ent)
    552.    
    553.     update_specialammo(owner, g_SpecialAmmo[owner], 0)
    554.     g_SpecialAmmo[owner] = 0
    555.    
    556.     replace_weapon_models(owner, weaponid)
    557. }
    558.  
    559. public CurrentWeapon(id)
    560. {
    561.     if( read_data(2) != CSW_M3 ) {
    562.         if( g_reload[id] ) {
    563.             g_reload[id] = 0
    564.             remove_task( id + 1331 )
    565.         }
    566.     }
    567.     replace_weapon_models(id, read_data(2))
    568. }
    569.  
    570. replace_weapon_models(id, weaponid)
    571. {
    572.     switch (weaponid)
    573.     {
    574.         case CSW_M3:
    575.         {
    576.             if(g_has_railcannon[id])
    577.             {
    578.                 set_pev(id, pev_viewmodel2, RAILCANNON_V_MODEL)
    579.                 set_pev(id, pev_weaponmodel2, RAILCANNON_P_MODEL)
    580.                 if(oldweap[id] != CSW_M3)
    581.                 {
    582.                     set_weapons_timeidle(id, CSW_M3, 1.0)
    583.                     set_player_nextattackx(id, 1.0)
    584.                     UTIL_PlayWeaponAnimation(id, RAILCANNON_DRAW)
    585.                     udah[id] = 0
    586.                     zz[id] = 0
    587.                     railcannon_mode[id] = 1
    588.                     remove_task(id+TASK_SOUND)
    589.                     remove_task(id)
    590.  
    591.                     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
    592.                     write_string("weapon_railcannon")
    593.                     write_byte(5)
    594.                     write_byte(32)
    595.                     write_byte(-1)
    596.                     write_byte(-1)
    597.                     write_byte(0)
    598.                     write_byte(5)
    599.                     write_byte(CSW_M3)
    600.                     message_end()
    601.                 }
    602.             }
    603.         }
    604.     }
    605.     oldweap[id] = weaponid
    606. }
    607.  
    608. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
    609. {
    610.     if(!is_user_alive(Player) || get_user_weapon(Player) != CSW_M3 || !g_has_railcannon[Player])
    611.         return FMRES_IGNORED
    612.    
    613.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    614.     return FMRES_HANDLED
    615. }
    616.  
    617. public fw_RAIL_PrimaryAttack(Weapon)
    618. {
    619.     new Player = get_pdata_cbase(Weapon, 41, 4)
    620.    
    621.     if (!g_has_railcannon[Player])
    622.         return
    623.    
    624.     g_IsInPrimaryAttack = 1
    625.     pev(Player,pev_punchangle,cl_pushangle[Player])
    626.    
    627.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
    628.     if(g_clip_ammo[Player]) Make_Muzzleflash(Player)
    629. }
    630.  
    631. public fw_RAIL_PrimaryAttack_Post(Weapon)
    632. {
    633.     g_IsInPrimaryAttack = 0
    634.     new Player = get_pdata_cbase(Weapon, 41, 4)
    635.    
    636.     new szClip, szAmmo
    637.     get_user_weapon(Player, szClip, szAmmo)
    638.    
    639.     if(!is_user_alive(Player))
    640.         return
    641.  
    642.     if(g_has_railcannon[Player])
    643.     {
    644.         if (!g_clip_ammo[Player] && railcannon_mode[Player] == 1)
    645.             return
    646.        
    647.         g_reload[Player] = 0
    648.         remove_task( Player + 1331 )
    649.         new Float:push[3]
    650.         pev(Player,pev_punchangle,push)
    651.         xs_vec_sub(push,cl_pushangle[Player],push)
    652.         xs_vec_mul_scalar(push,cvar_recoil_railcannon,push)
    653.         xs_vec_add(push,cl_pushangle[Player],push)
    654.         set_pev(Player,pev_punchangle,push)
    655.        
    656.         UTIL_PlayWeaponAnimation(Player,random_num(4,5))
    657.         set_weapons_timeidle(Player, CSW_M3, 0.3)
    658.         set_player_nextattackx(Player, 0.3)
    659.         g_clip_ammo[Player] --
    660.        
    661.         if(railcannon_mode[Player] == 3) emit_sound(Player, CHAN_WEAPON, "weapons/railcanon-2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    662.         else emit_sound(Player, CHAN_WEAPON, Fire_Sounds, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    663.        
    664.         railcannon_mode[Player] = 1
    665.     }
    666. }
    667.  
    668. public Make_Muzzleflash(id)
    669. {
    670.     static Float:Origin[3], TE_FLAG
    671.     get_position(id, 32.0, 6.0, -15.0, Origin)
    672.    
    673.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    674.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
    675.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
    676.    
    677.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
    678.     write_byte(TE_EXPLOSION)
    679.     engfunc(EngFunc_WriteCoord, Origin[0])
    680.     engfunc(EngFunc_WriteCoord, Origin[1])
    681.     engfunc(EngFunc_WriteCoord, Origin[2])
    682.     write_short(g_MuzzleFlash_SprId)
    683.     write_byte(2)
    684.     write_byte(30)
    685.     write_byte(TE_FLAG)
    686.     message_end()
    687. }
    688.  
    689. public fw_CmdStart(id, uc_handle, seed)
    690. {
    691.     new ammo, clip, weapon = get_user_weapon(id, clip, ammo)
    692.     if (!g_has_railcannon[id] || weapon != CSW_M3 || !is_user_alive(id))
    693.         return
    694.    
    695.     static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    696.        
    697.     if(!pev_valid(ent))
    698.         return
    699.        
    700.     static CurButton
    701.     CurButton = get_uc(uc_handle, UC_Buttons)
    702.    
    703.     if(CurButton & IN_ATTACK)
    704.     {
    705.         new wpn = fm_get_user_weapon_entity(id, get_user_weapon(id))
    706.        
    707.         new Id = pev( wpn, pev_owner ), clip, bpammo
    708.         get_user_weapon( Id, clip, bpammo )
    709.         if( g_has_railcannon[ Id ] ) {
    710.         if( clip >= 2 ) {
    711.             if( g_reload[Id] ) {
    712.                 remove_task( Id + 1331 )
    713.                 g_reload[Id] = 0
    714.             }
    715.         }
    716.         else if( clip == 1 )
    717.         {
    718.             if(get_pdata_float(Id, 83, 4) <= 0.3)
    719.             {
    720.                 if( g_reload[Id] ) {
    721.                 remove_task( Id + 1331 )
    722.                 g_reload[Id] = 0
    723.             }
    724.             }
    725.         }
    726.     }
    727.     }
    728.    
    729.     else if(CurButton & IN_ATTACK2)
    730.     {
    731.         if(!zz[id] && get_pdata_float(id, 83, 4) <= 0.0 && g_clip_ammo[id] >= 1)
    732.         {
    733.             set_weapons_timeidle(id, CSW_M3, 200.0)
    734.             set_player_nextattackx(id, 200.0)
    735.             UTIL_PlayWeaponAnimation(id, 1)
    736.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage1_start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    737.             set_task(0.6, "charge_idle2", id)
    738.             zz[id] = 1
    739.             udah[id] = 0
    740.             railcannon_mode[id] = 2
    741.            
    742.             update_specialammo(id, g_SpecialAmmo[id], 0)
    743.             g_SpecialAmmo[id] ++
    744.             update_specialammo(id, g_SpecialAmmo[id], 1)
    745.            
    746.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    747.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    748.             g_clip_ammo[id] --
    749.         }
    750.     }
    751.    
    752.     else if(!(pev(id, pev_oldbuttons) & IN_ATTACK) && zz[id])
    753.     {
    754.         zz[id] = 0
    755.         if(udah[id])
    756.         {
    757.             if(g_clip_ammo[id] >= 1)
    758.             {
    759.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    760.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    761.                 set_player_nextattackx(id, 1.1)
    762.                 udah[id] = 0
    763.                 remove_task(id+TASK_SOUND)
    764.                
    765.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    766.                 g_SpecialAmmo[id] = 0
    767.                
    768.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    769.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    770.                 g_clip_ammo[id] ++
    771.             }
    772.             else
    773.             {
    774.                 new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    775.                 cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    776.                 g_clip_ammo[id] ++
    777.                
    778.                 ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    779.                 set_weapons_timeidle(id, CSW_M3, 1.1)
    780.                 set_player_nextattackx(id, 1.1)
    781.                 udah[id] = 0
    782.                 remove_task(id+TASK_SOUND)
    783.                
    784.                 update_specialammo(id, g_SpecialAmmo[id], 0)
    785.                 g_SpecialAmmo[id] = 0
    786.             }
    787.         }
    788.     }
    789. }
    790.  
    791. public charge_idle2(id)
    792. {
    793.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    794.         return
    795.     if(zz[id])
    796.     {
    797.         if(g_clip_ammo[id] >= 1)
    798.         {
    799.             UTIL_PlayWeaponAnimation(id, 2)
    800.             set_weapons_timeidle(id, CSW_M3, 200.0)
    801.             set_player_nextattackx(id, 200.0)
    802.             set_task(0.6, "charge_idle3", id)
    803.            
    804.             update_specialammo(id, g_SpecialAmmo[id], 0)
    805.             g_SpecialAmmo[id] ++
    806.             update_specialammo(id, g_SpecialAmmo[id], 1)
    807.            
    808.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    809.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    810.             g_clip_ammo[id] --
    811.         }
    812.         else
    813.         {
    814.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    815.        
    816.             if(!pev_valid(ent))
    817.                 return
    818.            
    819.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    820.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    821.             g_clip_ammo[id] ++
    822.            
    823.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    824.             set_weapons_timeidle(id, CSW_M3, 1.1)
    825.             set_player_nextattackx(id, 1.1)
    826.            
    827.             update_specialammo(id, g_SpecialAmmo[id], 0)
    828.             g_SpecialAmmo[id] = 0
    829.         }
    830.     }
    831.     else
    832.     {
    833.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    834.        
    835.         if(!pev_valid(ent))
    836.             return
    837.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    838.         set_weapons_timeidle(id, CSW_M3, 1.1)
    839.         set_player_nextattackx(id, 1.1)
    840.        
    841.         update_specialammo(id, g_SpecialAmmo[id], 0)
    842.         g_SpecialAmmo[id] = 0
    843.        
    844.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    845.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    846.         g_clip_ammo[id] ++
    847.     }
    848. }
    849.  
    850. public charge_idle3(id)
    851. {
    852.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    853.         return
    854.     if(zz[id])
    855.     {
    856.         if(g_clip_ammo[id] >= 1)
    857.         {
    858.             UTIL_PlayWeaponAnimation(id, 3)
    859.             emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    860.             set_task(0.794, "play_sound", id+TASK_SOUND,_,_,"b")
    861.             udah[id] = 1
    862.             railcannon_mode[id] = 3
    863.             set_weapons_timeidle(id, CSW_M3, 200.0)
    864.             set_player_nextattackx(id, 200.0)
    865.            
    866.             update_specialammo(id, g_SpecialAmmo[id], 0)
    867.             g_SpecialAmmo[id] ++
    868.             update_specialammo(id, g_SpecialAmmo[id], 1)
    869.            
    870.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    871.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] - 1)
    872.             g_clip_ammo[id] --
    873.         }
    874.         else
    875.         {
    876.             static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    877.        
    878.             if(!pev_valid(ent))
    879.                 return
    880.             new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    881.             cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    882.             g_clip_ammo[id] ++
    883.            
    884.             ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    885.             set_weapons_timeidle(id, CSW_M3, 1.1)
    886.             set_player_nextattackx(id, 1.1)
    887.            
    888.             update_specialammo(id, g_SpecialAmmo[id], 0)
    889.             g_SpecialAmmo[id] = 0
    890.         }
    891.     }
    892.     else
    893.     {
    894.         static ent; ent = fm_get_user_weapon_entity(id, CSW_M3)
    895.        
    896.         if(!pev_valid(ent))
    897.             return
    898.         ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
    899.         set_weapons_timeidle(id, CSW_M3, 1.1)
    900.         set_player_nextattackx(id, 1.1)
    901.        
    902.         update_specialammo(id, g_SpecialAmmo[id], 0)
    903.         g_SpecialAmmo[id] = 0
    904.        
    905.         new weapon = find_ent_by_owner( -1, "weapon_m3", id )
    906.         cs_set_weapon_ammo( weapon, g_clip_ammo[id] + 1)
    907.         g_clip_ammo[id] ++
    908.     }
    909. }
    910.  
    911. public play_sound(id)
    912. {
    913.     id -= TASK_SOUND
    914.    
    915.     if(!is_user_alive(id) || get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    916.         return
    917.    
    918.     emit_sound(id, CHAN_WEAPON, "weapons/railcanon_chage3_loop.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    919. }
    920.  
    921. public fw_railcannonidleanim(Weapon)
    922. {
    923.     new id = get_pdata_cbase(Weapon, 41, 4)
    924.  
    925.     if(!is_user_alive(id) || !g_has_railcannon[id] || get_user_weapon(id) != CSW_M3)
    926.         return HAM_IGNORED;
    927.    
    928.     if(railcannon_mode[id] == 1 && get_pdata_float(Weapon, 48, 4) <= 0.25)
    929.     {
    930.         UTIL_PlayWeaponAnimation(id, 0)
    931.         set_pdata_float(Weapon, 48, 20.0, 4)
    932.         return HAM_SUPERCEDE;
    933.     }
    934.    
    935.     if(railcannon_mode[id] == 3 && get_pdata_float(Weapon, 48, 4) <= 0.01)
    936.     {
    937.         UTIL_PlayWeaponAnimation(id, 3)
    938.         set_pdata_float(Weapon, 48, 1.7, 4)
    939.         return HAM_SUPERCEDE;
    940.     }
    941.  
    942.     return HAM_IGNORED;
    943. }
    944.  
    945. public update_specialammo(id, Ammo, On)
    946. {
    947.     static AmmoSprites[33]
    948.     format(AmmoSprites, sizeof(AmmoSprites), "number_%d", Ammo)
    949.    
    950.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("StatusIcon"), {0,0,0}, id)
    951.     write_byte(On)
    952.     write_string(AmmoSprites)
    953.     write_byte(42) // red
    954.     write_byte(255) // green
    955.     write_byte(42) // blue
    956.     message_end()
    957. }
    958.  
    959. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    960. {
    961.     if ((eventid != g_orig_event_railcannon) || !g_IsInPrimaryAttack)
    962.         return FMRES_IGNORED
    963.        
    964.     if (!(1 <= invoker <= g_MaxPlayers))
    965.         return FMRES_IGNORED
    966.  
    967.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    968.     return FMRES_SUPERCEDE
    969. }
    970.  
    971. public RAILCANNON_Reload( wpn ) {
    972.     if(railcannon_mode[pev( wpn, pev_owner )] == 3)
    973.           return HAM_SUPERCEDE
    974.          
    975.     if( g_has_railcannon[ pev( wpn, pev_owner ) ] ) {
    976.         RAILCANNON_Reload_Post( wpn )
    977.         return HAM_SUPERCEDE
    978.     }
    979.     return HAM_IGNORED
    980. }
    981.  
    982. public RAILCANNON_Reload_Post(weapon) {
    983.     new id = pev( weapon, pev_owner )
    984.     if(railcannon_mode[id] == 3 || g_reload[id])
    985.           return HAM_SUPERCEDE
    986.     new clip, bpammo
    987.     get_user_weapon(id, clip, bpammo )
    988.     if( g_has_railcannon[ id ] && clip < cvar_clip_railcannon && bpammo > 0 ) {
    989.         if(!task_exists( id+1331 )) set_task( 0.1, "reload", id+1331 )
    990.         }
    991.     return HAM_IGNORED
    992. }
    993.  
    994. public reload( id ) {
    995.     id -= 1331
    996.     set_weapons_timeidle(id, CSW_M3, 3.0)
    997.     set_player_nextattackx(id, 3.0)
    998.     UTIL_PlayWeaponAnimation(id, 6)
    999.     g_reload[id] = 1
    1000.     set_task(3.0, "isi", id)
    1001. }
    1002.  
    1003. public isi(id)
    1004. {
    1005.     if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
    1006.         return
    1007.    
    1008.     if(!g_reload[id])
    1009.         return
    1010.    
    1011.     new clip, pluru, pengurang, bpammo, weapon = find_ent_by_owner( -1, "weapon_m3", id )
    1012.     get_user_weapon(id, clip, bpammo )
    1013.     pengurang = cvar_clip_railcannon - clip
    1014.     pluru = bpammo - pengurang
    1015.     cs_set_user_bpammo( id, CSW_M3, pluru )
    1016.    
    1017.     if(bpammo <= pengurang) cs_set_weapon_ammo( weapon, clip + bpammo)
    1018.     else cs_set_weapon_ammo( weapon, cvar_clip_railcannon)
    1019.    
    1020.     g_clip_ammo[id] = cvar_clip_railcannon
    1021. }
    1022.  
    1023. stock knockback(ent, Float:VicOrigin[3], Float:speed, type)
    1024. {
    1025.     static Float:fl_Velocity[3]
    1026.     static Float:EntOrigin[3]
    1027.     static Float:EntVelocity[3]
    1028.    
    1029.     pev(ent, pev_velocity, EntVelocity)
    1030.     pev(ent, pev_origin, EntOrigin)
    1031.     static Float:distance_f
    1032.     distance_f = get_distance_f(EntOrigin, VicOrigin)
    1033.    
    1034.     static Float:fl_Time; fl_Time = distance_f / speed
    1035.    
    1036.     if(type == 1)
    1037.     {
    1038.         fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
    1039.         fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
    1040.         fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time       
    1041.         } else if(type == 2) {
    1042.         fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
    1043.         fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
    1044.         fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
    1045.     }
    1046.    
    1047.     xs_vec_add(EntVelocity, fl_Velocity, fl_Velocity)
    1048.     set_pev(ent, pev_velocity, fl_Velocity)
    1049. }
    1050.  
    1051. stock fm_cs_get_current_weapon_ent(id)
    1052. {
    1053.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
    1054. }
    1055.  
    1056. stock fm_set_weapon_ammo(entity, amount)
    1057. {
    1058.     set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
    1059. }
    1060.  
    1061. stock fm_cs_get_weapon_ent_owner(ent)
    1062. {
    1063.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
    1064. }
    1065.  
    1066. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
    1067. {
    1068.     set_pev(Player, pev_weaponanim, Sequence)
    1069.    
    1070.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    1071.     write_byte(Sequence)
    1072.     write_byte(pev(Player, pev_body))
    1073.     message_end()
    1074. }
    1075.  
    1076. stock set_player_nextattackx(id, Float:nexttime)
    1077. {
    1078.     if(!is_user_alive(id))
    1079.         return
    1080.        
    1081.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
    1082. }
    1083.  
    1084. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
    1085. {
    1086.     new Float:vfEnd[3], viEnd[3]
    1087.     get_user_origin(id, viEnd, 3)  
    1088.     IVecFVec(viEnd, vfEnd)
    1089.    
    1090.     new Float:fOrigin[3], Float:fAngle[3]
    1091.    
    1092.     pev(id, pev_origin, fOrigin)
    1093.     pev(id, pev_view_ofs, fAngle)
    1094.    
    1095.     xs_vec_add(fOrigin, fAngle, fOrigin)
    1096.    
    1097.     new Float:fAttack[3]
    1098.    
    1099.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1100.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    1101.    
    1102.     new Float:fRate
    1103.    
    1104.     fRate = fDis / vector_length(fAttack)
    1105.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
    1106.    
    1107.     xs_vec_add(fOrigin, fAttack, output)
    1108. }
    1109.  
    1110. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
    1111. {
    1112.     if(!is_user_alive(id))
    1113.         return
    1114.        
    1115.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
    1116.     if(!pev_valid(entwpn))
    1117.         return
    1118.        
    1119.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1120.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
    1121.     set_pdata_float(entwpn, 48, TimeIdle + 1.0, WEAP_LINUX_XTRA_OFF)
    1122. }
    1123.  
    1124. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
    1125. {
    1126.     new_velocity[0] = origin2[0] - origin1[0]
    1127.     new_velocity[1] = origin2[1] - origin1[1]
    1128.     new_velocity[2] = origin2[2] - origin1[2]
    1129.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    1130.     new_velocity[0] *= num
    1131.     new_velocity[1] *= num
    1132.     new_velocity[2] *= num
    1133.    
    1134.     return 1;
    1135. }
    1136.  
    1137. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
    1138. {
    1139.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    1140.    
    1141.     pev(id, pev_origin, vOrigin)
    1142.     pev(id, pev_view_ofs, vUp) //for player
    1143.     xs_vec_add(vOrigin, vUp, vOrigin)
    1144.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
    1145.    
    1146.     angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
    1147.     angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
    1148.     angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
    1149.    
    1150.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    1151.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    1152.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
    1153. }
    1154.  
    1155.  
    1156. stock drop_weapons(id, dropwhat)
    1157. {
    1158.     static weapons[32], num, i, weaponid
    1159.     num = 0
    1160.     get_user_weapons(id, weapons, num)
    1161.      
    1162.     for (i = 0; i < num; i++)
    1163.     {
    1164.         weaponid = weapons[i]
    1165.          
    1166.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    1167.         {
    1168.             static wname[32]
    1169.             get_weaponname(weaponid, wname, sizeof wname - 1)
    1170.             engclient_cmd(id, "drop", wname)
    1171.         }
    1172.     }
    1173. }

Try this Bro ... And Test it and then report here
Bro can you post it in our extra-item section?

Ok Bro
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#6

Post