Raised This Month: $ Target: $400
 0% 

How to fix the bug that makes any weapon to influence the damage done by the jetpack?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 10-27-2021 , 18:11   How to fix the bug that makes any weapon to influence the damage done by the jetpack?
Reply With Quote #1

Hello. There is a bug that allows any weapon, added as an extra item, to influence damage done by the jetpack's rocket.

It doesn't matter what weapon you use, the jetpack's rocket damage will be influenced immediately when you switch from jetpack to weapon, after you launch the jetpack's rocket.

I will give an example with jetpack and golden AK-47.

This is the code of the jetpack plugin i use:

Code:
/*
---------------------------------------------------------
   #  #  #    #===    ###    ##    #
  #    ##     #===   #      #  #    #
   #   #      #===    ###    ##    #
---------------------------------------------------------
[ZP] Extra Item: Jetpack + Bazooka 1.2

Plugin made by <VeCo>
Special thanks to:
 - truex_88: for finding the bugs fixed in version 1.2.

---------------------------------------------------------
If you modify the code, please DO NOT change the author!
---------------------------------------------------------
Contacts:
e-mail: [email protected]
skype: veco_kn
---------------------------------------------------------
Changes log:
 -> v 1.0 = First release!
 -> v 1.1 = Now, the bazooka can break func_breakable
	    entities.
	    Fixed bug with the knife model.
 -> v 1.2 = Fixed sound getting louder while flying.
			Fixed rocket exploding on trigger entities.
---------------------------------------------------------
Don't forget to visit http://www.amxmodxbg.org :)
---------------------------------------------------------
*/

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>
#include <cstrike>
#include <zombieplague>

new sprite_explosion,sprite_beamcylinder, jp_itemid,
cvar_cost,cvar_damage,cvar_speed,cvar_reload_time,cvar_radius,
cvar_start_energy,cvar_remove_energy,cvar_heal_energy,cvar_heal_time,cvar_zvelocity,cvar_aimvelocity,
cvar_can_drop,cvar_one_round,
maxplayers,hudsync, has_jetpack[33],can_shoot[33],energy[33], Float:last_sndplay[33]
public plugin_precache()
{
	precache_model("models/v_egon.mdl")
	precache_model("models/p_egon.mdl")
	precache_model("models/w_egon.mdl")
	
	precache_model("models/rpgrocket.mdl")
	
	sprite_explosion = precache_model("sprites/zerogxplode.spr")
	sprite_beamcylinder = precache_model("sprites/white.spr")
	
	precache_sound("weapons/rocketfire1.wav")
	precache_sound("common/bodydrop2.wav")
	precache_sound("items/gunpickup2.wav")
	precache_sound("jetpack.wav")
}

public plugin_init() {
	register_plugin("[ZP] Extra Item: Jetpack + Bazooka", "1.2", "<VeCo>")
	
	cvar_cost = register_cvar("vecjp_cost","35")
	cvar_speed = register_cvar("vecjp_rocket_speed","800")
	cvar_damage = register_cvar("vecjp_damage","80000")
	cvar_reload_time = register_cvar("vecjp_reload_time","6.0")
	cvar_radius = register_cvar("vecjp_radius","250")
	cvar_start_energy = register_cvar("vecjp_start_energy","250")
	cvar_remove_energy = register_cvar("vecjp_remove_energy","1")
	cvar_heal_energy = register_cvar("vecjp_heal_energy","10")
	cvar_heal_time = register_cvar("vecjp_heal_time","1.0")
	cvar_zvelocity = register_cvar("vecjp_zvelocity","300")
	cvar_aimvelocity = register_cvar("vecjp_aimvelocity","300")
	cvar_can_drop = register_cvar("vecjp_can_drop","1")
	cvar_one_round = register_cvar("vecjp_one_round","0")
	
	jp_itemid = zp_register_extra_item("Jetpack + bazooka",get_pcvar_num(cvar_cost),ZP_TEAM_HUMAN)
	
	register_clcmd("drop","drop_jetpack")
	
	RegisterHam(Ham_Weapon_SecondaryAttack,"weapon_knife","shoot_jetpack")
	RegisterHam(Ham_Player_Jump,"player","fly_jetpack")
	
	register_touch("weapon_jetpack","player","get_jetpack")
	register_touch("","info_jetpack_rocket","touch_jetpack")
	
	register_event("DeathMsg","hook_death","a")
	register_event("CurWeapon","event_curweapon","be","1=1","2=29")
	
	register_logevent("round_end",2,"1=Round_End")
	
	maxplayers = get_maxplayers()
	hudsync = CreateHudSyncObj()
}

public zp_extra_item_selected(id,itemid)
{
	if(itemid != jp_itemid) return
	
	if(has_jetpack[id])
	{
		client_print(id,print_chat,"[VECJP] You have already own a jetpack.")
		return
	}
	
	has_jetpack[id] = true
	can_shoot[id] = true
	energy[id] = get_pcvar_num(cvar_start_energy)
	
	emit_sound(id,CHAN_AUTO,"items/gunpickup2.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM)
	
	client_cmd(id,"weapon_knife")
	
	entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl")
	entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl")
	
	set_task(get_pcvar_float(cvar_heal_time),"action_heal_user_jetpack",id)
}

public drop_jetpack(id) if(get_pcvar_num(cvar_can_drop) && get_user_weapon(id) == CSW_KNIFE && has_jetpack[id]) action_drop_user_jetpack(id)

public shoot_jetpack(ent)
{
	new id = entity_get_edict(ent,EV_ENT_owner)
	if(!has_jetpack[id]) return HAM_IGNORED
	
	if(!can_shoot[id])
	{
		client_print(id,print_center,"[VECJP] You can't shoot with the jetpack right now. Please wait...")
		return HAM_IGNORED
	}
	
	action_shoot_user_jetpack(id)
	
	return HAM_IGNORED
}

public fly_jetpack(id)
{
	if(!has_jetpack[id]) return HAM_IGNORED
	
	if(!energy[id])
	{
		client_print(id,print_center,"[VECJP] You don't have enough energy to fly.")
		return HAM_IGNORED
	}
	
	if(get_user_button(id) & IN_DUCK) action_fly_user_jetpack(id)
	
	return HAM_IGNORED
}

public action_heal_user_jetpack(id)
{
	if(!is_user_connected(id) || !has_jetpack[id]) return
	
	if(zp_get_user_zombie(id) || zp_get_user_nemesis(id))
	{
		action_remove_user_jetpack(id)
		return
	}
	
	if(entity_get_int(id,EV_INT_flags) & FL_INWATER)
	{
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_KILLBEAM)
		write_short(id)
		message_end()
	}
	
	if(entity_get_int(id,EV_INT_flags) & FL_ONGROUND)
	{
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_KILLBEAM)
		write_short(id)
		message_end()
		
		if(energy[id] < get_pcvar_num(cvar_start_energy))
		{
			energy[id] += get_pcvar_num(cvar_heal_energy)
			if(energy[id] > get_pcvar_num(cvar_start_energy)) energy[id] = get_pcvar_num(cvar_start_energy)
			
			set_hudmessage(255, 0, 0, -1.0, 0.29, 0, 6.0, 1.0, 0.1, 0.2, -1)
			ShowSyncHudMsg(id,hudsync,"Jetpack Energy: [%i / %i]",energy[id],get_pcvar_num(cvar_start_energy))
		}
	}
	
	set_task(get_pcvar_float(cvar_heal_time),"action_heal_user_jetpack",id)
}

public action_drop_user_jetpack(id)
{
	remove_task(id)
	
	has_jetpack[id] = false
	can_shoot[id] = false
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_KILLBEAM)
	write_short(id)
	message_end()
	
	emit_sound(id,CHAN_AUTO,"common/bodydrop2.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM)
	
	new ent = create_entity("info_target")
	if(ent)
	{
		new Float:origin[3],Float:velocity[3]
		
		entity_get_vector(id,EV_VEC_origin,origin)
		velocity_by_aim(id,60,velocity)
		
		origin[0] += velocity[0]

		origin[1] += velocity[1]
		
		entity_set_string(ent,EV_SZ_classname,"weapon_jetpack")
		entity_set_model(ent,"models/w_egon.mdl")
		
		entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
		entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)
		
		entity_set_int(ent,EV_INT_iuser1,energy[id])
		
		entity_set_float(ent,EV_FL_gravity,1.0)
		
		entity_set_origin(ent,origin)
	}
	
	energy[id] = 0
}

public action_shoot_user_jetpack(id)
{
	can_shoot[id] = false
	
	emit_sound(id,CHAN_AUTO,"weapons/rocketfire1.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM)
	
	new ent = create_entity("info_target")
	if(ent)
	{
		new Float:origin[3],Float:velocity[3],Float:angles[3]
		
		entity_get_vector(id,EV_VEC_origin,origin)
		velocity_by_aim(id,60,velocity)
		
		origin[0] += velocity[0]
		origin[1] += velocity[1]
		
		velocity[0] = 0.0
		velocity[1] = 0.0
		
		velocity_by_aim(id,get_pcvar_num(cvar_speed),velocity)
		
		entity_set_string(ent,EV_SZ_classname,"info_jetpack_rocket")
		entity_set_model(ent,"models/rpgrocket.mdl")
		
		entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
		entity_set_int(ent,EV_INT_movetype,MOVETYPE_FLY)
		
		entity_set_size(ent,Float:{-0.5,-0.5,-0.5},Float:{0.5,0.5,0.5})
		
		entity_set_vector(ent,EV_VEC_velocity,velocity)
		
		vector_to_angle(velocity,angles)
		entity_set_vector(ent,EV_VEC_angles,angles)
		
		entity_set_edict(ent,EV_ENT_owner,id)
		
		entity_set_int(ent,EV_INT_effects,entity_get_int(ent,EV_INT_effects) | EF_LIGHT)
		
		entity_set_origin(ent,origin)
		
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_BEAMFOLLOW)
		write_short(ent)
		write_short(sprite_beamcylinder)
		write_byte(30)
		write_byte(5)
		write_byte(255)
		write_byte(255)
		write_byte(255)
		write_byte(140)
		message_end()
	}
	
	set_task(get_pcvar_float(cvar_reload_time),"action_reload_user_jetpack",id)
}

public action_fly_user_jetpack(id)
{
	new Float:velocity[3]
	velocity_by_aim(id,get_pcvar_num(cvar_aimvelocity),velocity)
	velocity[2] += float(get_pcvar_num(cvar_zvelocity))
	entity_set_vector(id,EV_VEC_velocity,velocity)
	
	energy[id] -= get_pcvar_num(cvar_remove_energy)
	if(energy[id] < 1) energy[id] = 0
	
	set_hudmessage(255, 0, 0, -1.0, 0.29, 0, 6.0, 1.0, 0.1, 0.2, -1)
	ShowSyncHudMsg(id,hudsync,"Jetpack Energy: [%i / %i]",energy[id],get_pcvar_num(cvar_start_energy))
	
	if((get_gametime() - last_sndplay[id]) > 1.0)
	{
		emit_sound(id,CHAN_AUTO,"jetpack.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM)
		last_sndplay[id] = get_gametime()
	}
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_KILLBEAM)
	write_short(id)
	message_end()
	
	if(entity_get_int(id,EV_INT_flags) & FL_INWATER) return
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_BEAMFOLLOW)
	write_short(id)
	write_short(sprite_beamcylinder)
	write_byte(25)
	write_byte(10)
	write_byte(255)
	write_byte(255)
	write_byte(255)
	write_byte(175)
	message_end()
}

public action_reload_user_jetpack(id)
{
	if(!is_user_connected(id) || !has_jetpack[id]) return
	can_shoot[id] = true
	
	client_print(id,print_center,"[VECJP] Your jetpack has been reloaded. Now you can shoot again!")
}

public get_jetpack(ent,id)
{
	if(has_jetpack[id] || zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return
	
	remove_task(id)
	
	has_jetpack[id] = true
	can_shoot[id] = false
	energy[id] = entity_get_int(ent,EV_INT_iuser1)
	
	emit_sound(id,CHAN_AUTO,"items/gunpickup2.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM)
	
	client_cmd(id,"weapon_knife")
	
	entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl")
	entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl")
	
	set_task(get_pcvar_float(cvar_reload_time),"action_reload_user_jetpack",id)
	set_task(get_pcvar_float(cvar_heal_time),"action_heal_user_jetpack",id)
	
	remove_entity(ent)
}

public touch_jetpack(world,ent)
{
	if(!is_valid_ent(ent) || (is_valid_ent(world) && entity_get_int(world,EV_INT_solid) == SOLID_TRIGGER)) return
	
	new Float:origin[3], origin_int[3], owner = entity_get_edict(ent,EV_ENT_owner)
	entity_get_vector(ent,EV_VEC_origin,origin)
	
	FVecIVec(origin,origin_int)
	
	new id = -1
	while((id = find_ent_in_sphere(id,origin,float(get_pcvar_num(cvar_radius)))) != 0)
	{
		if(!is_user_connected(owner)) break
		
		if(1 <= id <= maxplayers)
		{
			if(!zp_get_user_zombie(id) && !zp_get_user_nemesis(id)) continue
			ExecuteHamB(Ham_TakeDamage,id, owner,owner, float(get_pcvar_num(cvar_damage)), DMG_ALWAYSGIB)
		} else {
			if(!is_valid_ent(id)) continue
			
			new classname[15]
			entity_get_string(id,EV_SZ_classname,classname,14)
			
			if(!equal(classname,"func_breakable")) continue
			
			ExecuteHamB(Ham_TakeDamage,id, owner,owner, float(get_pcvar_num(cvar_damage)), DMG_ALWAYSGIB)
		}
	}
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY,origin_int)
	write_byte(TE_EXPLOSION)
	write_coord(origin_int[0])
	write_coord(origin_int[1])
	write_coord(origin_int[2])
	write_short(sprite_explosion)
	write_byte(floatround(get_pcvar_num(cvar_radius) * 0.5))
	write_byte(10)
	write_byte(0)
	message_end()
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY,origin_int)
	write_byte(TE_DLIGHT)
	write_coord(origin_int[0])
	write_coord(origin_int[1])
	write_coord(origin_int[2])
	write_byte(floatround(get_pcvar_num(cvar_radius) * 0.25))
	write_byte(200)
	write_byte(145)
	write_byte(0)
	write_byte(16)
	write_byte(32)
	message_end()
	
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY,origin_int)
	write_byte(TE_BEAMCYLINDER)
	write_coord(origin_int[0])
	write_coord(origin_int[1])
	write_coord(origin_int[2])
	write_coord(origin_int[0])
	write_coord(origin_int[1])
	write_coord(origin_int[2] + get_pcvar_num(cvar_radius))
	write_short(sprite_beamcylinder)
	write_byte(0)
	write_byte(0)
	write_byte(10)
	write_byte(50)
	write_byte(0)
	write_byte(255)
	write_byte(255)
	write_byte(255)
	write_byte(160)
	write_byte(0)
	message_end()
	
	remove_entity(ent)
}

public hook_death()
{
	new id = read_data(2)
	action_remove_user_jetpack(id)
}

public action_remove_user_jetpack(id)
{
	if(get_pcvar_num(cvar_can_drop))
	{
		if(has_jetpack[id] && get_user_weapon(id) == CSW_KNIFE) action_drop_user_jetpack(id)
		
		has_jetpack[id] = false
		can_shoot[id] = false
		energy[id] = 0
		
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
		write_byte(TE_KILLBEAM)
		write_short(id)
		message_end()
	} else {
		has_jetpack[id] = false
		can_shoot[id] = false
		energy[id] = 0
	}
}

public event_curweapon(id)
{
	if(has_jetpack[id] && !zp_get_user_zombie(id))
	{
		entity_set_string(id,EV_SZ_viewmodel,"models/v_egon.mdl")
		entity_set_string(id,EV_SZ_weaponmodel,"models/p_egon.mdl")
	}
}

public round_end()
{
	remove_entity_name("weapon_jetpack")
	
	if(get_pcvar_num(cvar_one_round))
	{
		for(new i=1;i<maxplayers;i++)
		{
			if(is_user_connected(i))
			{
				has_jetpack[i] = false
				can_shoot[i] = false
				energy[i] = 0
			}
		}
	}
}

public client_connect(id) has_jetpack[id] = false
public client_disconnect(id) has_jetpack[id] = false
This is the code of the golden AK-47 plugin i use:

Code:
/*
[ZP] Extra Item: Golden Ak 47
Team: Humans

Description: This plugin adds a new weapon for Human Teams.
Weapon Cost: 30

Features:
- This weapon do more damage
- This weapon has zoom
- Launch Lasers
- This weapon has unlimited bullets

Credits:

KaOs - For his Dual MP5 mod

Cvars:


- zp_goldenak_dmg_multiplier <5> - Damage Multiplier for Golden Ak 47
- zp_goldenak_gold_bullets <1|0> - Golden bullets effect ?
- zp_goldenak_custom_model <1|0> - Golden ak Custom Model
- zp_goldenak_unlimited_clip <1|0> - Golden ak Unlimited Clip 

*/



#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>

#define is_valid_player(%1) (1 <= %1 <= 32)

new AK_V_MODEL[64] = "models/zombie_plague/v_golden_ak47.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_golden_ak47.mdl"

/* Pcvars */
new cvar_dmgmultiplier, cvar_goldbullets,  cvar_custommodel, cvar_uclip

// Item ID
new g_itemid

new bool:g_HasAk[33]

new g_hasZoom[ 33 ]
new bullets[ 33 ]

// Sprite
new m_spriteTexture

const Wep_ak47 = ((1<<CSW_AK47))

public plugin_init()
{
	
	/* CVARS */
	cvar_dmgmultiplier = register_cvar("zp_goldenak_dmg_multiplier", "15")
	cvar_custommodel = register_cvar("zp_goldenak_custom_model", "1")
	cvar_goldbullets = register_cvar("zp_goldenak_gold_bullets", "0")
	cvar_uclip = register_cvar("zp_goldenak_unlimited_clip", "1")
	
	// Register The Plugin
	register_plugin("[ZP] Extra: Golden Ak 47", "1.1", "AlejandroSk")
	// Register Zombie Plague extra item
	g_itemid = zp_register_extra_item("Golden Ak 47", 30, ZP_TEAM_HUMAN)
	// Death Msg
	register_event("DeathMsg", "Death", "a")
	// Weapon Pick Up
	register_event("WeapPickup","checkModel","b","1=19")
	// Current Weapon Event
	register_event("CurWeapon","checkWeapon","be","1=1")
	register_event("CurWeapon", "make_tracer", "be", "1=1", "3>0")
	// Ham TakeDamage
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	register_forward( FM_CmdStart, "fw_CmdStart" )
	RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
	
}

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

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

public Death()
{
	g_HasAk[read_data(2)] = false
}

public fwHamPlayerSpawnPost(id)
{
	g_HasAk[id] = false
}

public plugin_precache()
{
	precache_model(AK_V_MODEL)
	precache_model(AK_P_MODEL)
	m_spriteTexture = precache_model("sprites/dot.spr")
	precache_sound("weapons/zoom.wav")
}

public zp_user_infected_post(id)
{
	if (zp_get_user_zombie(id))
	{
		g_HasAk[id] = false
	}
}

public checkModel(id)
{
	if ( zp_get_user_zombie(id) )
		return PLUGIN_HANDLED
	
	new szWeapID = read_data(2)
	
	if ( szWeapID == CSW_AK47 && g_HasAk[id] == true && get_pcvar_num(cvar_custommodel) )
	{
		set_pev(id, pev_viewmodel2, AK_V_MODEL)
		set_pev(id, pev_weaponmodel2, AK_P_MODEL)
	}
	return PLUGIN_HANDLED
}

public checkWeapon(id)
{
	new plrClip, plrAmmo, plrWeap[32]
	new plrWeapId
	
	plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
	
	if (plrWeapId == CSW_AK47 && g_HasAk[id])
	{
		checkModel(id)
	}
	else 
	{
		return PLUGIN_CONTINUE
	}
	
	if (plrClip == 0 && get_pcvar_num(cvar_uclip))
	{
		// If the user is out of ammo..
		get_weaponname(plrWeapId, plrWeap, 31)
		// Get the name of their weapon
		give_item(id, plrWeap)
		engclient_cmd(id, plrWeap) 
		engclient_cmd(id, plrWeap)
		engclient_cmd(id, plrWeap)
	}
	return PLUGIN_HANDLED
}



public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
    if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
    }
}

public fw_CmdStart( id, uc_handle, seed )
{
	if( !is_user_alive( id ) ) 
		return PLUGIN_HANDLED
	
	if( ( get_uc( uc_handle, UC_Buttons ) & IN_ATTACK2 ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK2 ) )
	{
		new szClip, szAmmo
		new szWeapID = get_user_weapon( id, szClip, szAmmo )
		
		if( szWeapID == CSW_AK47 && g_HasAk[id] == true && !g_hasZoom[id] == true)
		{
			g_hasZoom[id] = true
			cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )
			emit_sound( id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100 )
		}
		
		else if ( szWeapID == CSW_AK47 && g_HasAk[id] == true && g_hasZoom[id])
		{
			g_hasZoom[ id ] = false
			cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
			
		}
		
	}
	return PLUGIN_HANDLED
}


public make_tracer(id)
{
	if (get_pcvar_num(cvar_goldbullets))
	{
		new clip,ammo
		new wpnid = get_user_weapon(id,clip,ammo)
		new pteam[16]
		
		get_user_team(id, pteam, 15)
		
		if ((bullets[id] > clip) && (wpnid == CSW_AK47) && g_HasAk[id]) 
		{
			new vec1[3], vec2[3]
			get_user_origin(id, vec1, 1) // origin; your camera point.
			get_user_origin(id, vec2, 4) // termina; where your bullet goes (4 is cs-only)
			
			
			//BEAMENTPOINTS
			message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
			write_byte (0)     //TE_BEAMENTPOINTS 0
			write_coord(vec1[0])
			write_coord(vec1[1])
			write_coord(vec1[2])
			write_coord(vec2[0])
			write_coord(vec2[1])
			write_coord(vec2[2])
			write_short( m_spriteTexture )
			write_byte(1) // framestart
			write_byte(5) // framerate
			write_byte(2) // life
			write_byte(10) // width
			write_byte(0) // noise
			write_byte( 255 )     // r, g, b
			write_byte( 215 )       // r, g, b
			write_byte( 0 )       // r, g, b
			write_byte(200) // brightness
			write_byte(150) // speed
			message_end()
		}
	
		bullets[id] = clip
	}
	
}

public zp_extra_item_selected(player, itemid)
{
	if ( itemid == g_itemid )
	{
		if ( user_has_weapon(player, CSW_AK47) )
		{
			drop_prim(player)
		}
		
		give_item(player, "weapon_ak47")
		client_print(player, print_chat, "[ZP] You bought Golden Ak - 47")
		g_HasAk[player] = true;
	}
}

stock drop_prim(id) 
{
	new weapons[32], num
	get_user_weapons(id, weapons, num)
	for (new i = 0; i < num; i++) {
		if (Wep_ak47 & (1<<weapons[i])) 
		{
			static wname[32]
			get_weaponname(weapons[i], wname, sizeof wname - 1)
			engclient_cmd(id, "drop", wname)
		}
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
*/
The damage of the jetpack's rocket i set at 80000
Code:
cvar_damage = register_cvar("vecjp_damage","80000")
The damage multiplier of the golden AK-47 is set at 15
Code:
cvar_dmgmultiplier = register_cvar("zp_goldenak_dmg_multiplier", "15")
If you launch the jetpack rocket toward a zombie, you will deal 80000 damage, when the rocket explodes and affects the zombie.

If you launch the jetpack rocket toward a zombie, but then you switch to golden AK-47 BEFORE the rocket hits the zombie, you will deal 2100000 damage, when the rocket explodes and affects the zombie.

The 2100000 damage will be done by the jetpack rocket, because the rocket's damage will be influenced by the golden AK-47's damage multiplier.

So, how to fix this bug? There are other weapons that influence the jetpack rocket's damage, but i don't know how to fix this bug. However, if someone explain me how to fix this bug for golden AK-47, i will understand how to fix this bug for other weapons, too.

Thanks.

Last edited by GlobalPlague; 10-27-2021 at 18:35. Reason: mistake
GlobalPlague is offline
Old 10-27-2021, 18:31
GlobalPlague
This message has been deleted by GlobalPlague. Reason: quoted my original post by mistake
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-28-2021 , 00:53   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #3

Attempts to fix the exploit. Untested.
Code:
#include engine_stocks public fw_TakeDamage(victim, inflictor, attacker, Float:damage) if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] ) {     if(!has_fired_rocket(attacker))         SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) ) } bool:has_fired_rocket(attacker) {     new fired_rocket = find_ent(-1,"info_jetpack_rocket")     return pev(fired_rocket, pev_owner) != attacker ? false : true }
__________________
DJEarthQuake is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 10-29-2021 , 10:46   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #4

Quote:
Originally Posted by DJEarthQuake View Post
Attempts to fix the exploit. Untested.
Code:
#include engine_stocks public fw_TakeDamage(victim, inflictor, attacker, Float:damage) if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] ) {     if(!has_fired_rocket(attacker))         SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) ) } bool:has_fired_rocket(attacker) {     new fired_rocket = find_ent(-1,"info_jetpack_rocket")     return pev(fired_rocket, pev_owner) != attacker ? false : true }
Hello. Thanks for trying to help me.

Sadly, i get the following errors hwnei try to compile to code you gave me:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// bugfix.sma
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(4) : error 017: undefined symbol "is_valid_player"
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(4) : warning 215: expression has no effect
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(4) : error 001: expected token: ";", but found "]"
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(6) : error 010: invalid function or declaration
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(7) : error 021: symbol already defined: "get_pcvar_float"
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(18 ) : warning 203: symbol is never used: "SetHamParamFloat"
// C:\Mod\cstrike\addons\amxmodx\scripting\bugfi x.sma(18 ) : warning 203: symbol is never used: "has_fired_rocket"
//
// 4 Errors.
// Could not locate output file C:\Mod\cstrike\addons\amxmodx\scripting\compi led\bugfix.amx (compile failed).
//
// Compilation Time: 0.53 sec
// ----------------------------------------

Press enter to exit ...

Last edited by GlobalPlague; 10-29-2021 at 10:52. Reason: mistake
GlobalPlague is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-29-2021 , 11:20   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #5

It's replacement code not standalone.

Comment out original function first. Can use /* comment out */ method for multiple lines.
Spoiler
__________________

Last edited by DJEarthQuake; 10-30-2021 at 07:28. Reason: typo
DJEarthQuake is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 10-30-2021 , 06:53   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #6

Quote:
Originally Posted by DJEarthQuake View Post
It's replacement code not standalone.

Comment out original function first. Can use /* comment out */ method for multiple lines.
Spoiler
Hello. Thanks for your reply.

Sadly, i'm not sure i understand what you mean.

What do you mean by "It's replacement code not standalone"? Do you mean that i don't have to use this code as separated plugin, but i have to integrate it into the code of the jetpack plugin or the golden AK-47 plugin?

Also, i don't see DEFINE lines in the code you presented. Also, what is the original function you are talking about, saying i have to un-comment it? Would you give me more details about what i have to do in order to make this code to work.

I'm not very familiar with Pawn-scripting, so i would like you to explain me things in more details, if possible.

Thanks.
GlobalPlague is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-30-2021 , 08:30   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #7

The spoiler is copy and paste into the AK script. Disregard comment about define. Typo. Meant include.

Highlight this in AK script.

Code:
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
    if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
    }
}
Paste entire contents of the spoiler. That's replacement code.
__________________
DJEarthQuake is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 10-30-2021 , 13:24   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #8

Quote:
Originally Posted by DJEarthQuake View Post
The spoiler is copy and paste into the AK script. Disregard comment about define. Typo. Meant include.

Highlight this in AK script.

Code:
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
    if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
    }
}
Paste entire contents of the spoiler. That's replacement code.
Alright. I did what you said, and the compiler didn't produce any errors or warnings. I tested your code, and it works. Thanks.

One more question, would you explain me how to add the same bugfix to other extra items, too?

I tried to do it by myself, but something didn't work.

When i tried to apply the bugfix to one of the extra items, the compiler produced a warning, and when i tested the extra item, the bugfix didn't work. Here is the warning:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// zp_extra_plasmagun.sma
// C:\Mod\cstrike\addons\amxmodx\scripting\zp_ex tra_plasmagun.sma(712) : warning 203: symbol is never used: "has_fired_plasmagun"
// Header size: 2524 bytes
// Code size: 17768 bytes
// Data size: 12528 bytes
// Stack/heap size: 16384 bytes; estimated max. usage=790 cells (3160 bytes)
// Total requirements: 49204 bytes
//
// 1 Warning.
// Done.
//
// Compilation Time: 1.25 sec
// ----------------------------------------

Press enter to exit ...


Here is how i changed the bugfix code in attempts to make it suit the plasma-gun:

I changed it from this:

Code:
bool:has_fired_rocket(attacker)
{
    new fired_rocket = find_ent(-1,"info_jetpack_rocket")
    return pev(fired_rocket, pev_owner) != attacker ? false : true
}
to this:

Code:
bool:has_fired_plasmagun(attacker)
{
    new fired_plasmagun = find_ent(-1,"info_plasmagun")
    return pev(fired_plasmagun, pev_owner) != attacker ? false : true
}
Then, i found this code:

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

	if (!g_has_plasmagun[attacker])
		return HAM_IGNORED;

	if (get_user_weapon(attacker) != CSW_AUG)
		return HAM_IGNORED;

	SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_plasmagun_damage));

	return HAM_IGNORED;
}
Then, i placed this:

Code:
bool:has_fired_plasmagun(attacker)
{
    new fired_plasmagun = find_ent(-1,"info_plasmagun")
    return pev(fired_plasmagun, pev_owner) != attacker ? false : true
}
below the "{" symbol that is under "return HAM_IGNORED;"

After i did it, this is how the whole code looks like:

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

	if (!g_has_plasmagun[attacker])
		return HAM_IGNORED;

	if (get_user_weapon(attacker) != CSW_AUG)
		return HAM_IGNORED;

	SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_plasmagun_damage));

	return HAM_IGNORED;
}

bool:has_fired_plasmagun(attacker)
{
    new fired_plasmagun = find_ent(-1,"info_plasmagun")
    return pev(fired_plasmagun, pev_owner) != attacker ? false : true
}
So, i would like to add the bugfix to other extra items, too. Would you explain me what to look for when i want to use the information of the extra item to add that information to the bugfix code?

For example, if i want to add this bugfix code to Plasma Gun, what values i have to add to the bugfix? What do i have to write in the following lines marked with "?"?


bool:has_fired_??????????(attacker)
{
new fired_?????????? = find_ent(-1,"info_??????????")
return pev(fired_??????????, pev_owner) != attacker ? false : true
}

I tried to add "plasmagun" but it didn't work. So, let's suppose i want to add this bug fix to Plasma Gun and MiniGun. If i want to do so, how should the bugfix code look lile?

Here are the codes of Plasma Gun and MiniGun:

Plasma Gun:

Code:
/*================================================================================
 
			---------------------------
			[ZP] Extra Item: Plasma Gun
			---------------------------

		Plasma Gun
		Copyright (C) 2017 by Crazy

		-------------------
		-*- Description -*-
		-------------------

		This plugin add a new weapon into your zombie plague mod with
		the name of Plasma Gun. That weapon launch powerfull green lasers!
		When the bullet of this weapon hit any object, a nice effect appers!

		----------------
		-*- Commands -*-
		----------------

		* zp_give_plasma_gun <target> - Give the item to target.

		-------------
		-*- Cvars -*-
		-------------

		* zp_plasma_gun_ammo <number> - Ammo amout.
		* zp_plasma_gun_clip <number> - Clip amout. (Max: 100)
		* zp_plasma_gun_one_round <0/1> - Only one round.
		* zp_plasma_gun_damage <number> - Damage multiplier.
		* zp_plasma_gun_unlimited <0/1> - Unlimited ammunition.

		------------------
		-*- Change Log -*-
		------------------

		* v0.1: (Mar 2017)
			- First release;

		---------------
		-*- Credits -*-
		---------------

		* MeRcyLeZZ: for the nice zombie plague mod.
		* Crazy: created the extra item code.
		* deanamx: for the nice weapon model.
		* And all zombie-mod players that use this weapon.


=================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <cs_ham_bots_api>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

// Item Name
#define ITEM_NAME "Plasma Gun"

// Item Cost
#define ITEM_COST 70

/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/

new const PLUGIN_VERSION[] = "v0.1";

new const V_PLASMAGUN_MDL[64] = "models/zombie_plague/v_plasma_gun.mdl";
new const P_PLASMAGUN_MDL[64] = "models/zombie_plague/p_plasma_gun.mdl";
new const W_PLASMAGUN_MDL[64] = "models/zombie_plague/w_plasma_gun.mdl";

new const PLASMAGUN_SOUNDS[][] = { "weapons/plasmagun_aug-1.wav", "weapons/plasmagun_aug-2.wav", "weapons/plasmagun_clipin1.wav",  "weapons/plasmagun_clipin2.wav", "weapons/plasmagun_clipout.wav", "weapons/plasmagun_draw.wav", "weapons/plasmagun_exp.wav", "weapons/plasmagun_idle.wav" };

new g_has_plasmagun[33], g_plasmagun, g_msgWeaponList, g_plasmabomb, g_xenobeam, g_event_plasmagun, g_playername[33][32], g_maxplayers, g_primary_attack, g_plasmagun_reload_clip[33], cvar_plasmagun_clip, cvar_plasmagun_ammo, cvar_plasmagun_damage, cvar_plasmagun_oneround, cvar_plasgun_infinit;

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

const m_iClip = 51;
const m_flNextAttack = 83;
const m_fInReload = 54;

const OFFSET_WEAPON_OWNER = 41;
const OFFSET_LINUX_WEAPONS = 4;
const OFFSET_LINUX = 5;
const OFFSET_ACTIVE_ITEM = 373;

const PLASMAGUN_KEY = 054687;

const WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_GALIL));

enum
{
	idle = 0,
	reload,
	draw,
	shoot1,
	shoot2,
	shoot3
}

public plugin_init()
{
	/* Plugin register */
	register_plugin("[ZP] Extra Item: Plasma Gun", PLUGIN_VERSION, "Crazy");

	/* Item register */
	g_plasmagun = zp_register_extra_item(ITEM_NAME, ITEM_COST, ZP_TEAM_HUMAN);

	/* Events */
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0");

	/* Messages */
	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");

	/* Admin command */
	register_concmd("zp_give_plasmagun", "cmd_give_plasmagun", 0);

	/* Forwards */
	register_forward(FM_UpdateClientData, "fw_UpdateData_Post", 1);
	register_forward(FM_SetModel, "fw_SetModel");
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");

	/* Ham Forwards */
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack_Post", 1);
	RegisterHam(Ham_Item_Deploy, "weapon_aug", "fw_Item_Deploy_Post", 1);
	RegisterHam(Ham_Item_AddToPlayer, "weapon_aug", "fw_Item_AddToPlayer_Post", 1);
	RegisterHam(Ham_Item_PostFrame, "weapon_aug", "fw_Item_PostFrame");
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "fw_PrimaryAttack");
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "fw_PrimaryAttack_Post", 1);
	RegisterHam(Ham_Weapon_Reload, "weapon_aug", "fw_Reload");
	RegisterHam(Ham_Weapon_Reload, "weapon_aug", "fw_Reload_Post", 1);
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
	RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage");

	/* Cvars */
	cvar_plasmagun_clip = register_cvar("zp_plasma_gun_clip", "50");
	cvar_plasmagun_ammo = register_cvar("zp_plasma_gun_ammo", "500");
	cvar_plasmagun_damage = register_cvar("zp_plasma_gun_damage", "9.5");
	cvar_plasmagun_oneround = register_cvar("zp_plasma_gun_one_round", "0");
	cvar_plasgun_infinit = register_cvar("zp_plasma_gun_unlimited", "0");

	/* Max Players */
	g_maxplayers = get_maxplayers()

	/* Message hook */
	g_msgWeaponList = get_user_msgid("WeaponList");
}

public plugin_precache()
{
	engfunc(EngFunc_PrecacheModel, V_PLASMAGUN_MDL);
	engfunc(EngFunc_PrecacheModel, P_PLASMAGUN_MDL);
	engfunc(EngFunc_PrecacheModel, W_PLASMAGUN_MDL);

	engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_plasmagun.txt");
	engfunc(EngFunc_PrecacheGeneric, "sprites/640hud3_plasma.spr");
	engfunc(EngFunc_PrecacheGeneric, "sprites/640hud91_plasma.spr");

	g_plasmabomb = engfunc(EngFunc_PrecacheModel, "sprites/plasmabomb.spr");
	g_xenobeam = engfunc(EngFunc_PrecacheModel, "sprites/xenobeam.spr");

	for (new i = 0; i < sizeof PLASMAGUN_SOUNDS; i++)
	engfunc(EngFunc_PrecacheSound, PLASMAGUN_SOUNDS[i]);

	register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1);
	register_clcmd("weapon_plasmagun", "cmd_plasma_selected");
}

public zp_user_infected_post(id)
{
	g_has_plasmagun[id] = false;
}

public zp_user_humanized_post(id)
{
	g_has_plasmagun[id] = false;
}

public client_putinserver(id)
{
	g_has_plasmagun[id] = false;

	get_user_name(id, g_playername[id], charsmax(g_playername[]));
}

public event_round_start()
{
	for (new id = 0; id <= g_maxplayers; id++)
	{
		if (get_pcvar_num(cvar_plasmagun_oneround))
		g_has_plasmagun[id] = false;
	}
}

public cmd_give_plasmagun(id, level, cid)
{
	if ((get_user_flags(id) & level) != level)
		return PLUGIN_HANDLED;

	static arg[32], player;
	read_argv(1, arg, charsmax(arg));
	player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF));
	
	if (!player)
		return PLUGIN_HANDLED;

	if (g_has_plasmagun[player])
	{
		client_print(id, print_chat, "[ZP] The %s already have the %s.", g_playername[player], ITEM_NAME);
		return PLUGIN_HANDLED;
	}

	give_plasmagun(player);
	
	client_print(player, print_chat, "[ZP] You won a %s from %s!", ITEM_NAME, g_playername[id]);

	return PLUGIN_HANDLED;
}

public cmd_plasma_selected(client)
{
	engclient_cmd(client, "weapon_aug");
	return PLUGIN_HANDLED;
}

public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
	if (!is_user_alive(msg_entity))
		return;

	if (!g_has_plasmagun[msg_entity])
		return;

	if (get_user_weapon(msg_entity) != CSW_AUG)
		return;

	if (get_msg_arg_int(1) != 1)
		return;

	if (get_pcvar_num(cvar_plasgun_infinit))
	{
		static ent;
		ent = fm_cs_get_current_weapon_ent(msg_entity);

		if (!pev_valid(ent))
			return;

		cs_set_weapon_ammo(ent, get_pcvar_num(cvar_plasmagun_clip));
		set_msg_arg_int(3, get_msg_argtype(3), get_pcvar_num(cvar_plasmagun_clip));
	}
}

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

	if (g_has_plasmagun[id])
	{
		client_print(id, print_chat, "[ZP] You already have the %s.", ITEM_NAME);
		return;
	}

	give_plasmagun(id);

	client_print(id, print_chat, "[ZP] You bought the %s.", ITEM_NAME);
}

public fw_UpdateData_Post(id, sendweapons, cd_handle)
{
	if (!is_user_alive(id))
		return FMRES_IGNORED;

	if (!g_has_plasmagun[id])
		return FMRES_IGNORED;

	if (get_user_weapon(id) != CSW_AUG)
		return FMRES_IGNORED;

	set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);

	return FMRES_IGNORED;
}

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

	if (!equal(model, "models/w_aug.mdl"))
		return HAM_IGNORED;

	static class_name[33];
	pev(ent, pev_classname, class_name, charsmax(class_name));

	if (!equal(class_name, "weaponbox"))
		return FMRES_IGNORED;

	static owner, weapon;
	owner = pev(ent, pev_owner);
	weapon = find_ent_by_owner(-1, "weapon_aug", ent);

	if (!g_has_plasmagun[owner] || !pev_valid(weapon))
		return FMRES_IGNORED;

	g_has_plasmagun[owner] = false;

	set_pev(weapon, pev_impulse, PLASMAGUN_KEY);

	engfunc(EngFunc_SetModel, ent, W_PLASMAGUN_MDL);

	return FMRES_SUPERCEDE;
}

public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_event_plasmagun) || !g_primary_attack)
		return FMRES_IGNORED;

	if (!(1 <= invoker <= g_maxplayers))
		return FMRES_IGNORED;

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

	return FMRES_SUPERCEDE;
}

public fw_PrecacheEvent_Post(type, const name[])
{
	if (!equal("events/aug.sc", name))
		return HAM_IGNORED;

	g_event_plasmagun = get_orig_retval()

	return FMRES_HANDLED;
}

public fw_Item_Deploy_Post(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	set_pev(id, pev_viewmodel2, V_PLASMAGUN_MDL);
	set_pev(id, pev_weaponmodel2, P_PLASMAGUN_MDL);

	play_weapon_anim(id, draw);

	return HAM_IGNORED;
}

public fw_Item_AddToPlayer_Post(ent, id)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	if (!is_user_connected(id))
		return HAM_IGNORED;

	if (pev(ent, pev_impulse) == PLASMAGUN_KEY)
	{
		g_has_plasmagun[id] = true;
		set_pev(ent, pev_impulse, 0);
	}

	message_begin(MSG_ONE, g_msgWeaponList, _, id)
	write_string((g_has_plasmagun[id] ? "weapon_plasmagun" : "weapon_aug"))
	write_byte(4)
	write_byte(90)
	write_byte(-1)
	write_byte(-1)
	write_byte(0)
	write_byte(14)
	write_byte(CSW_AUG)
	write_byte(0)
	message_end()

	return HAM_IGNORED;
}

public fw_Item_PostFrame(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	static cvar_clip; cvar_clip = get_pcvar_num(cvar_plasmagun_clip);

	new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
	new bpammo = cs_get_user_bpammo(id, CSW_AUG);

	new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, OFFSET_LINUX);
	new fInReload = get_pdata_int(ent, m_fInReload, OFFSET_LINUX_WEAPONS);

	if (fInReload && flNextAttack <= 0.0)
	{
		new temp_clip = min(cvar_clip - clip, bpammo);

		set_pdata_int(ent, m_iClip, clip + temp_clip, OFFSET_LINUX_WEAPONS);

		cs_set_user_bpammo(id, CSW_AUG, bpammo-temp_clip);

		set_pdata_int(ent, m_fInReload, 0, OFFSET_LINUX_WEAPONS);

		fInReload = 0;
	}

	return HAM_IGNORED;
}

public fw_PrimaryAttack(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	if (!cs_get_weapon_ammo(ent))
		return HAM_IGNORED;

	g_primary_attack = true;

	return HAM_IGNORED;
}

public fw_PrimaryAttack_Post(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	if (!cs_get_weapon_ammo(ent))
		return HAM_IGNORED;

	g_primary_attack = false;

	play_weapon_anim(id, random_num(shoot1, shoot2));

	emit_sound(id, CHAN_WEAPON, PLASMAGUN_SOUNDS[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

	make_xenobeam(id);

	return HAM_IGNORED;
}

public fw_Reload(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	g_plasmagun_reload_clip[id] = -1;

	static cvar_clip; cvar_clip = get_pcvar_num(cvar_plasmagun_clip);

	new clip = get_pdata_int(ent, m_iClip, OFFSET_LINUX_WEAPONS);
	new bpammo = cs_get_user_bpammo(id, CSW_AUG);

	if (bpammo <= 0)
		return HAM_SUPERCEDE;

	if (clip >= cvar_clip)
		return HAM_SUPERCEDE;
	
	g_plasmagun_reload_clip[id] = clip;

	return HAM_IGNORED;
}

public fw_Reload_Post(ent)
{
	if (!pev_valid(ent))
		return HAM_IGNORED;

	new id = get_pdata_cbase(ent, OFFSET_WEAPON_OWNER, OFFSET_LINUX_WEAPONS);

	if (!is_user_alive(id))
		return HAM_IGNORED;

	if (!g_has_plasmagun[id])
		return HAM_IGNORED;

	if (g_plasmagun_reload_clip[id] == -1)
		return HAM_IGNORED;

	set_pdata_int(ent, m_iClip, g_plasmagun_reload_clip[id], OFFSET_LINUX_WEAPONS);
	set_pdata_int(ent, m_fInReload, 1, OFFSET_LINUX_WEAPONS);

	play_weapon_anim(id, reload);

	return HAM_IGNORED;
}

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

	if (!g_has_plasmagun[attacker])
		return HAM_IGNORED;

	if (get_user_weapon(attacker) != CSW_AUG)
		return HAM_IGNORED;

	SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_plasmagun_damage));

	return HAM_IGNORED;
}

public fw_TraceAttack_Post(ent, attacker, Float:damage, Float:dir[3], ptr, dmg_bits)
{
	if (!is_user_alive(attacker))
		return HAM_IGNORED;

	if (get_user_weapon(attacker) != CSW_AUG)
		return HAM_IGNORED;

	if (!g_has_plasmagun[attacker])
		return HAM_IGNORED;

	static Float:end[3];
	get_tr2(ptr, TR_vecEndPos, end);

	if(ent)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_DECAL)
		engfunc(EngFunc_WriteCoord, end[0])
		engfunc(EngFunc_WriteCoord, end[1])
		engfunc(EngFunc_WriteCoord, end[2])
		write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
		write_short(ent)
		message_end()
	}
	else
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_SPRITE)
		engfunc(EngFunc_WriteCoord, end[0])
		engfunc(EngFunc_WriteCoord, end[1])
		engfunc(EngFunc_WriteCoord, end[2])
		write_short(g_plasmabomb)
		write_byte(10)
		write_byte(200)
		message_end()
	}

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_GUNSHOTDECAL)
	engfunc(EngFunc_WriteCoord, end[0])
	engfunc(EngFunc_WriteCoord, end[1])
	engfunc(EngFunc_WriteCoord, end[2])
	write_short(attacker)
	write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
	message_end()

	return HAM_IGNORED;
}

give_plasmagun(id)
{
	drop_primary(id);

	g_has_plasmagun[id] = true;

	new weapon = fm_give_item(id, "weapon_aug");

	cs_set_weapon_ammo(weapon, get_pcvar_num(cvar_plasmagun_clip));
	cs_set_user_bpammo(id, CSW_AUG, get_pcvar_num(cvar_plasmagun_ammo));
}

play_weapon_anim(id, frame)
{
	set_pev(id, pev_weaponanim, frame);

	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
	write_byte(frame)
	write_byte(pev(id, pev_body))
	message_end()
}

drop_primary(id)
{
	static weapons[32], num;
	get_user_weapons(id, weapons, num);

	for (new i = 0; i < num; i++)
	{
		if (WEAPON_BITSUM & (1<<weapons[i]))
		{
			static wname[32];
			get_weaponname(weapons[i], wname, sizeof wname - 1);

			engclient_cmd(id, "drop", wname);
		}
	}
}

make_xenobeam(id)
{
	static originF[3];
	get_user_origin(id, originF, 3);

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMENTPOINT)
	write_short(id | 0x1000)
	write_coord(originF[0])
	write_coord(originF[1])
	write_coord(originF[2])
	write_short(g_xenobeam)
	write_byte(0)
	write_byte(0)
	write_byte(1)
	write_byte(20)
	write_byte(0)
	write_byte(110)
	write_byte(251)
	write_byte(110)
	write_byte(200)
	write_byte(5)
	message_end()
}

stock fm_give_item(index, const item[])
{
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
		return 0;

	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
	if (!pev_valid(ent))
		return 0;

	new Float:origin[3];
	pev(index, pev_origin, origin);
	set_pev(ent, pev_origin, origin);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);

	new save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, index);
	if (pev(ent, pev_solid) != save)
		return ent;

	engfunc(EngFunc_RemoveEntity, ent);

	return -1;
}

stock fm_cs_get_current_weapon_ent(id)
{
	if (pev_valid(id) != 2)
		return -1;
	
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
}
And, this is the code of MiniGun:

Code:
#include <amxmodx>
#include <engine>
#include <fakemeta_util>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define MAX_PLAYERS 32
#define MAX_BLOOD_DISTANCE	64
#define LOADUP_TIME		0.75
#define SHUTDOWN_TIME	1.7
#define SHAKE_FORCE		-5.0 //(must be negative value)
new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45}	// Gunshot decal list
// Plugin information
new const PLUGIN[] = "[ZP] WPN Minigun"
new const VERSION[] = "1.65"
new const AUTHOR[] = "CLLlAgOB"
// Weapon information
new const g_item_name[] = { "MiniGUN!" }
const g_item_cost = 30
// other
new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],bool:delay[33],bool:beackup[33],
clipp[33],clipstart,g_itemid_minigun,g_fwid,g_guns_eventids_bitsum,bool:g_fix_punchangle[33],
bool:frstCLIP[33],g_MaxPlayers, Float:g_lastShot[33], g_normal_trace[33],DMGMG,bool:haswhpnnmg[33],
Float:g_nextSound[33], g_plAction[33],bool:canfire[33],oneround,bool:user_bot[33],bool:delayhud[33],
clipstartsuv,bool:survivor[33],bool:is_alive[33],bool:is_connected[33]
// Blood
new g_blood
new g_bloodspray
// CS Player PData Offsets (win32)
const OFFSET_CSTEAMS = 114
// Linux diff's
const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
// Models
new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
// Sounds
new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
//no recoil
new const g_guns_events[][] = {"events/m249.sc"}
//connect valid?
#define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])

enum {
	anim_idle,
	anim_idle2,
	anim_gentleidle,
	anim_stillidle,
	anim_draw,
	anim_holster,
	anim_spinup,
	anim_spindown,
	anim_spinidle,
	anim_spinfire,
	anim_spinidledown
}

// Types
enum {
	act_none,
	act_load_up,
	act_run
}

public plugin_precache() {
	precache_model(P_MODEL)
	precache_model(V_MODEL)
	precache_model(W_MODEL)
	precache_sound(m_SOUND[0])
	precache_sound(m_SOUND[1])
	precache_sound(m_SOUND[2])
	precache_sound(m_SOUND[3])
	g_blood = precache_model("sprites/blood.spr")
	g_bloodspray = precache_model("sprites/bloodspray.spr")
	g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	clipstart = register_cvar("amx_ammo_m249","600")
	clipstartsuv = register_cvar("amx_ammosuv_m249","10000")
	m249 = 		register_cvar("amx_minigun_speed","0.7")
	DMGMG =		register_cvar("amx_minigun_damage","2.35")
	oneround = 	register_cvar("amx_oneround","0")
	g_itemid_minigun = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
	register_event("CurWeapon","event_curweapon","be", "1=1")
	register_event("DeathMsg","unminigun","a")
	register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
	register_forward(FM_CmdStart, "fwd_CmdStart")
	register_forward(FM_EmitSound,"fwd_emitsound")
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
	register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
	register_forward(FM_StartFrame, "fwd_StartFrame")
	register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
	register_clcmd("drop","dropcmd", 0)
	g_MaxPlayers = get_maxplayers()
	//events
	register_logevent("event_start", 2, "1=Round_Start")
	register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
	register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
	unregister_forward(FM_PrecacheEvent, g_fwid, 1)
}

// Client joins the game
public client_putinserver(id)
{
	// Player joined
	is_connected[id] = true
}
// Client leaving
public fw_ClientDisconnect(id)
{
	is_connected[id] = false
	is_alive[id] = false
}
public fw_PlayerSpawn_Post(id)
{
	// Not alive or didn't join a team yet
	if (!is_user_alive(id) || !fm_cs_get_user_team(id))
		return;
	// Player spawned
	is_alive[id] = true
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
	//player die
	is_alive[victim] = false
}

public unminigun(){
	new id = read_data(2) 
	if(has_minigun[id] && !is_alive[id]) {
		new Float:Aim[3],Float:origin[3]
		VelocityByAim(id, 64, Aim)
		entity_get_vector(id,EV_VEC_origin,origin)
		
		origin[0] += Aim[0]
		origin[1] += Aim[1]
		
		new minigun = create_entity("info_target")
		entity_set_string(minigun,EV_SZ_classname,"minigun")
		entity_set_model(minigun,W_MODEL)	
		
		entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
		entity_set_int(minigun,EV_INT_solid,1)
		
		entity_set_int(minigun,EV_INT_movetype,6)
		entity_set_int(minigun, EV_INT_iuser1, clipp[id])
		entity_set_vector(minigun,EV_VEC_origin,origin)
		has_minigun[id] = false
		remowegun(id)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}

//damage lvl
public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
	if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true  && attacker!=victim)
		{
		damage = damage*get_pcvar_float(DMGMG)
		SetHamParamFloat(4, damage)
		return HAM_IGNORED
		} 
	return HAM_IGNORED
}


public event_start_freezetime(){
	remove_miniguns()
	static iPlayers[32], iPlayersNum, i 
	get_players(iPlayers, iPlayersNum, "a")
	if(get_pcvar_num(oneround)){
		for (i = 0; i <= iPlayersNum; ++i){
			if(has_minigun[iPlayers[i]]){
				has_minigun[iPlayers[i]] = false 
				remowegun(iPlayers[i])
				removesuv(iPlayers[i])
			}
		}
	} else { 
		for (i = 0; i <= iPlayersNum; ++i){
			g_plAction[iPlayers[i]] = false
			canfire[iPlayers[i]] = false
			frstCLIP[iPlayers[i]] = true	
			set_task(0.1,"event_curweapon",iPlayers[i])
			removesuv(iPlayers[i])
			}
	}
}

public removesuv(id){
	if(survivor[id]){
		has_minigun[id] = false
		survivor[id] = false
		remowegun(id)
	}
}

// remove gun and save all guns
public remowegun(id) { 
	new wpnList[32] 
	new number
	get_user_weapons(id,wpnList,number) 
	for (new i = 0;i < number ;i++) { 
		if (wpnList[i] == CSW_M249) {
			fm_strip_user_gun(id, wpnList[i])
		}
	}
} 

public event_start(){
	static iPlayers[32], iPlayersNum, i 
	get_players(iPlayers, iPlayersNum, "a")
	for (i = 0; i <= iPlayersNum; ++i)
		canfire[iPlayers[i]] = true
}



public fwEvGameWillRestartIn() { 
	static iPlayers[32], iPlayersNum, i 
	get_players(iPlayers, iPlayersNum, "a") 
	for (i = 0; i <= iPlayersNum; ++i) 
		has_minigun[iPlayers[i]] = false
}
public client_connect(id){
	canfire[id]= false
	has_minigun[id] = false
	g_normal_trace[id] = 0
	if(is_user_bot(id)) user_bot[id] = true 
	else user_bot[id] = false 
}

//block sound no ammo in atack
public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
{	
	if (!is_user_valid_connected(id) || !has_minigun[id])
		return FMRES_IGNORED;
	else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
		{
		return FMRES_SUPERCEDE
		}	
	return FMRES_IGNORED
}

// someone bought our extra item
public zp_extra_item_selected(id, itemid)
    {
		if (itemid == g_itemid_minigun)	give_weapon(id,0,1)
	}
//infect plaer
public zp_user_infected_pre(player, infector){
	has_minigun[player] = false
	dropcmd(player)
}

public dropcmd(id) {
	if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
		new Float:Aim[3],Float:origin[3]
		VelocityByAim(id, 64, Aim)
		entity_get_vector(id,EV_VEC_origin,origin)
		
		origin[0] += Aim[0]
		origin[1] += Aim[1]
		
		new minigun = create_entity("info_target")
		entity_set_string(minigun,EV_SZ_classname,"minigun")
		entity_set_model(minigun,W_MODEL)	
		
		entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
		entity_set_int(minigun,EV_INT_solid,1)
		
		entity_set_int(minigun,EV_INT_movetype,6)
		entity_set_int(minigun, EV_INT_iuser1, clipp[id])
		entity_set_vector(minigun,EV_VEC_origin,origin)
		has_minigun[id] = false
		canfire[id] = false
		remowegun(id)
		g_plAction[id] = false
		return PLUGIN_HANDLED
	} 
	return PLUGIN_CONTINUE
}

public pfn_touch(ptr, ptd) {
	if(is_valid_ent(ptr)) {
		new classname[32]
		entity_get_string(ptr,EV_SZ_classname,classname,31)
		
		if(equal(classname, "minigun")) {
			if(is_valid_ent(ptd)) {
				new id = ptd
				if(id > 0 && id < 34) {
					if(!has_minigun[id] && is_alive[id] && !zp_get_user_zombie(id)) {
						give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
						remove_entity(ptr)
					}
				}
			}
		}
	}
}

public remove_miniguns() {
	new nextitem  = find_ent_by_class(-1,"minigun")
	while(nextitem) {
		remove_entity(nextitem)
		nextitem = find_ent_by_class(-1,"minigun")
	}
	return PLUGIN_CONTINUE
}

//give wpn
public give_weapon(id, ammo, frst){
	has_minigun[id] = true
	give_item(id,"weapon_m249")
	canfire[id] = true
	clipp[id] = ammo
	if(frst) frstCLIP[id] = true
	else beackup[id] = true
	
}


//set models
public event_curweapon(id){
	if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;	
	new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
	if(zp_get_user_survivor(id) && get_pcvar_num(clipstartsuv)!=0 && !survivor[id]){
		survivor[id] = true
		give_weapon(id,0,1)
	}
	if((has_minigun[id]) && (weapon == CSW_M249)){
		if(g_plAction[id] != act_run && frstCLIP[id]){
				if(survivor[id]){
						clipp[id] = get_pcvar_num(clipstartsuv)
					} else {
						clipp[id] = get_pcvar_num(clipstart)
					}
				new ent = get_weapon_ent(id,weapon)
				if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
				cs_set_weapon_ammo(ent, clipp[id])
				frstCLIP[id] = false
			}
		if(g_plAction[id] != act_run && beackup[id]){
			new ent = get_weapon_ent(id,weapon)
			cs_set_weapon_ammo(ent, clipp[id])
			beackup[id] = false
		}
		if(clipp[id] == 0){
				new ent = get_weapon_ent(id,weapon)
				cs_set_weapon_ammo(ent, clipp[id])
			}
		if(g_plAction[id] == act_run){
			clipp[id] = clip
		}
		message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id) 
		write_byte(1) 
		write_byte(CSW_KNIFE) 
		write_byte(0) 
		message_end()
		if(!haswhpnnmg[id]){
			entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
			entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
			haswhpnnmg[id] = true
		}
		new	Ent = get_weapon_ent(id,weapon)
		new Float:N_Speed
		if(Ent) 
			{
			N_Speed = get_pcvar_float(m249)
			new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed	
			if (Delay > 0.0){
				set_pdata_float( Ent, 46, Delay, 4)
			}
		}
		ammo_hud(id)
		if(atk1[id]){
			fire_mode(id, 0)
		}
		if(atk2[id]){
			fire_mode(id, 1)
		}
	} 
	if(weapon != CSW_M249) haswhpnnmg[id] = false
	if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
	
	return;
 }	

//play anim
public native_playanim(player,anim)
{
	set_pev(player, pev_weaponanim, anim)
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
	write_byte(anim)
	write_byte(pev(player, pev_body))
	message_end()
}


 //marks on hit
 public native_gi_get_gunshot_decal()
{
	return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
}

//hit bulet 
public testbulet(id){
	// Find target
	new aimOrigin[3], target, body
	get_user_origin(id, aimOrigin, 3)
	get_user_aiming(id, target, body)
	
	if(target > 0 && target <= g_MaxPlayers)
	{
		new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
		pev(id, pev_origin, fStart)
		
		// Get ids view direction
		velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
		
		// Calculate position where blood should be displayed
		fStart[0] = float(aimOrigin[0])
		fStart[1] = float(aimOrigin[1])
		fStart[2] = float(aimOrigin[2])
		fEnd[0] = fStart[0]+fVel[0]
		fEnd[1] = fStart[1]+fVel[1]
		fEnd[2] = fStart[2]+fVel[2]
		
		// Draw traceline from victims origin into ids view direction to find
		// the location on the wall to put some blood on there
		new res
		engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
		get_tr2(res, TR_vecEndPos, fRes)
				
		// Show some blood :)
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
		write_byte(TE_BLOODSPRITE)
		write_coord(floatround(fStart[0])) 
		write_coord(floatround(fStart[1])) 
		write_coord(floatround(fStart[2])) 
		write_short(g_bloodspray)
		write_short(g_blood)
		write_byte(70)
		write_byte(random_num(1,2))
		message_end()
		
		
	} else {
		new decal = native_gi_get_gunshot_decal()
		
		// Check if the wall hit is an entity
		if(target)
		{
			// Put decal on an entity
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_DECAL)
			write_coord(aimOrigin[0])
			write_coord(aimOrigin[1])
			write_coord(aimOrigin[2])
			write_byte(decal)
			write_short(target)
			message_end()
		} else {
			// Put decal on "world" (a wall)
			message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
			write_byte(TE_WORLDDECAL)
			write_coord(aimOrigin[0])
			write_coord(aimOrigin[1])
			write_coord(aimOrigin[2])
			write_byte(decal)
			message_end()
		}
		
		// Show sparcles
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		write_coord(aimOrigin[0])
		write_coord(aimOrigin[1])
		write_coord(aimOrigin[2])
		write_short(id)
		write_byte(decal)
		message_end()
	}
}




//block anim standart wpn 
public UpdateClientData_Post( id, sendweapons, cd_handle ){
	if ( !is_alive[id] ) return FMRES_IGNORED;
	if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );      
	return FMRES_HANDLED;
}

 public fwd_CmdStart(id, uc_handle, seed)
{
	
	if(!is_alive[id] || !has_minigun[id]) return FMRES_IGNORED
	if(!canfire[id]) return FMRES_HANDLED
	
	if(haswhpnnmg[id])
	{
		static buttons
		buttons = get_uc(uc_handle, UC_Buttons)		
		if(buttons & IN_ATTACK)
		{
			atk1[id] = true
			atk2[id] = false
			
		
		}
		else if(buttons & IN_ATTACK2)
		{
			atk2[id] = true
			atk1[id] = false
		}
		if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
			buttons &= ~IN_ATTACK
			buttons &= ~IN_ATTACK2
			set_uc(uc_handle, UC_Buttons, buttons)
			fire_mode(id,0)
		} else if(atk2[id] || atk1[id] && clipp[id]==0){
			fire_mode(id,1)
		}
			
	}
	return FMRES_IGNORED	
}

// in fire
fire_mode(id, type) {
	static Float:gtime
	gtime = get_gametime()
	g_lastShot[id] = gtime
	
	if(g_nextSound[id] <= gtime && canfire[id]) {
		switch(g_plAction[id]) {
			case act_none: {
				native_playanim(id, anim_spinup)
				emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_nextSound[id] = gtime + LOADUP_TIME
				g_plAction[id] = act_load_up
			}
			case act_load_up: {
				g_nextSound[id] = gtime
				g_plAction[id] = act_run
			}
		}
	}
	
	if(g_plAction[id] == act_run) {
		if(type == 0 && clipp[id]>0 && atk1[id]){
			emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
			testbulet(id)
			if(!delay[id]) {
				native_playanim(id, anim_spinfire)
				ammo_hud(id)
				set_task(0.2,"delayanim",id)
				delay[id] = true
				}
		} 
		else { 
			if(!delay[id]) {
				ammo_hud(id)
				emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
				native_playanim(id, anim_spinidle)
				set_task(0.2,"delayanim",id)
				delay[id] = true
			}
		}
	}
	atk1[id] = false
	atk2[id] = false
}

public delayanim(id){
	delay[id] = false
}

//sound and anim
public fwd_StartFrame() {
	static Float:gtime, id
	
	gtime = get_gametime()
	
	for(id = 0; id <= g_MaxPlayers; id++) {
		if(g_plAction[id] != act_none) {
			
			if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
				native_playanim(id, anim_spinidledown)
				emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_nextSound[id] = gtime + SHUTDOWN_TIME
				g_plAction[id] = act_none
			}
		}
	}
}


// No recoil stuff

public fwPrecacheEvent(type, const name[]) {
	for (new i = 0; i < sizeof g_guns_events; ++i) {
		if (equal(g_guns_events[i], name)) {
			g_guns_eventids_bitsum |= (1<<get_orig_retval())
			return FMRES_HANDLED
		}
	}

	return FMRES_IGNORED
}
public fwPlaybackEvent(flags, invoker, eventid) {
	if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers) || !haswhpnnmg[invoker] || !has_minigun[invoker])
		return FMRES_IGNORED

	g_fix_punchangle[invoker] = true

	return FMRES_HANDLED
}

public fwPlayerPostThink(id) {
	if (g_fix_punchangle[id]) {
		g_fix_punchangle[id] = false
		set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
		return FMRES_HANDLED
	}

	return FMRES_IGNORED
}

public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
	if (!(1 <= id <= g_MaxPlayers))
		return FMRES_IGNORED

	if (!g_normal_trace[id]) {
		g_normal_trace[id] = ptr
		return FMRES_HANDLED
	}
	if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !is_alive[id] || !haswhpnnmg[id] || !has_minigun[id])
		return FMRES_IGNORED

	fix_recoil_trace(id, start, ptr)

	return FMRES_SUPERCEDE
}

// show ammo clip
public ammo_hud(id) {
	if(!delayhud[id]) {
		delayhud[id] = true
		new AmmoHud[65]
		new clip = clipp[id]
		format(AmmoHud, 64, "Ammo: %i", clip)
		set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
		show_hudmessage(id,"%s",AmmoHud)
		set_task(0.2,"delayhutmsg",id)
	}
}

public delayhutmsg(id){
	delayhud[id]= false
}

//get weapon id
stock get_weapon_ent(id,wpnid=0,wpnName[]="")
{
	// who knows what wpnName will be
	static newName[24];

	// need to find the name
	if(wpnid) get_weaponname(wpnid,newName,23);

	// go with what we were told
	else formatex(newName,23,"%s",wpnName);

	// prefix it if we need to
	if(!equal(newName,"weapon_",7))
		format(newName,23,"weapon_%s",newName);

	return fm_find_ent_by_owner(get_maxplayers(),newName,id);
} 
fix_recoil_trace(id, const Float:start[], ptr) {
	static Float:dest[3]
	pev(id, pev_v_angle, dest)
	engfunc(EngFunc_MakeVectors, dest)
	global_get(glb_v_forward, dest)
	xs_vec_mul_scalar(dest, 9999.0, dest)
	xs_vec_add(start, dest, dest)
	engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
}
// Get User Team
stock fm_cs_get_user_team(id)
{
	return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
}
So, if i want to add the bugfix to these two extra items, what should the bugfix code look like? Would you explain me what shoild i know before adding this bugfix to any extra item i choose?

Before applying the bugfix to other extra items, what values/words/terms do i have to transfer from the extra item to the bugfix code? How do i know what values/terms/words to write in the bugfix code by watching the code of the extra item?

In order to make the bugfix to work on an extra item, what do i have to write in the following lines marked with "?"?


bool:has_fired_??????????(attacker)
{
new fired_?????????? = find_ent(-1,"info_??????????")
return pev(fired_??????????, pev_owner) != attacker ? false : true
}

I'm sorry for my bad English. I hope you understand me.

Thanks.

Last edited by GlobalPlague; 10-30-2021 at 13:29. Reason: mistake
GlobalPlague is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-30-2021 , 19:15   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #9

Nice. Welcome. Put it before SetHamParamFloat.

if(!has_fired_whatever(attacker))
SetHamParamFloat...
__________________
DJEarthQuake is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 10-31-2021 , 18:20   Re: How to fix the bug that makes any weapon to influence the damage done by the jetp
Reply With Quote #10

Quote:
Originally Posted by DJEarthQuake View Post
Nice. Welcome. Put it before SetHamParamFloat.

if(!has_fired_whatever(attacker))
SetHamParamFloat...
Is this how the code shouuld look like? Red code is the bugfix code:

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

	if (!g_has_plasmagun[attacker])
		return HAM_IGNORED;

	if (get_user_weapon(attacker) != CSW_AUG)
		return HAM_IGNORED;
		
	if(!has_fired_plasmagun(attacker))

	SetHamParamFloat(OFFSET_LINUX_WEAPONS, damage * get_pcvar_float(cvar_plasmagun_damage));

	return HAM_IGNORED;
}

bool:has_fired_plasmagun(attacker)
{
    new fired_plasmagun = find_ent(-1,"info_plasmagun")
    return pev(fired_plasmagun, pev_owner) != attacker ? false : true
}
I added "if(!has_fired_plasmagun(attacker))" where you told me to add it - now the compiler doen't produce any errors or warnings. However, the bugfix doesn't work. The jetpack rocket's damage is still influenced when you fire the rocket and switch to PlasmaGun before the rocket hit a zombie.

Any ideas how to fix this bug?

Shouldn't we try to edit the jetpack code, and add bugfixes there, instead of adding bugfixes in every extra item (weapon) one by one? Is there a way to edit the jetpack code in a way the jetpack rocket's damage to not be influenced by other weapons when you switch to other weapons after you fire the rocket but you switch to other weapons before the rocket hit a zombie?

Or, maybe the bugfix works, but i didn't add it correctly? Didn't i add the bugfix in the way you told me to add it?

Last edited by GlobalPlague; 10-31-2021 at 18:22.
GlobalPlague is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode