Available Extra bombs for zombies

Unpaid Requests, Public Plugins
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

Extra bombs for zombies

#1

Post by czirimbolo » 5 years ago

Please can someone covert this extra addons to our zombie escape mod and make them for ZOMBIE VIPS only?

JUMP GRENADE:

Code: Select all

/*
- Создание плагинов на закз:

- Контакты:
- Vk: http://vk.com/Opo4uMapy
- ICQ: 585552410
*/

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

#define PLUGIN		"[ZP] Extra Item: Jump Bomb"
#define VERSION    	"1.0"
#define AUTHOR    	"Opo4uMapy"

native cs_get_user_bpammo(index, weapon)
native cs_set_user_bpammo(index, weapon, amount)

#define JUMPBOMB_ID		55556

/////////////////////////////////////Cvars/////////////////////////////////////

#define ITEM_NAME		"Jump Grenade" 	// Имя айтема
#define ITEM_COST		6 		// Стоимость за 1 бомбу
#define MAX_GRENADE    		5 		// Лимит гранат
#define RADIUS			300.0 		// Радиус взрыва
#define JUMP_DAMAGE		20		// Урон
#define JUMP_EXP		500.0		// Сила отдачи от гранаты	

#define GRENADE_ICON				//Иконка с лева. Что бы отключить поставьте //

#define BUY_GRENADE_MSG		"[ZP] Вы купили гранату джамп"
#define MAX_GRENADE_MSG		"[ZP] Вы купили маскимум гранат"

#define TRAIL		//Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )

/////////////////////////////////////WeaponList/////////////////////////////////////

#define WEAPONLIST 	// WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )

#define WEAPON_DEFAULT		"weapon_smokegrenade"	//Weapon под которую сделана граната
#define DEFAULT_CSW		CSW_SMOKEGRENADE	//CSW под которую сделана граната

#if defined WEAPONLIST
#define WEAPON_NEW		"weapon_zombj1_sisa"	//Название WeaponList'a новой гранаты

new const WeaponList_Sprite[][] =
{
	"sprites/weapon_zombj1_sisa.txt",
	"sprites/640hud61.spr",
	"sprites/640hud7x.spr"
}

enum
{
	prim_ammoid 		= 13,
	prim_ammomaxamount 	= 1,
	sec_ammoid 		= -1,
	sec_ammomaxamount 	= -1,
	slotid 			= 3,
	number_in_slot 		= 3,
	weaponid 		= 9,
	flags 			= 24
}
#endif

////////////////////////////////////////////////////////////////////////////////////

// Модели гранаты
new const BOMB_MODEL[][] = 
{
	"models/v_zombibomb.mdl",
	"models/p_zombibomb.mdl",
	"models/w_zombibomb.mdl"
}

//Звуки покупки
#define	g_SoundGrenadeBuy	"items/gunpickup2.wav"
#define g_SoundAmmoPurchase	"items/9mmclip1.wav"
	
//Звук взрыва
#define g_SoundBombExplode	"nst_zombie/zombi_bomb_exp.wav"

//Не изменять! Звуки прописаны в модели.
new const frogbomb_sound[][] = 
{
	"nst_zombie/zombi_bomb_pull_1.wav", 
	"nst_zombie/zombi_bomb_deploy.wav",
	"nst_zombie/zombi_bomb_throw.wav"
}

new const frogbomb_sound_idle[][] = 
{ 
	"nst_zombie/zombi_bomb_idle_1.wav", 
	"nst_zombie/zombi_bomb_idle_2.wav", 
	"nst_zombie/zombi_bomb_idle_3.wav", 
	"nst_zombie/zombi_bomb_idle_4.wav"
}
new g_itemid

new g_JumpGrenadeCount[33], g_iExplo
#if defined TRAIL
new g_trailSpr
#endif
#if defined GRENADE_ICON
new grenade_icons[33][32]
#endif

public plugin_precache()
{
	static i

	for(i = 0; i < sizeof BOMB_MODEL; i++)
		precache_model(BOMB_MODEL[i])

	for(i = 0; i < sizeof frogbomb_sound; i++)
		precache_sound(frogbomb_sound[i])

	for(i = 0; i < sizeof frogbomb_sound_idle; i++)
		precache_sound(frogbomb_sound_idle[i])

	precache_sound(g_SoundGrenadeBuy)
	precache_sound(g_SoundAmmoPurchase)
	precache_sound(g_SoundBombExplode)

	#if defined WEAPONLIST
	register_clcmd(WEAPON_NEW, "hook")

	for(i = 0; i < sizeof WeaponList_Sprite; i++)
		precache_generic(WeaponList_Sprite[i])

	#endif

	g_iExplo = precache_model("sprites/zombiebomb_exp.spr")

	#if defined TRAIL
	g_trailSpr = precache_model("sprites/laserbeam.spr")
	#endif
}

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	//Ham
	RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
	RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)

	//Forward
	register_forward(FM_SetModel, "fw_SetModel")

	//Event
	register_event("DeathMsg", "DeathMsg", "a")

	#if defined GRENADE_ICON
	register_event("CurWeapon", "grenade_icon", "be", "1=1")
	#endif

	//Extra Item
	g_itemid = zp_register_extra_item(ITEM_NAME, ITEM_COST, ZP_TEAM_ZOMBIE)
}

#if defined WEAPONLIST
public hook(id)
{ 
	if(!is_user_connected(id))
		return PLUGIN_CONTINUE
		
	engclient_cmd(id, WEAPON_DEFAULT)
	
	return PLUGIN_HANDLED
}
#endif

public zp_extra_item_selected(id, Item)
{
	if(Item == g_itemid)
	{
		if(g_JumpGrenadeCount[id] >= MAX_GRENADE)
		{
			client_print(id, print_chat, "%s", MAX_GRENADE_MSG)
			return ZP_PLUGIN_HANDLED
		}

		new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
		if(g_JumpGrenadeCount[id] >= 1)
		{
			cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
			emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			g_JumpGrenadeCount[id]++
		}
		else
		{
			fm_give_item(id, WEAPON_DEFAULT)
			client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
			emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			g_JumpGrenadeCount[id] = 1
		}

		AmmoPickup(id)
		#if defined WEAPONLIST
		WeaponList(id, 1)
		#endif
	}
	return PLUGIN_HANDLED
}

public zp_user_infected_post(id, infector, nemesis)
{
	if(zp_get_user_nemesis(id) || zp_is_survivor_round() || zp_is_nemesis_round())
		return

	g_JumpGrenadeCount[id] = 0

	fm_give_item(id, WEAPON_DEFAULT)    
	cs_set_user_bpammo(id, DEFAULT_CSW, 1)
	emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)       

	AmmoPickup(id)

	g_JumpGrenadeCount[id] = 1
	#if defined WEAPONLIST
	WeaponList(id, 1)
	#endif
}

public zp_user_humanized_post(id, survivor)
{
	g_JumpGrenadeCount[id] = 0
	#if defined WEAPONLIST
	WeaponList(id, 0)
	#endif
}

public DeployPost(entity)
{
	static id
	id = get_pdata_cbase(entity, 41, 4)

	if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id))
		return PLUGIN_CONTINUE

	set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
	set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])

	return PLUGIN_CONTINUE
}

public fw_SetModel(Entity, const Model[])
{
	if (Entity < 0)
		return FMRES_IGNORED

	if (pev(Entity, pev_dmgtime) == 0.0)
		return FMRES_IGNORED

	new iOwner = pev(Entity, pev_owner)
 
	if(!zp_get_user_zombie(iOwner))
		return FMRES_IGNORED
	       
	if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
	{
		g_JumpGrenadeCount[iOwner]--

		set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
		set_pev(Entity, pev_body, 23)

		fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)

		#if defined TRAIL
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMFOLLOW)
		write_short(Entity) 		// entity
		write_short(g_trailSpr) 	// sprite
		write_byte(2) 			// life
		write_byte(5) 			// width
		write_byte(0) 			// r
		write_byte(200) 		// g
		write_byte(0) 			// b
		write_byte(200) 		// brightness
		message_end()
		#endif

		engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])

		return FMRES_SUPERCEDE    
	}
	return FMRES_IGNORED
}

public fw_ThinkGrenade(Entity)
{
	if(!pev_valid(Entity))
		return HAM_IGNORED
       
	static Float:dmg_time
	pev(Entity, pev_dmgtime, dmg_time)
       
	if(dmg_time > get_gametime())
		return HAM_IGNORED
       
	if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
	{
		JumpBombExplode(Entity)
		return HAM_SUPERCEDE
	}
	return HAM_IGNORED
}

public JumpBombExplode(Entity)
{
	if(Entity < 0)
		return
       
	static Float:Origin[3]
	pev(Entity, pev_origin, Origin)

	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_SPRITE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
	write_short(g_iExplo)
	write_byte(35)
	write_byte(186)
	message_end()
	       
	emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
      
	for(new victim = 1; victim <= get_maxplayers(); victim++)
	{
		if (!is_user_alive(victim))
			continue
                  
		new Float:VictimOrigin[3]
		pev(victim, pev_origin, VictimOrigin)
		           
		new Float:Distance = get_distance_f(Origin, VictimOrigin)   
		           
		if(Distance <= RADIUS)
		{
			static Float:NewSpeed

			NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
			               
			static Float:Velocity[3]
			get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
			               
			set_pev(victim, pev_velocity, Velocity)
			
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
			write_short(1<<12 * 10)       
			write_short(1<<12 * 10)
			write_short(1<<12 * 10)
			message_end()

			if(zp_get_user_zombie(victim))
				set_user_takedamage(victim, JUMP_DAMAGE)

		}
	}
	engfunc(EngFunc_RemoveEntity, Entity)
}       
#if defined GRENADE_ICON
public grenade_icon(id)
{
	remove_grenade_icon(id)
		
	if(is_user_bot(id))
		return

	static igrenade, grenade_sprite[16], grenade_color[3]
	igrenade = get_user_weapon(id)
	
	switch(igrenade) 
	{
		case DEFAULT_CSW:
		{
			if(!is_user_alive(id) || zp_get_user_zombie(id)) 
			{
				grenade_sprite = "dmg_gas"
				grenade_color = {255, 165, 0} 
			}
			else
			{
				grenade_sprite = ""
				grenade_color = {0, 0, 0} 
			}
		}
		default: return
	}
	grenade_icons[id] = grenade_sprite
	
	message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
	write_byte(1)
	write_string(grenade_icons[id]) 
	write_byte(grenade_color[0])
	write_byte(grenade_color[1])
	write_byte(grenade_color[2]) 
	message_end()

	return
}
#endif
public zp_round_ended() 
{
	for(new id = 1; id <= get_maxplayers(); id++) 
	{
		if(!is_user_alive(id) || !zp_get_user_zombie(id)) 
			continue

		ham_strip_weapon(id, WEAPON_DEFAULT)
		g_JumpGrenadeCount[id] = 0
	}
}

public DeathMsg()
{
	new attacker = read_data(1)
	new victim = read_data(2)

	if(!is_user_connected(attacker))
		return HAM_IGNORED

	if(victim == attacker || !victim)
		return HAM_IGNORED

	if(!zp_get_user_zombie(victim))
		return HAM_IGNORED

	#if defined GRENADE_ICON
	remove_grenade_icon(victim)
	#endif

	#if defined WEAPONLIST
	WeaponList(victim, 0)
	#endif

	g_JumpGrenadeCount[victim] = 0

        return HAM_HANDLED
}

public client_connect(id) g_JumpGrenadeCount[id] = 0

#if defined WEAPONLIST
WeaponList(index, mode = 0)
{
	if (!is_user_connected(index))
		return
	
	message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
	write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
	write_byte(prim_ammoid)
	write_byte(prim_ammomaxamount)
	write_byte(sec_ammoid)
	write_byte(sec_ammomaxamount)
	write_byte(slotid)
	write_byte(number_in_slot)
	write_byte(weaponid)
	write_byte(flags)
	message_end()
}
#endif

#if defined GRENADE_ICON
static remove_grenade_icon(index) 
{
	message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
	write_byte(0) 
	write_string(grenade_icons[index])
	message_end()
}
#endif

stock set_user_takedamage(index, damage)
{
	if(!is_user_alive(index))
		return

	new vec[3]
	FVecIVec(get_target_origin_f(index), vec)

	message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
	write_byte(0)
	write_byte(damage)
	write_long(DMG_CRUSH)
	write_coord(vec[0]) 
	write_coord(vec[1])
	write_coord(vec[2])
	message_end()

	if(pev(index, pev_health) - 20.0 <= 0)
		ExecuteHamB(Ham_Killed, index, index, 1)
	else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
}

stock AmmoPickup(index)
{
	message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
	write_byte(13)
	write_byte(1)
	message_end()
}

stock Float:get_target_origin_f(index)
{
	new Float:orig[3]
	pev(index, pev_origin, orig)

	if(index > get_maxplayers())
	{
		new Float:mins[3], Float:maxs[3]
		pev(index, pev_mins, mins)
		pev(index, pev_maxs, maxs)
		
		if(!mins[2]) orig[2] += maxs[2] / 2
	}
	return orig
}

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 fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) 
{
	new Float:RenderColor[3]
	RenderColor[0] = float(r)
	RenderColor[1] = float(g)
	RenderColor[2] = float(b)

	set_pev(entity, pev_renderfx, fx)
	set_pev(entity, pev_rendercolor, RenderColor)
	set_pev(entity, pev_rendermode, render)
	set_pev(entity, pev_renderamt, float(amount))

	return 1
}

stock fm_give_item(index, const item[])
{
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
		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 ham_strip_weapon(index, weapon[])
{
	if(!equal(weapon, "weapon_", 7))
		return 0

    	new wId = get_weaponid(weapon)
    	if(!wId) return 0

    	new wEnt
    	while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}

    	if(!wEnt) 
		return 0

    	if(get_user_weapon(index) == wId)
		ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)

    	if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
		return 0

    	ExecuteHamB(Ham_Item_Kill, wEnt)

    	set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))

    	return 1
}

CONSUSSION Grenade:

Code: Select all

/*
	[ZP] Extra Item: Concussion Grenade
	Copyright (C) 2009 by NiHiLaNTh

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	
	In addition, as a special exception, the author gives permission to
	link the code of this program with the Half-Life Game Engine ("HL
	Engine") and Modified Game Libraries ("MODs") developed by Valve,
	L.L.C ("Valve"). You must obey the GNU General Public License in all
	respects for all of the code used other than the HL Engine and MODs
	from Valve. If you modify this file, you may extend this exception
	to your version of the file, but you are not obligated to do so. If
	you do not wish to do so, delete this exception statement from your
	version.

	--- Introduction ---
	This plugin adds new weapon to zombie plague - concussion grenade.I took
	this idead from Team Fortress Classic.When grenade explodes it doesn't
	do any damage, but it starts to make hallucinations to players, such as
	screen shake, screen fade, recoil changes.
	
	--- CVARs ---
	zp_conc_nade_radius 500 -- Explosion radius
	zp_conc_nade_duration 7 -- Duration of hallucinations
	
	--- Credits ---
	NiHiLaNTh - Plugin
	dels/Shalun - Grenade model
	MeRcyLeZZ - Some useful code parts
	xPaw / Xellath - Code optimization
	
	--- Changelog ---
	v1.0 - Initial release 
	v1.1 - Optimized code ( Thanks xPaw and Xellath )
	v1.2 - Fixed bug when after explosion player were not affected
	v1.3 - Added p_ and w_ model support
	     - Fixed run-time error
	     - Made some minor improvements ( MeTaLiCroSS )
	v1.4 - Players are able to carry multiple grenades at the same time     
*/

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

// Plugin version
#define VERSION "1.4"

// Defines
#define MAXPLAYERS 	32
#define FCVAR_FLAGS 	( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
#define OFFSET_PLAYER	41
#define OFFSET_ACTIVE	373
#define LINUX_DIFF	5
#define NADE_TYPE_CONC	7000
#define FFADE_IN	0x0000
#define REPEAT		0.2 // Time when next screen fade/shake message is being sent
#define TASK_AFFECT	666
#define ID_AFFECT	( taskid - TASK_AFFECT )
#define OFFSET_FLAMMO	387

// Grenade cost
#define GRENADE_COST	15

// Grenade models
new const grenade_model_p [ ] = "models/p_grenade_conc.mdl"
new const grenade_model [ ] = "models/v_grenade_conc.mdl"
new const grenade_model_w [ ] = "models/w_grenade_conc.mdl"

// Sounds
new const explosion_sound [ ] = "zombie_plague/concgren_blast1.wav"
new const purchase_sound [ ] = "items/gunpickup2.wav"
new const purchase_sound2 [ ] = "items/9mmclip1.wav"

// Cached sprite indexes
new m_iTrail, m_iRing

// Item ID
new g_conc

// Player variables
new g_NadeCount [ MAXPLAYERS+1 ]

// Message ID's
new g_msgScreenFade, g_msgScreenShake, g_msgAmmoPickup

// CVAR pointers
new cvar_nade_radius, cvar_duration

// Precache
public plugin_precache ( )
{
	// Precache grenade models
	precache_model ( grenade_model_p )
	precache_model ( grenade_model )
	precache_model ( grenade_model_w )
	
	// Precache sounds
	precache_sound ( explosion_sound )
	precache_sound ( purchase_sound )
	precache_sound ( purchase_sound2 )
	
	// Precache sprites
	m_iRing = precache_model ( "sprites/shockwave.spr" )
	m_iTrail = precache_model ( "sprites/laserbeam.spr" )
}

// Plugin initialization
public plugin_init ( )
{
	// New plugin
	register_plugin ( "[ZP] Extra Item: Concussion Grenade", VERSION, "NiHiLaNTh" )
	
	// Add cvar to detect servers with this plugin
	register_cvar ( "zp_concgren_version", VERSION, FCVAR_FLAGS )
	
	// New extra item
	g_conc = zp_register_extra_item ( "Concussion Grenade", GRENADE_COST, ZP_TEAM_ZOMBIE )
	
	// Events
	register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
	register_event ( "DeathMsg", "Event_DeathMsg", "a" )
	register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
	
	// Forwards
	register_forward ( FM_SetModel, "fw_SetModel" )
	RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
	register_forward ( FM_CmdStart, "fw_CmdStart" )
	
	// CVARs
	cvar_nade_radius = register_cvar ( "zp_conc_nade_radius", "500" )
	cvar_duration = register_cvar ( "zp_conc_nade_duration", "7" )
	
	// Messages
	g_msgScreenShake = get_user_msgid ( "ScreenShake" )
	g_msgScreenFade = get_user_msgid ( "ScreenFade" )
	g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
}

// Someone decided to buy our an extra item
public zp_extra_item_selected ( Player, Item )
{
	// This is our grenade
	if ( Item == g_conc )
	{
		// Player already have it
		if ( g_NadeCount [ Player ] >= 1 )
		{
			// Increase nade count
			g_NadeCount [ Player ]++
			
			// Increase bp ammo
			set_pdata_int ( Player, OFFSET_FLAMMO, get_pdata_int ( Player, OFFSET_FLAMMO, LINUX_DIFF )+1, LINUX_DIFF )
			
			// Ammo pickup
			message_begin ( MSG_ONE, g_msgAmmoPickup, _, Player )
			write_byte ( 11 ) // Ammo ID
			write_byte ( 1 ) // Ammo amount
			message_end ( )
			
			// Emit sound
			emit_sound ( Player, CHAN_WEAPON, purchase_sound2, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
		}
		else // 0 grenades
		{
			// Increase nade count
			g_NadeCount [ Player ] = 1
			
			// Give him flashbang
			give_item ( Player, "weapon_flashbang" )
			
			// Play purchase sound
			client_cmd ( Player, "spk %s", purchase_sound )	
		}
	}
	return PLUGIN_CONTINUE
}
	
// Someone was infected	
public zp_user_infected_post ( Player, Infector )
{
	// We were affected by concussion grenade
	if ( task_exists ( Player+TASK_AFFECT ) )
		remove_task ( Player+TASK_AFFECT )
}	

// Someone were turned back to human
public zp_user_humanized_post ( Player, Survivor )
{
	// We dont' have nade anymore
	if ( g_NadeCount [ Player ] )
	{
		g_NadeCount [ Player ] = 0
	}
}

// New round started
public Event_NewRound ( )
{
	// Reset nade count
	arrayset ( g_NadeCount, false, 33 )
		
	// And they aren't affected by conc.grenade
	remove_task ( TASK_AFFECT )	
}

// Someone died
public Event_DeathMsg ( )
{
	// Get victim
	new victim = read_data ( 2 )
	
	// Some people had error without this check
	if ( !is_user_connected ( victim ) )
		return 
	
	// Remove hallucinations
	remove_task ( victim+TASK_AFFECT )
		
	// Reset nade count	
	g_NadeCount [ victim ] = 0
}

// Current weapon player is holding
public Event_CurrentWeapon ( Player )
{
	// Dead or not zombie or don't have conc. grenade
	if ( !is_user_alive ( Player ) || !zp_get_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
		return PLUGIN_CONTINUE
	
	// Replace flashbang model with our ones
	set_pev ( Player, pev_viewmodel2, grenade_model )
	set_pev ( Player, pev_weaponmodel2, grenade_model_p )
	
	return PLUGIN_CONTINUE
}

// Set model
public fw_SetModel ( Entity, const Model [ ] )
{
	// Prevent invalid ent messages
	if ( !pev_valid ( Entity ) )
		return FMRES_IGNORED
		
	// Grenade not thrown yet	
	if ( pev ( Entity, pev_dmgtime ) == 0.0 )
		return FMRES_IGNORED
		
	// We are throwing concussion grenade	
	if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
	{
		//Draw trail
		message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
		write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
		write_short ( Entity ) // Entity to follow
		write_short ( m_iTrail ) // Sprite index
		write_byte ( 10 ) // Life
		write_byte ( 10 ) // Line width
		write_byte ( 255 ) // Red amount
		write_byte ( 255 ) // Blue amount
		write_byte ( 0 ) // Blue amount
		write_byte ( 255 ) // Alpha
		message_end ( )
		
		// Set grenade entity
		set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_CONC )
		
		// Decrease nade count
		g_NadeCount [ pev ( Entity, pev_owner ) ]--
		
		// Set world model
		engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
		return FMRES_SUPERCEDE
	}
	return FMRES_IGNORED
}

// Grenade is getting to explode
public fw_ThinkGrenade ( Entity )
{
	// Prevent invalid ent messages
	if ( !pev_valid ( Entity ) )
		return HAM_IGNORED
	
	// Get damage time
	static Float:dmg_time
	pev ( Entity, pev_dmgtime, dmg_time )
	
	// maybe it is time to go off
	if ( dmg_time > get_gametime ( ) )
		return HAM_IGNORED
		
	// Our grenade	
	if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_CONC )
	{
		// Force to explode
		concussion_explode ( Entity )
		return HAM_SUPERCEDE
	}
	return HAM_IGNORED
}

// Command start
public fw_CmdStart ( Player, UC_Handle, Seed )
{
	// Dead, zombie or not affected
	if ( !is_user_alive ( Player ) || zp_get_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
		return FMRES_IGNORED
	
	// Get buttons
	new buttons = get_uc ( UC_Handle, UC_Buttons )
	
	// We are firing
	if ( buttons & IN_ATTACK )
	{
		// We are holding an active weapon
		if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
		{
			// New recoil
			set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
		}
	}
	return FMRES_HANDLED
}
			

// Grenade explode
public concussion_explode ( Entity )
{
	// Invalid entity ?
	if ( !pev_valid ( Entity  ) )
		return
	
	// Get entities origin
	static Float:origin [ 3 ]
	pev ( Entity, pev_origin, origin )
	
	// Draw ring
	UTIL_DrawRing (origin )
	
	// Explosion sound
	emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
	
	// Collisions
	static victim 
	victim = -1
	
	// Find radius
	static Float:radius
	radius = get_pcvar_float ( cvar_nade_radius )
	
	// Find all players in a radius
	while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
	{
		// Dead or zombie
		if ( !is_user_alive ( victim ) || zp_get_user_zombie ( victim ) )
			continue
			
		// Victim isn't affected yet	
		if ( !task_exists ( victim+TASK_AFFECT ) ) 
		{
			// Get duration
			new duration = get_pcvar_num ( cvar_duration )
			
			// Calculate affect times
			new affect_count = floatround ( duration / REPEAT )
			
			// Continiously affect them
			set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
		}
	}
	
	// Remove entity from ground
	engfunc ( EngFunc_RemoveEntity, Entity )
}

// We are going to affect you
public affect_victim ( taskid )
{
	// Dead
	if ( !is_user_alive ( ID_AFFECT ) )
		return
		
	// Make a screen fade
	message_begin ( MSG_ONE_UNRELIABLE, g_msgScreenFade, {0,0,0}, ID_AFFECT )
	write_short ( 1<<13 ) // Duration
	write_short ( 1<<14 ) // Hold Time
	write_short ( FFADE_IN ) // Fade type
	write_byte ( random_num ( 50, 200 ) ) // Red amount
	write_byte ( random_num ( 50, 200 ) ) // Green amount
	write_byte ( random_num ( 50, 200 ) ) // Blue amount
	write_byte ( random_num ( 50, 200 ) ) // Alpha
	message_end ( )
		
	// Make a screen shake
	message_begin ( MSG_ONE_UNRELIABLE, g_msgScreenShake, {0,0,0}, ID_AFFECT )
	write_short ( 0xFFFF ) // Amplitude
	write_short ( 1<<13 ) // Duration
	write_short ( 0xFFFF ) // Frequency
	message_end ( )
	
	// Remove task after all
	remove_task ( ID_AFFECT )
}

// Draw explosion ring ( from zombie_plague40.sma )
stock UTIL_DrawRing ( const Float:origin [ 3 ] )
{
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, origin[0]) // x
	engfunc(EngFunc_WriteCoord, origin[1]) // y
	engfunc(EngFunc_WriteCoord, origin[2]) // z
	engfunc(EngFunc_WriteCoord, origin[0]) // x axis
	engfunc(EngFunc_WriteCoord, origin[1]) // y axis
	engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
	write_short( m_iRing ) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(4) // life
	write_byte(60) // width
	write_byte(0) // noise
	write_byte(200) // red
	write_byte(200) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#2

Post by Night Fury » 5 years ago

Jump Grenade:
  1. /*
  2. - Создание плагинов на закз:
  3.  
  4. - Контакты:
  5. - Vk: http://vk.com/Opo4uMapy
  6. - ICQ: 585552410
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fakemeta >
  11.  
  12. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  13. #define VERSION     "1.0"
  14. #define AUTHOR      "Opo4uMapy"
  15.  
  16. #define VIP_FLAGS "VIP_A"
  17.  
  18. native cs_get_user_bpammo(index, weapon)
  19. native cs_set_user_bpammo(index, weapon, amount)
  20.  
  21. #define JUMPBOMB_ID     55556
  22.  
  23. /////////////////////////////////////Cvars/////////////////////////////////////
  24.  
  25. #define ITEM_NAME       "Jump Grenade"  // Имя айтема
  26. #define ITEM_COST       6       // Стоимость за 1 бомбу
  27. #define MAX_GRENADE         5       // Лимит гранат
  28. #define RADIUS          300.0       // Радиус взрыва
  29. #define JUMP_DAMAGE     20      // Урон
  30. #define JUMP_EXP        500.0       // Сила отдачи от гранаты   
  31.  
  32. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  33.  
  34. #define BUY_GRENADE_MSG     "[ZP] Вы купили гранату джамп"
  35. #define MAX_GRENADE_MSG     "[ZP] Вы купили маскимум гранат"
  36.  
  37. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  38.  
  39. /////////////////////////////////////WeaponList/////////////////////////////////////
  40.  
  41. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  42.  
  43. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  44. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  45.  
  46. #if defined WEAPONLIST
  47. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  48.  
  49. new const WeaponList_Sprite[][] =
  50. {
  51.     "sprites/weapon_zombj1_sisa.txt",
  52.     "sprites/640hud61.spr",
  53.     "sprites/640hud7x.spr"
  54. }
  55.  
  56. enum
  57. {
  58.     prim_ammoid         = 13,
  59.     prim_ammomaxamount  = 1,
  60.     sec_ammoid      = -1,
  61.     sec_ammomaxamount   = -1,
  62.     slotid          = 3,
  63.     number_in_slot      = 3,
  64.     weaponid        = 9,
  65.     flags           = 24
  66. }
  67. #endif
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. // Модели гранаты
  72. new const BOMB_MODEL[][] =
  73. {
  74.     "models/v_zombibomb.mdl",
  75.     "models/p_zombibomb.mdl",
  76.     "models/w_zombibomb.mdl"
  77. }
  78.  
  79. //Звуки покупки
  80. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  81. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  82.    
  83. //Звук взрыва
  84. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  85.  
  86. //Не изменять! Звуки прописаны в модели.
  87. new const frogbomb_sound[][] =
  88. {
  89.     "nst_zombie/zombi_bomb_pull_1.wav",
  90.     "nst_zombie/zombi_bomb_deploy.wav",
  91.     "nst_zombie/zombi_bomb_throw.wav"
  92. }
  93.  
  94. new const frogbomb_sound_idle[][] =
  95. {
  96.     "nst_zombie/zombi_bomb_idle_1.wav",
  97.     "nst_zombie/zombi_bomb_idle_2.wav",
  98.     "nst_zombie/zombi_bomb_idle_3.wav",
  99.     "nst_zombie/zombi_bomb_idle_4.wav"
  100. }
  101. new g_itemid
  102.  
  103. new g_JumpGrenadeCount[33], g_iExplo
  104. #if defined TRAIL
  105. new g_trailSpr
  106. #endif
  107. #if defined GRENADE_ICON
  108. new grenade_icons[33][32]
  109. #endif
  110.  
  111. public plugin_precache()
  112. {
  113.     static i
  114.  
  115.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  116.         precache_model(BOMB_MODEL[i])
  117.  
  118.     for(i = 0; i < sizeof frogbomb_sound; i++)
  119.         precache_sound(frogbomb_sound[i])
  120.  
  121.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  122.         precache_sound(frogbomb_sound_idle[i])
  123.  
  124.     precache_sound(g_SoundGrenadeBuy)
  125.     precache_sound(g_SoundAmmoPurchase)
  126.     precache_sound(g_SoundBombExplode)
  127.  
  128.     #if defined WEAPONLIST
  129.     register_clcmd(WEAPON_NEW, "hook")
  130.  
  131.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  132.         precache_generic(WeaponList_Sprite[i])
  133.  
  134.     #endif
  135.  
  136.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  137.  
  138.     #if defined TRAIL
  139.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  140.     #endif
  141. }
  142.  
  143. public plugin_init()
  144. {
  145.     register_plugin(PLUGIN, VERSION, AUTHOR)
  146.  
  147.     //Ham
  148.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  149.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  150.  
  151.     //Forward
  152.     register_forward(FM_SetModel, "fw_SetModel")
  153.  
  154.     //Event
  155.     register_event("DeathMsg", "DeathMsg", "a")
  156.  
  157.     #if defined GRENADE_ICON
  158.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  159.     #endif
  160.  
  161.     //Extra Item
  162.     g_itemid = ze_register_item(ITEM_NAME, ITEM_COST, MAX_GRENADE)
  163.     ze_set_item_vip(g_itemid, VIP_FLAGS)
  164. }
  165.  
  166. #if defined WEAPONLIST
  167. public hook(id)
  168. {
  169.     if(!is_user_connected(id))
  170.         return PLUGIN_CONTINUE
  171.        
  172.     engclient_cmd(id, WEAPON_DEFAULT)
  173.    
  174.     return PLUGIN_HANDLED
  175. }
  176. #endif
  177.  
  178. public ze_select_item_preo(id, item)
  179. {
  180.     if (item != g_itemid)
  181.         return ZE_ITEM_AVAILABLE
  182.  
  183.     if (!ze_is_user_zombie(id))
  184.         return ZE_ITEM_DONT_SHOW
  185.  
  186.     return ZE_ITEM_AVAILABLE
  187. }
  188.  
  189. public ze_select_item_post(id, Item)
  190. {
  191.     if(Item == g_itemid)
  192.     {
  193.         new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  194.         if(g_JumpGrenadeCount[id] >= 1)
  195.         {
  196.             cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  197.             emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  198.             g_JumpGrenadeCount[id]++
  199.         }
  200.         else
  201.         {
  202.             fm_give_item(id, WEAPON_DEFAULT)
  203.             client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
  204.             emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.             g_JumpGrenadeCount[id] = 1
  206.         }
  207.  
  208.         AmmoPickup(id)
  209.         #if defined WEAPONLIST
  210.         WeaponList(id, 1)
  211.         #endif
  212.     }
  213.     return PLUGIN_HANDLED
  214. }
  215.  
  216. public ze_user_infected(id)
  217. {
  218.     g_JumpGrenadeCount[id] = 0
  219.  
  220.     fm_give_item(id, WEAPON_DEFAULT)    
  221.     cs_set_user_bpammo(id, DEFAULT_CSW, 1)
  222.     emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)      
  223.  
  224.     AmmoPickup(id)
  225.  
  226.     g_JumpGrenadeCount[id] = 1
  227.     #if defined WEAPONLIST
  228.     WeaponList(id, 1)
  229.     #endif
  230. }
  231.  
  232. public ze_user_humanized(id)
  233. {
  234.     g_JumpGrenadeCount[id] = 0
  235.     #if defined WEAPONLIST
  236.     WeaponList(id, 0)
  237.     #endif
  238. }
  239.  
  240. public DeployPost(entity)
  241. {
  242.     static id
  243.     id = get_pdata_cbase(entity, 41, 4)
  244.  
  245.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  246.         return PLUGIN_CONTINUE
  247.  
  248.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  249.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  250.  
  251.     return PLUGIN_CONTINUE
  252. }
  253.  
  254. public fw_SetModel(Entity, const Model[])
  255. {
  256.     if (Entity < 0)
  257.         return FMRES_IGNORED
  258.  
  259.     if (pev(Entity, pev_dmgtime) == 0.0)
  260.         return FMRES_IGNORED
  261.  
  262.     new iOwner = pev(Entity, pev_owner)
  263.  
  264.     if(!ze_is_user_zombie(iOwner))
  265.         return FMRES_IGNORED
  266.            
  267.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  268.     {
  269.         g_JumpGrenadeCount[iOwner]--
  270.  
  271.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  272.         set_pev(Entity, pev_body, 23)
  273.  
  274.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  275.  
  276.         #if defined TRAIL
  277.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  278.         write_byte(TE_BEAMFOLLOW)
  279.         write_short(Entity)         // entity
  280.         write_short(g_trailSpr)     // sprite
  281.         write_byte(2)           // life
  282.         write_byte(5)           // width
  283.         write_byte(0)           // r
  284.         write_byte(200)         // g
  285.         write_byte(0)           // b
  286.         write_byte(200)         // brightness
  287.         message_end()
  288.         #endif
  289.  
  290.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  291.  
  292.         return FMRES_SUPERCEDE    
  293.     }
  294.     return FMRES_IGNORED
  295. }
  296.  
  297. public fw_ThinkGrenade(Entity)
  298. {
  299.     if(!pev_valid(Entity))
  300.         return HAM_IGNORED
  301.        
  302.     static Float:dmg_time
  303.     pev(Entity, pev_dmgtime, dmg_time)
  304.        
  305.     if(dmg_time > get_gametime())
  306.         return HAM_IGNORED
  307.        
  308.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  309.     {
  310.         JumpBombExplode(Entity)
  311.         return HAM_SUPERCEDE
  312.     }
  313.     return HAM_IGNORED
  314. }
  315.  
  316. public JumpBombExplode(Entity)
  317. {
  318.     if(Entity < 0)
  319.         return
  320.        
  321.     static Float:Origin[3]
  322.     pev(Entity, pev_origin, Origin)
  323.  
  324.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  325.     write_byte(TE_SPRITE)
  326.     engfunc(EngFunc_WriteCoord, Origin[0])
  327.     engfunc(EngFunc_WriteCoord, Origin[1])
  328.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  329.     write_short(g_iExplo)
  330.     write_byte(35)
  331.     write_byte(186)
  332.     message_end()
  333.            
  334.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  335.      
  336.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  337.     {
  338.         if (!is_user_alive(victim))
  339.             continue
  340.                  
  341.         new Float:VictimOrigin[3]
  342.         pev(victim, pev_origin, VictimOrigin)
  343.                    
  344.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  345.                    
  346.         if(Distance <= RADIUS)
  347.         {
  348.             static Float:NewSpeed
  349.  
  350.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  351.                            
  352.             static Float:Velocity[3]
  353.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  354.                            
  355.             set_pev(victim, pev_velocity, Velocity)
  356.            
  357.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  358.             write_short(1<<12 * 10)      
  359.             write_short(1<<12 * 10)
  360.             write_short(1<<12 * 10)
  361.             message_end()
  362.  
  363.             if(ze_is_user_zombie(victim))
  364.                 set_user_takedamage(victim, JUMP_DAMAGE)
  365.  
  366.         }
  367.     }
  368.     engfunc(EngFunc_RemoveEntity, Entity)
  369. }      
  370. #if defined GRENADE_ICON
  371. public grenade_icon(id)
  372. {
  373.     remove_grenade_icon(id)
  374.        
  375.     if(is_user_bot(id))
  376.         return
  377.  
  378.     static igrenade, grenade_sprite[16], grenade_color[3]
  379.     igrenade = get_user_weapon(id)
  380.    
  381.     switch(igrenade)
  382.     {
  383.         case DEFAULT_CSW:
  384.         {
  385.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  386.             {
  387.                 grenade_sprite = "dmg_gas"
  388.                 grenade_color = {255, 165, 0}
  389.             }
  390.             else
  391.             {
  392.                 grenade_sprite = ""
  393.                 grenade_color = {0, 0, 0}
  394.             }
  395.         }
  396.         default: return
  397.     }
  398.     grenade_icons[id] = grenade_sprite
  399.    
  400.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  401.     write_byte(1)
  402.     write_string(grenade_icons[id])
  403.     write_byte(grenade_color[0])
  404.     write_byte(grenade_color[1])
  405.     write_byte(grenade_color[2])
  406.     message_end()
  407.  
  408.     return
  409. }
  410. #endif
  411. public ze_roundend()
  412. {
  413.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  414.     {
  415.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  416.             continue
  417.  
  418.         ham_strip_weapon(id, WEAPON_DEFAULT)
  419.         g_JumpGrenadeCount[id] = 0
  420.     }
  421. }
  422.  
  423. public DeathMsg()
  424. {
  425.     new attacker = read_data(1)
  426.     new victim = read_data(2)
  427.  
  428.     if(!is_user_connected(attacker))
  429.         return HAM_IGNORED
  430.  
  431.     if(victim == attacker || !victim)
  432.         return HAM_IGNORED
  433.  
  434.     if(!ze_is_user_zombie(victim))
  435.         return HAM_IGNORED
  436.  
  437.     #if defined GRENADE_ICON
  438.     remove_grenade_icon(victim)
  439.     #endif
  440.  
  441.     #if defined WEAPONLIST
  442.     WeaponList(victim, 0)
  443.     #endif
  444.  
  445.     g_JumpGrenadeCount[victim] = 0
  446.  
  447.         return HAM_HANDLED
  448. }
  449.  
  450. public client_connect(id) g_JumpGrenadeCount[id] = 0
  451.  
  452. #if defined WEAPONLIST
  453. WeaponList(index, mode = 0)
  454. {
  455.     if (!is_user_connected(index))
  456.         return
  457.    
  458.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  459.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  460.     write_byte(prim_ammoid)
  461.     write_byte(prim_ammomaxamount)
  462.     write_byte(sec_ammoid)
  463.     write_byte(sec_ammomaxamount)
  464.     write_byte(slotid)
  465.     write_byte(number_in_slot)
  466.     write_byte(weaponid)
  467.     write_byte(flags)
  468.     message_end()
  469. }
  470. #endif
  471.  
  472. #if defined GRENADE_ICON
  473. static remove_grenade_icon(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  476.     write_byte(0)
  477.     write_string(grenade_icons[index])
  478.     message_end()
  479. }
  480. #endif
  481.  
  482. stock set_user_takedamage(index, damage)
  483. {
  484.     if(!is_user_alive(index))
  485.         return
  486.  
  487.     new vec[3]
  488.     FVecIVec(get_target_origin_f(index), vec)
  489.  
  490.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  491.     write_byte(0)
  492.     write_byte(damage)
  493.     write_long(DMG_CRUSH)
  494.     write_coord(vec[0])
  495.     write_coord(vec[1])
  496.     write_coord(vec[2])
  497.     message_end()
  498.  
  499.     if(pev(index, pev_health) - 20.0 <= 0)
  500.         ExecuteHamB(Ham_Killed, index, index, 1)
  501.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  502. }
  503.  
  504. stock AmmoPickup(index)
  505. {
  506.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  507.     write_byte(13)
  508.     write_byte(1)
  509.     message_end()
  510. }
  511.  
  512. stock Float:get_target_origin_f(index)
  513. {
  514.     new Float:orig[3]
  515.     pev(index, pev_origin, orig)
  516.  
  517.     if(index > get_maxplayers())
  518.     {
  519.         new Float:mins[3], Float:maxs[3]
  520.         pev(index, pev_mins, mins)
  521.         pev(index, pev_maxs, maxs)
  522.        
  523.         if(!mins[2]) orig[2] += maxs[2] / 2
  524.     }
  525.     return orig
  526. }
  527.  
  528. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  529. {
  530.     new_velocity[0] = origin2[0] - origin1[0]
  531.     new_velocity[1] = origin2[1] - origin1[1]
  532.     new_velocity[2] = origin2[2] - origin1[2]
  533.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  534.     new_velocity[0] *= num
  535.     new_velocity[1] *= num
  536.     new_velocity[2] *= num
  537.  
  538.     return 1
  539. }
  540.  
  541. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  542. {
  543.     new Float:RenderColor[3]
  544.     RenderColor[0] = float(r)
  545.     RenderColor[1] = float(g)
  546.     RenderColor[2] = float(b)
  547.  
  548.     set_pev(entity, pev_renderfx, fx)
  549.     set_pev(entity, pev_rendercolor, RenderColor)
  550.     set_pev(entity, pev_rendermode, render)
  551.     set_pev(entity, pev_renderamt, float(amount))
  552.  
  553.     return 1
  554. }
  555.  
  556. stock fm_give_item(index, const item[])
  557. {
  558.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  559.         return 0
  560.  
  561.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  562.     if (!pev_valid(ent))
  563.         return 0
  564.  
  565.     new Float:origin[3]
  566.     pev(index, pev_origin, origin)
  567.     set_pev(ent, pev_origin, origin)
  568.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  569.     dllfunc(DLLFunc_Spawn, ent)
  570.  
  571.     new save = pev(ent, pev_solid)
  572.     dllfunc(DLLFunc_Touch, ent, index)
  573.     if (pev(ent, pev_solid) != save)
  574.         return ent
  575.  
  576.     engfunc(EngFunc_RemoveEntity, ent)
  577.  
  578.     return -1
  579. }
  580.  
  581. stock ham_strip_weapon(index, weapon[])
  582. {
  583.     if(!equal(weapon, "weapon_", 7))
  584.         return 0
  585.  
  586.         new wId = get_weaponid(weapon)
  587.         if(!wId) return 0
  588.  
  589.         new wEnt
  590.         while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  591.  
  592.         if(!wEnt)
  593.         return 0
  594.  
  595.         if(get_user_weapon(index) == wId)
  596.         ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  597.  
  598.         if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  599.         return 0
  600.  
  601.         ExecuteHamB(Ham_Item_Kill, wEnt)
  602.  
  603.         set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  604.  
  605.         return 1
  606. }

Concussion Grenade:
  1. /*
  2.     [ZP] Extra Item: Concussion Grenade
  3.     Copyright (C) 2009 by NiHiLaNTh
  4.  
  5.     This program is free software: you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation, either version 3 of the License, or
  8.     (at your option) any later version.
  9.    
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.    
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.    
  18.     In addition, as a special exception, the author gives permission to
  19.     link the code of this program with the Half-Life Game Engine ("HL
  20.     Engine") and Modified Game Libraries ("MODs") developed by Valve,
  21.     L.L.C ("Valve"). You must obey the GNU General Public License in all
  22.     respects for all of the code used other than the HL Engine and MODs
  23.     from Valve. If you modify this file, you may extend this exception
  24.     to your version of the file, but you are not obligated to do so. If
  25.     you do not wish to do so, delete this exception statement from your
  26.     version.
  27.  
  28.     --- Introduction ---
  29.     This plugin adds new weapon to zombie plague - concussion grenade.I took
  30.     this idead from Team Fortress Classic.When grenade explodes it doesn't
  31.     do any damage, but it starts to make hallucinations to players, such as
  32.     screen shake, screen fade, recoil changes.
  33.    
  34.     --- CVARs ---
  35.     zp_conc_nade_radius 500 -- Explosion radius
  36.     zp_conc_nade_duration 7 -- Duration of hallucinations
  37.    
  38.     --- Credits ---
  39.     NiHiLaNTh - Plugin
  40.     dels/Shalun - Grenade model
  41.     MeRcyLeZZ - Some useful code parts
  42.     xPaw / Xellath - Code optimization
  43.    
  44.     --- Changelog ---
  45.     v1.0 - Initial release
  46.     v1.1 - Optimized code ( Thanks xPaw and Xellath )
  47.     v1.2 - Fixed bug when after explosion player were not affected
  48.     v1.3 - Added p_ and w_ model support
  49.          - Fixed run-time error
  50.          - Made some minor improvements ( MeTaLiCroSS )
  51.     v1.4 - Players are able to carry multiple grenades at the same time    
  52. */
  53.  
  54. #include < zombie_escape >
  55. #include < fakemeta >
  56. #include < fun >
  57.  
  58. #define VIP_FLAG "VIP_A"
  59.  
  60. // Plugin version
  61. #define VERSION "1.4"
  62.  
  63. // Defines
  64. #define MAXPLAYERS  32
  65. #define FCVAR_FLAGS     ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
  66. #define OFFSET_PLAYER   41
  67. #define OFFSET_ACTIVE   373
  68. #define LINUX_DIFF  5
  69. #define NADE_TYPE_CONC  7000
  70. #define FFADE_IN    0x0000
  71. #define REPEAT      0.2 // Time when next screen fade/shake message is being sent
  72. #define TASK_AFFECT 666
  73. #define ID_AFFECT   ( taskid - TASK_AFFECT )
  74. #define OFFSET_FLAMMO   387
  75.  
  76. // Grenade cost
  77. #define GRENADE_COST    15
  78.  
  79. // Grenade models
  80. new const grenade_model_p [ ] = "models/p_grenade_conc.mdl"
  81. new const grenade_model [ ] = "models/v_grenade_conc.mdl"
  82. new const grenade_model_w [ ] = "models/w_grenade_conc.mdl"
  83.  
  84. // Sounds
  85. new const explosion_sound [ ] = "zombie_plague/concgren_blast1.wav"
  86. new const purchase_sound [ ] = "items/gunpickup2.wav"
  87. new const purchase_sound2 [ ] = "items/9mmclip1.wav"
  88.  
  89. // Cached sprite indexes
  90. new m_iTrail, m_iRing
  91.  
  92. // Item ID
  93. new g_conc
  94.  
  95. // Player variables
  96. new g_NadeCount [ MAXPLAYERS+1 ]
  97.  
  98. // Message ID's
  99. new g_msgScreenFade, g_msgScreenShake, g_msgAmmoPickup
  100.  
  101. // CVAR pointers
  102. new cvar_nade_radius, cvar_duration
  103.  
  104. // Precache
  105. public plugin_precache ( )
  106. {
  107.     // Precache grenade models
  108.     precache_model ( grenade_model_p )
  109.     precache_model ( grenade_model )
  110.     precache_model ( grenade_model_w )
  111.    
  112.     // Precache sounds
  113.     precache_sound ( explosion_sound )
  114.     precache_sound ( purchase_sound )
  115.     precache_sound ( purchase_sound2 )
  116.    
  117.     // Precache sprites
  118.     m_iRing = precache_model ( "sprites/shockwave.spr" )
  119.     m_iTrail = precache_model ( "sprites/laserbeam.spr" )
  120. }
  121.  
  122. // Plugin initialization
  123. public plugin_init ( )
  124. {
  125.     // New plugin
  126.     register_plugin ( "[ZP] Extra Item: Concussion Grenade", VERSION, "NiHiLaNTh" )
  127.    
  128.     // Add cvar to detect servers with this plugin
  129.     register_cvar ( "zp_concgren_version", VERSION, FCVAR_FLAGS )
  130.    
  131.     // New extra item
  132.     g_conc = ze_register_item ( "Concussion Grenade", GRENADE_COST, 0)
  133.     ze_set_item_vip(g_conc, VIP_FLAG)
  134.    
  135.     // Events
  136.     register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
  137.     register_event ( "DeathMsg", "Event_DeathMsg", "a" )
  138.     register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
  139.    
  140.     // Forwards
  141.     register_forward ( FM_SetModel, "fw_SetModel" )
  142.     RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
  143.     register_forward ( FM_CmdStart, "fw_CmdStart" )
  144.    
  145.     // CVARs
  146.     cvar_nade_radius = register_cvar ( "zp_conc_nade_radius", "500" )
  147.     cvar_duration = register_cvar ( "zp_conc_nade_duration", "7" )
  148.    
  149.     // Messages
  150.     g_msgScreenShake = get_user_msgid ( "ScreenShake" )
  151.     g_msgScreenFade = get_user_msgid ( "ScreenFade" )
  152.     g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
  153. }
  154.  
  155. public ze_select_item_pre(id, item)
  156. {
  157.     if (item != g_conc)
  158.         return ZE_ITEM_AVAILABLE
  159.  
  160.     if (!ze_is_user_zombie(id))
  161.         return ZE_ITEM_DONT_SHOW
  162.  
  163.     return ZE_ITEM_AVAILABLE
  164. }
  165.  
  166. // Someone decided to buy our an extra item
  167. public ze_select_item_post( Player, Item )
  168. {
  169.     // This is our grenade
  170.     if ( Item == g_conc )
  171.     {
  172.         // Player already have it
  173.         if ( g_NadeCount [ Player ] >= 1 )
  174.         {
  175.             // Increase nade count
  176.             g_NadeCount [ Player ]++
  177.            
  178.             // Increase bp ammo
  179.             set_pdata_int ( Player, OFFSET_FLAMMO, get_pdata_int ( Player, OFFSET_FLAMMO, LINUX_DIFF )+1, LINUX_DIFF )
  180.            
  181.             // Ammo pickup
  182.             message_begin ( MSG_ONE, g_msgAmmoPickup, _, Player )
  183.             write_byte ( 11 ) // Ammo ID
  184.             write_byte ( 1 ) // Ammo amount
  185.             message_end ( )
  186.            
  187.             // Emit sound
  188.             emit_sound ( Player, CHAN_WEAPON, purchase_sound2, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  189.         }
  190.         else // 0 grenades
  191.         {
  192.             // Increase nade count
  193.             g_NadeCount [ Player ] = 1
  194.            
  195.             // Give him flashbang
  196.             give_item ( Player, "weapon_flashbang" )
  197.            
  198.             // Play purchase sound
  199.             client_cmd ( Player, "spk %s", purchase_sound )
  200.         }
  201.     }
  202.     return PLUGIN_CONTINUE
  203. }
  204.    
  205. // Someone was infected
  206. public ze_user_infected( Player )
  207. {
  208.     // We were affected by concussion grenade
  209.     if ( task_exists ( Player+TASK_AFFECT ) )
  210.         remove_task ( Player+TASK_AFFECT )
  211. }  
  212.  
  213. // Someone were turned back to human
  214. public ze_user_humanized( Player )
  215. {
  216.     // We dont' have nade anymore
  217.     if ( g_NadeCount [ Player ] )
  218.     {
  219.         g_NadeCount [ Player ] = 0
  220.     }
  221. }
  222.  
  223. // New round started
  224. public Event_NewRound ( )
  225. {
  226.     // Reset nade count
  227.     arrayset ( g_NadeCount, false, 33 )
  228.        
  229.     // And they aren't affected by conc.grenade
  230.     remove_task ( TASK_AFFECT )
  231. }
  232.  
  233. // Someone died
  234. public Event_DeathMsg ( )
  235. {
  236.     // Get victim
  237.     new victim = read_data ( 2 )
  238.    
  239.     // Some people had error without this check
  240.     if ( !is_user_connected ( victim ) )
  241.         return
  242.    
  243.     // Remove hallucinations
  244.     remove_task ( victim+TASK_AFFECT )
  245.        
  246.     // Reset nade count
  247.     g_NadeCount [ victim ] = 0
  248. }
  249.  
  250. // Current weapon player is holding
  251. public Event_CurrentWeapon ( Player )
  252. {
  253.     // Dead or not zombie or don't have conc. grenade
  254.     if ( !is_user_alive ( Player ) || !ze_is_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
  255.         return PLUGIN_CONTINUE
  256.    
  257.     // Replace flashbang model with our ones
  258.     set_pev ( Player, pev_viewmodel2, grenade_model )
  259.     set_pev ( Player, pev_weaponmodel2, grenade_model_p )
  260.    
  261.     return PLUGIN_CONTINUE
  262. }
  263.  
  264. // Set model
  265. public fw_SetModel ( Entity, const Model [ ] )
  266. {
  267.     // Prevent invalid ent messages
  268.     if ( !pev_valid ( Entity ) )
  269.         return FMRES_IGNORED
  270.        
  271.     // Grenade not thrown yet  
  272.     if ( pev ( Entity, pev_dmgtime ) == 0.0 )
  273.         return FMRES_IGNORED
  274.        
  275.     // We are throwing concussion grenade  
  276.     if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
  277.     {
  278.         //Draw trail
  279.         message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
  280.         write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
  281.         write_short ( Entity ) // Entity to follow
  282.         write_short ( m_iTrail ) // Sprite index
  283.         write_byte ( 10 ) // Life
  284.         write_byte ( 10 ) // Line width
  285.         write_byte ( 255 ) // Red amount
  286.         write_byte ( 255 ) // Blue amount
  287.         write_byte ( 0 ) // Blue amount
  288.         write_byte ( 255 ) // Alpha
  289.         message_end ( )
  290.        
  291.         // Set grenade entity
  292.         set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_CONC )
  293.        
  294.         // Decrease nade count
  295.         g_NadeCount [ pev ( Entity, pev_owner ) ]--
  296.        
  297.         // Set world model
  298.         engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
  299.         return FMRES_SUPERCEDE
  300.     }
  301.     return FMRES_IGNORED
  302. }
  303.  
  304. // Grenade is getting to explode
  305. public fw_ThinkGrenade ( Entity )
  306. {
  307.     // Prevent invalid ent messages
  308.     if ( !pev_valid ( Entity ) )
  309.         return HAM_IGNORED
  310.    
  311.     // Get damage time
  312.     static Float:dmg_time
  313.     pev ( Entity, pev_dmgtime, dmg_time )
  314.    
  315.     // maybe it is time to go off
  316.     if ( dmg_time > get_gametime ( ) )
  317.         return HAM_IGNORED
  318.        
  319.     // Our grenade 
  320.     if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_CONC )
  321.     {
  322.         // Force to explode
  323.         concussion_explode ( Entity )
  324.         return HAM_SUPERCEDE
  325.     }
  326.     return HAM_IGNORED
  327. }
  328.  
  329. // Command start
  330. public fw_CmdStart ( Player, UC_Handle, Seed )
  331. {
  332.     // Dead, zombie or not affected
  333.     if ( !is_user_alive ( Player ) || ze_is_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
  334.         return FMRES_IGNORED
  335.    
  336.     // Get buttons
  337.     new buttons = get_uc ( UC_Handle, UC_Buttons )
  338.    
  339.     // We are firing
  340.     if ( buttons & IN_ATTACK )
  341.     {
  342.         // We are holding an active weapon
  343.         if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
  344.         {
  345.             // New recoil
  346.             set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
  347.         }
  348.     }
  349.     return FMRES_HANDLED
  350. }
  351.            
  352.  
  353. // Grenade explode
  354. public concussion_explode ( Entity )
  355. {
  356.     // Invalid entity ?
  357.     if ( !pev_valid ( Entity  ) )
  358.         return
  359.    
  360.     // Get entities origin
  361.     static Float:origin [ 3 ]
  362.     pev ( Entity, pev_origin, origin )
  363.    
  364.     // Draw ring
  365.     UTIL_DrawRing (origin )
  366.    
  367.     // Explosion sound
  368.     emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  369.    
  370.     // Collisions
  371.     static victim
  372.     victim = -1
  373.    
  374.     // Find radius
  375.     static Float:radius
  376.     radius = get_pcvar_float ( cvar_nade_radius )
  377.    
  378.     // Find all players in a radius
  379.     while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
  380.     {
  381.         // Dead or zombie
  382.         if ( !is_user_alive ( victim ) || ze_is_user_zombie ( victim ) )
  383.             continue
  384.            
  385.         // Victim isn't affected yet   
  386.         if ( !task_exists ( victim+TASK_AFFECT ) )
  387.         {
  388.             // Get duration
  389.             new duration = get_pcvar_num ( cvar_duration )
  390.            
  391.             // Calculate affect times
  392.             new affect_count = floatround ( duration / REPEAT )
  393.            
  394.             // Continiously affect them
  395.             set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
  396.         }
  397.     }
  398.    
  399.     // Remove entity from ground
  400.     engfunc ( EngFunc_RemoveEntity, Entity )
  401. }
  402.  
  403. // We are going to affect you
  404. public affect_victim ( taskid )
  405. {
  406.     // Dead
  407.     if ( !is_user_alive ( ID_AFFECT ) )
  408.         return
  409.        
  410.     // Make a screen fade
  411.     message_begin ( MSG_ONE_UNRELIABLE, g_msgScreenFade, {0,0,0}, ID_AFFECT )
  412.     write_short ( 1<<13 ) // Duration
  413.     write_short ( 1<<14 ) // Hold Time
  414.     write_short ( FFADE_IN ) // Fade type
  415.     write_byte ( random_num ( 50, 200 ) ) // Red amount
  416.     write_byte ( random_num ( 50, 200 ) ) // Green amount
  417.     write_byte ( random_num ( 50, 200 ) ) // Blue amount
  418.     write_byte ( random_num ( 50, 200 ) ) // Alpha
  419.     message_end ( )
  420.        
  421.     // Make a screen shake
  422.     message_begin ( MSG_ONE_UNRELIABLE, g_msgScreenShake, {0,0,0}, ID_AFFECT )
  423.     write_short ( 0xFFFF ) // Amplitude
  424.     write_short ( 1<<13 ) // Duration
  425.     write_short ( 0xFFFF ) // Frequency
  426.     message_end ( )
  427.    
  428.     // Remove task after all
  429.     remove_task ( ID_AFFECT )
  430. }
  431.  
  432. // Draw explosion ring ( from zombie_plague40.sma )
  433. stock UTIL_DrawRing ( const Float:origin [ 3 ] )
  434. {
  435.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  436.     write_byte(TE_BEAMCYLINDER) // TE id
  437.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  438.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  439.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  440.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  441.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  442.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  443.     write_short( m_iRing ) // sprite
  444.     write_byte(0) // startframe
  445.     write_byte(0) // framerate
  446.     write_byte(4) // life
  447.     write_byte(60) // width
  448.     write_byte(0) // noise
  449.     write_byte(200) // red
  450.     write_byte(200) // green
  451.     write_byte(200) // blue
  452.     write_byte(200) // brightness
  453.     write_byte(0) // speed
  454.     message_end()
  455. }
  456. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  457. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  458. */
Last edited by Raheem 5 years ago, edited 1 time in total.
Reason: Make Concussion Grenade for zombies only.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#3

Post by czirimbolo » 5 years ago

Can you make it for zombies?? Because now that bomb is in HUMAN MENU. I want it for zombies ;)
Image

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

#4

Post by Raheem » 5 years ago

Edited, check now.
He who fails to plan is planning to fail

shady101852
Member
Member
United States of America
Posts: 27
Joined: 5 years ago
Contact:

#5

Post by shady101852 » 5 years ago

Raheem wrote: 5 years agoEdited, check now.
I tried this and the jump nade shows in the extra items menu when I'm a human, and it lets me buy it also and turns into a frost nade.

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#6

Post by Mark » 5 years ago

shady101852 wrote: 5 years ago
Raheem wrote: 5 years agoEdited, check now.
I tried this and the jump nade shows in the extra items menu when I'm a human, and it lets me buy it also and turns into a frost nade.
  1. /*
  2. - Создание плагинов на закз:
  3.  
  4. - Контакты:
  5. - Vk: http://vk.com/Opo4uMapy
  6. - ICQ: 585552410
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fakemeta >
  11.  
  12. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  13. #define VERSION     "1.0"
  14. #define AUTHOR      "Opo4uMapy"
  15.  
  16. #define VIP_FLAGS "VIP_A"
  17.  
  18. native cs_get_user_bpammo(index, weapon)
  19. native cs_set_user_bpammo(index, weapon, amount)
  20.  
  21. #define JUMPBOMB_ID     55556
  22.  
  23. /////////////////////////////////////Cvars/////////////////////////////////////
  24.  
  25. #define ITEM_NAME       "Jump Grenade"  // Имя айтема
  26. #define ITEM_COST       6       // Стоимость за 1 бомбу
  27. #define MAX_GRENADE         5       // Лимит гранат
  28. #define RADIUS          300.0       // Радиус взрыва
  29. #define JUMP_DAMAGE     20      // Урон
  30. #define JUMP_EXP        500.0       // Сила отдачи от гранаты  
  31.  
  32. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  33.  
  34. #define BUY_GRENADE_MSG     "[ZP] Вы купили гранату джамп"
  35. #define MAX_GRENADE_MSG     "[ZP] Вы купили маскимум гранат"
  36.  
  37. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  38.  
  39. /////////////////////////////////////WeaponList/////////////////////////////////////
  40.  
  41. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  42.  
  43. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  44. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  45.  
  46. #if defined WEAPONLIST
  47. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  48.  
  49. new const WeaponList_Sprite[][] =
  50. {
  51.     "sprites/weapon_zombj1_sisa.txt",
  52.     "sprites/640hud61.spr",
  53.     "sprites/640hud7x.spr"
  54. }
  55.  
  56. enum
  57. {
  58.     prim_ammoid         = 13,
  59.     prim_ammomaxamount  = 1,
  60.     sec_ammoid      = -1,
  61.     sec_ammomaxamount   = -1,
  62.     slotid          = 3,
  63.     number_in_slot      = 3,
  64.     weaponid        = 9,
  65.     flags           = 24
  66. }
  67. #endif
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. // Модели гранаты
  72. new const BOMB_MODEL[][] =
  73. {
  74.     "models/v_zombibomb.mdl",
  75.     "models/p_zombibomb.mdl",
  76.     "models/w_zombibomb.mdl"
  77. }
  78.  
  79. //Звуки покупки
  80. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  81. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  82.    
  83. //Звук взрыва
  84. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  85.  
  86. //Не изменять! Звуки прописаны в модели.
  87. new const frogbomb_sound[][] =
  88. {
  89.     "nst_zombie/zombi_bomb_pull_1.wav",
  90.     "nst_zombie/zombi_bomb_deploy.wav",
  91.     "nst_zombie/zombi_bomb_throw.wav"
  92. }
  93.  
  94. new const frogbomb_sound_idle[][] =
  95. {
  96.     "nst_zombie/zombi_bomb_idle_1.wav",
  97.     "nst_zombie/zombi_bomb_idle_2.wav",
  98.     "nst_zombie/zombi_bomb_idle_3.wav",
  99.     "nst_zombie/zombi_bomb_idle_4.wav"
  100. }
  101. new g_itemid
  102.  
  103. new g_JumpGrenadeCount[33], g_iExplo
  104. #if defined TRAIL
  105. new g_trailSpr
  106. #endif
  107. #if defined GRENADE_ICON
  108. new grenade_icons[33][32]
  109. #endif
  110.  
  111. public plugin_precache()
  112. {
  113.     static i
  114.  
  115.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  116.         precache_model(BOMB_MODEL[i])
  117.  
  118.     for(i = 0; i < sizeof frogbomb_sound; i++)
  119.         precache_sound(frogbomb_sound[i])
  120.  
  121.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  122.         precache_sound(frogbomb_sound_idle[i])
  123.  
  124.     precache_sound(g_SoundGrenadeBuy)
  125.     precache_sound(g_SoundAmmoPurchase)
  126.     precache_sound(g_SoundBombExplode)
  127.  
  128.     #if defined WEAPONLIST
  129.     register_clcmd(WEAPON_NEW, "hook")
  130.  
  131.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  132.         precache_generic(WeaponList_Sprite[i])
  133.  
  134.     #endif
  135.  
  136.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  137.  
  138.     #if defined TRAIL
  139.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  140.     #endif
  141. }
  142.  
  143. public plugin_init()
  144. {
  145.     register_plugin(PLUGIN, VERSION, AUTHOR)
  146.  
  147.     //Ham
  148.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  149.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  150.  
  151.     //Forward
  152.     register_forward(FM_SetModel, "fw_SetModel")
  153.  
  154.     //Event
  155.     register_event("DeathMsg", "DeathMsg", "a")
  156.  
  157.     #if defined GRENADE_ICON
  158.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  159.     #endif
  160.  
  161.     //Extra Item
  162.     g_itemid = ze_register_item(ITEM_NAME, ITEM_COST, MAX_GRENADE)
  163.     ze_set_item_vip(g_itemid, VIP_FLAGS)
  164. }
  165.  
  166. #if defined WEAPONLIST
  167. public hook(id)
  168. {
  169.     if(!is_user_connected(id))
  170.         return PLUGIN_CONTINUE
  171.        
  172.     engclient_cmd(id, WEAPON_DEFAULT)
  173.    
  174.     return PLUGIN_HANDLED
  175. }
  176. #endif
  177.  
  178. public ze_select_item_preo(id, item)
  179. {
  180.     if (item != g_itemid)
  181.         return ZE_ITEM_AVAILABLE
  182.  
  183.     if (ze_is_user_zombie(id))
  184.         return ZE_ITEM_DONT_SHOW
  185.  
  186.     return ZE_ITEM_AVAILABLE
  187. }
  188.  
  189. public ze_select_item_post(id, Item)
  190. {
  191.     if(Item == g_itemid)
  192.     {
  193.         new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  194.         if(g_JumpGrenadeCount[id] >= 1)
  195.         {
  196.             cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  197.             emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  198.             g_JumpGrenadeCount[id]++
  199.         }
  200.         else
  201.         {
  202.             fm_give_item(id, WEAPON_DEFAULT)
  203.             client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
  204.             emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.             g_JumpGrenadeCount[id] = 1
  206.         }
  207.  
  208.         AmmoPickup(id)
  209.         #if defined WEAPONLIST
  210.         WeaponList(id, 1)
  211.         #endif
  212.     }
  213.     return PLUGIN_HANDLED
  214. }
  215.  
  216. public ze_user_infected(id)
  217. {
  218.     g_JumpGrenadeCount[id] = 0
  219.  
  220.     fm_give_item(id, WEAPON_DEFAULT)    
  221.     cs_set_user_bpammo(id, DEFAULT_CSW, 1)
  222.     emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)      
  223.  
  224.     AmmoPickup(id)
  225.  
  226.     g_JumpGrenadeCount[id] = 1
  227.     #if defined WEAPONLIST
  228.     WeaponList(id, 1)
  229.     #endif
  230. }
  231.  
  232. public ze_user_humanized(id)
  233. {
  234.     g_JumpGrenadeCount[id] = 0
  235.     #if defined WEAPONLIST
  236.     WeaponList(id, 0)
  237.     #endif
  238. }
  239.  
  240. public DeployPost(entity)
  241. {
  242.     static id
  243.     id = get_pdata_cbase(entity, 41, 4)
  244.  
  245.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  246.         return PLUGIN_CONTINUE
  247.  
  248.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  249.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  250.  
  251.     return PLUGIN_CONTINUE
  252. }
  253.  
  254. public fw_SetModel(Entity, const Model[])
  255. {
  256.     if (Entity < 0)
  257.         return FMRES_IGNORED
  258.  
  259.     if (pev(Entity, pev_dmgtime) == 0.0)
  260.         return FMRES_IGNORED
  261.  
  262.     new iOwner = pev(Entity, pev_owner)
  263.  
  264.     if(!ze_is_user_zombie(iOwner))
  265.         return FMRES_IGNORED
  266.            
  267.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  268.     {
  269.         g_JumpGrenadeCount[iOwner]--
  270.  
  271.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  272.         set_pev(Entity, pev_body, 23)
  273.  
  274.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  275.  
  276.         #if defined TRAIL
  277.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  278.         write_byte(TE_BEAMFOLLOW)
  279.         write_short(Entity)         // entity
  280.         write_short(g_trailSpr)     // sprite
  281.         write_byte(2)           // life
  282.         write_byte(5)           // width
  283.         write_byte(0)           // r
  284.         write_byte(200)         // g
  285.         write_byte(0)           // b
  286.         write_byte(200)         // brightness
  287.         message_end()
  288.         #endif
  289.  
  290.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  291.  
  292.         return FMRES_SUPERCEDE    
  293.     }
  294.     return FMRES_IGNORED
  295. }
  296.  
  297. public fw_ThinkGrenade(Entity)
  298. {
  299.     if(!pev_valid(Entity))
  300.         return HAM_IGNORED
  301.        
  302.     static Float:dmg_time
  303.     pev(Entity, pev_dmgtime, dmg_time)
  304.        
  305.     if(dmg_time > get_gametime())
  306.         return HAM_IGNORED
  307.        
  308.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  309.     {
  310.         JumpBombExplode(Entity)
  311.         return HAM_SUPERCEDE
  312.     }
  313.     return HAM_IGNORED
  314. }
  315.  
  316. public JumpBombExplode(Entity)
  317. {
  318.     if(Entity < 0)
  319.         return
  320.        
  321.     static Float:Origin[3]
  322.     pev(Entity, pev_origin, Origin)
  323.  
  324.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  325.     write_byte(TE_SPRITE)
  326.     engfunc(EngFunc_WriteCoord, Origin[0])
  327.     engfunc(EngFunc_WriteCoord, Origin[1])
  328.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  329.     write_short(g_iExplo)
  330.     write_byte(35)
  331.     write_byte(186)
  332.     message_end()
  333.            
  334.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  335.      
  336.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  337.     {
  338.         if (!is_user_alive(victim))
  339.             continue
  340.                  
  341.         new Float:VictimOrigin[3]
  342.         pev(victim, pev_origin, VictimOrigin)
  343.                    
  344.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  345.                    
  346.         if(Distance <= RADIUS)
  347.         {
  348.             static Float:NewSpeed
  349.  
  350.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  351.                            
  352.             static Float:Velocity[3]
  353.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  354.                            
  355.             set_pev(victim, pev_velocity, Velocity)
  356.            
  357.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  358.             write_short(1<<12 * 10)      
  359.             write_short(1<<12 * 10)
  360.             write_short(1<<12 * 10)
  361.             message_end()
  362.  
  363.             if(ze_is_user_zombie(victim))
  364.                 set_user_takedamage(victim, JUMP_DAMAGE)
  365.  
  366.         }
  367.     }
  368.     engfunc(EngFunc_RemoveEntity, Entity)
  369. }      
  370. #if defined GRENADE_ICON
  371. public grenade_icon(id)
  372. {
  373.     remove_grenade_icon(id)
  374.        
  375.     if(is_user_bot(id))
  376.         return
  377.  
  378.     static igrenade, grenade_sprite[16], grenade_color[3]
  379.     igrenade = get_user_weapon(id)
  380.    
  381.     switch(igrenade)
  382.     {
  383.         case DEFAULT_CSW:
  384.         {
  385.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  386.             {
  387.                 grenade_sprite = "dmg_gas"
  388.                 grenade_color = {255, 165, 0}
  389.             }
  390.             else
  391.             {
  392.                 grenade_sprite = ""
  393.                 grenade_color = {0, 0, 0}
  394.             }
  395.         }
  396.         default: return
  397.     }
  398.     grenade_icons[id] = grenade_sprite
  399.    
  400.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  401.     write_byte(1)
  402.     write_string(grenade_icons[id])
  403.     write_byte(grenade_color[0])
  404.     write_byte(grenade_color[1])
  405.     write_byte(grenade_color[2])
  406.     message_end()
  407.  
  408.     return
  409. }
  410. #endif
  411. public ze_roundend()
  412. {
  413.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  414.     {
  415.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  416.             continue
  417.  
  418.         ham_strip_weapon(id, WEAPON_DEFAULT)
  419.         g_JumpGrenadeCount[id] = 0
  420.     }
  421. }
  422.  
  423. public DeathMsg()
  424. {
  425.     new attacker = read_data(1)
  426.     new victim = read_data(2)
  427.  
  428.     if(!is_user_connected(attacker))
  429.         return HAM_IGNORED
  430.  
  431.     if(victim == attacker || !victim)
  432.         return HAM_IGNORED
  433.  
  434.     if(!ze_is_user_zombie(victim))
  435.         return HAM_IGNORED
  436.  
  437.     #if defined GRENADE_ICON
  438.     remove_grenade_icon(victim)
  439.     #endif
  440.  
  441.     #if defined WEAPONLIST
  442.     WeaponList(victim, 0)
  443.     #endif
  444.  
  445.     g_JumpGrenadeCount[victim] = 0
  446.  
  447.         return HAM_HANDLED
  448. }
  449.  
  450. public client_connect(id) g_JumpGrenadeCount[id] = 0
  451.  
  452. #if defined WEAPONLIST
  453. WeaponList(index, mode = 0)
  454. {
  455.     if (!is_user_connected(index))
  456.         return
  457.    
  458.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  459.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  460.     write_byte(prim_ammoid)
  461.     write_byte(prim_ammomaxamount)
  462.     write_byte(sec_ammoid)
  463.     write_byte(sec_ammomaxamount)
  464.     write_byte(slotid)
  465.     write_byte(number_in_slot)
  466.     write_byte(weaponid)
  467.     write_byte(flags)
  468.     message_end()
  469. }
  470. #endif
  471.  
  472. #if defined GRENADE_ICON
  473. static remove_grenade_icon(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  476.     write_byte(0)
  477.     write_string(grenade_icons[index])
  478.     message_end()
  479. }
  480. #endif
  481.  
  482. stock set_user_takedamage(index, damage)
  483. {
  484.     if(!is_user_alive(index))
  485.         return
  486.  
  487.     new vec[3]
  488.     FVecIVec(get_target_origin_f(index), vec)
  489.  
  490.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  491.     write_byte(0)
  492.     write_byte(damage)
  493.     write_long(DMG_CRUSH)
  494.     write_coord(vec[0])
  495.     write_coord(vec[1])
  496.     write_coord(vec[2])
  497.     message_end()
  498.  
  499.     if(pev(index, pev_health) - 20.0 <= 0)
  500.         ExecuteHamB(Ham_Killed, index, index, 1)
  501.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  502. }
  503.  
  504. stock AmmoPickup(index)
  505. {
  506.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  507.     write_byte(13)
  508.     write_byte(1)
  509.     message_end()
  510. }
  511.  
  512. stock Float:get_target_origin_f(index)
  513. {
  514.     new Float:orig[3]
  515.     pev(index, pev_origin, orig)
  516.  
  517.     if(index > get_maxplayers())
  518.     {
  519.         new Float:mins[3], Float:maxs[3]
  520.         pev(index, pev_mins, mins)
  521.         pev(index, pev_maxs, maxs)
  522.        
  523.         if(!mins[2]) orig[2] += maxs[2] / 2
  524.     }
  525.     return orig
  526. }
  527.  
  528. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  529. {
  530.     new_velocity[0] = origin2[0] - origin1[0]
  531.     new_velocity[1] = origin2[1] - origin1[1]
  532.     new_velocity[2] = origin2[2] - origin1[2]
  533.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  534.     new_velocity[0] *= num
  535.     new_velocity[1] *= num
  536.     new_velocity[2] *= num
  537.  
  538.     return 1
  539. }
  540.  
  541. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  542. {
  543.     new Float:RenderColor[3]
  544.     RenderColor[0] = float(r)
  545.     RenderColor[1] = float(g)
  546.     RenderColor[2] = float(b)
  547.  
  548.     set_pev(entity, pev_renderfx, fx)
  549.     set_pev(entity, pev_rendercolor, RenderColor)
  550.     set_pev(entity, pev_rendermode, render)
  551.     set_pev(entity, pev_renderamt, float(amount))
  552.  
  553.     return 1
  554. }
  555.  
  556. stock fm_give_item(index, const item[])
  557. {
  558.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  559.         return 0
  560.  
  561.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  562.     if (!pev_valid(ent))
  563.         return 0
  564.  
  565.     new Float:origin[3]
  566.     pev(index, pev_origin, origin)
  567.     set_pev(ent, pev_origin, origin)
  568.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  569.     dllfunc(DLLFunc_Spawn, ent)
  570.  
  571.     new save = pev(ent, pev_solid)
  572.     dllfunc(DLLFunc_Touch, ent, index)
  573.     if (pev(ent, pev_solid) != save)
  574.         return ent
  575.  
  576.     engfunc(EngFunc_RemoveEntity, ent)
  577.  
  578.     return -1
  579. }
  580.  
  581. stock ham_strip_weapon(index, weapon[])
  582. {
  583.     if(!equal(weapon, "weapon_", 7))
  584.         return 0
  585.  
  586.         new wId = get_weaponid(weapon)
  587.         if(!wId) return 0
  588.  
  589.         new wEnt
  590.         while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  591.  
  592.         if(!wEnt)
  593.         return 0
  594.  
  595.         if(get_user_weapon(index) == wId)
  596.         ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  597.  
  598.         if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  599.         return 0
  600.  
  601.         ExecuteHamB(Ham_Item_Kill, wEnt)
  602.  
  603.         set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  604.  
  605.         return 1
  606. }

shady101852
Member
Member
United States of America
Posts: 27
Joined: 5 years ago
Contact:

#7

Post by shady101852 » 5 years ago

Mark wrote: 5 years ago
shady101852 wrote: 5 years ago
Raheem wrote: 5 years agoEdited, check now.
I tried this and the jump nade shows in the extra items menu when I'm a human, and it lets me buy it also and turns into a frost nade.
  1. /*
  2. - Создание плагинов на закз:
  3.  
  4. - Контакты:
  5. - Vk: http://vk.com/Opo4uMapy
  6. - ICQ: 585552410
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fakemeta >
  11.  
  12. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  13. #define VERSION     "1.0"
  14. #define AUTHOR      "Opo4uMapy"
  15.  
  16. #define VIP_FLAGS "VIP_A"
  17.  
  18. native cs_get_user_bpammo(index, weapon)
  19. native cs_set_user_bpammo(index, weapon, amount)
  20.  
  21. #define JUMPBOMB_ID     55556
  22.  
  23. /////////////////////////////////////Cvars/////////////////////////////////////
  24.  
  25. #define ITEM_NAME       "Jump Grenade"  // Имя айтема
  26. #define ITEM_COST       6       // Стоимость за 1 бомбу
  27. #define MAX_GRENADE         5       // Лимит гранат
  28. #define RADIUS          300.0       // Радиус взрыва
  29. #define JUMP_DAMAGE     20      // Урон
  30. #define JUMP_EXP        500.0       // Сила отдачи от гранаты  
  31.  
  32. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  33.  
  34. #define BUY_GRENADE_MSG     "[ZP] Вы купили гранату джамп"
  35. #define MAX_GRENADE_MSG     "[ZP] Вы купили маскимум гранат"
  36.  
  37. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  38.  
  39. /////////////////////////////////////WeaponList/////////////////////////////////////
  40.  
  41. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  42.  
  43. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  44. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  45.  
  46. #if defined WEAPONLIST
  47. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  48.  
  49. new const WeaponList_Sprite[][] =
  50. {
  51.     "sprites/weapon_zombj1_sisa.txt",
  52.     "sprites/640hud61.spr",
  53.     "sprites/640hud7x.spr"
  54. }
  55.  
  56. enum
  57. {
  58.     prim_ammoid         = 13,
  59.     prim_ammomaxamount  = 1,
  60.     sec_ammoid      = -1,
  61.     sec_ammomaxamount   = -1,
  62.     slotid          = 3,
  63.     number_in_slot      = 3,
  64.     weaponid        = 9,
  65.     flags           = 24
  66. }
  67. #endif
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. // Модели гранаты
  72. new const BOMB_MODEL[][] =
  73. {
  74.     "models/v_zombibomb.mdl",
  75.     "models/p_zombibomb.mdl",
  76.     "models/w_zombibomb.mdl"
  77. }
  78.  
  79. //Звуки покупки
  80. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  81. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  82.    
  83. //Звук взрыва
  84. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  85.  
  86. //Не изменять! Звуки прописаны в модели.
  87. new const frogbomb_sound[][] =
  88. {
  89.     "nst_zombie/zombi_bomb_pull_1.wav",
  90.     "nst_zombie/zombi_bomb_deploy.wav",
  91.     "nst_zombie/zombi_bomb_throw.wav"
  92. }
  93.  
  94. new const frogbomb_sound_idle[][] =
  95. {
  96.     "nst_zombie/zombi_bomb_idle_1.wav",
  97.     "nst_zombie/zombi_bomb_idle_2.wav",
  98.     "nst_zombie/zombi_bomb_idle_3.wav",
  99.     "nst_zombie/zombi_bomb_idle_4.wav"
  100. }
  101. new g_itemid
  102.  
  103. new g_JumpGrenadeCount[33], g_iExplo
  104. #if defined TRAIL
  105. new g_trailSpr
  106. #endif
  107. #if defined GRENADE_ICON
  108. new grenade_icons[33][32]
  109. #endif
  110.  
  111. public plugin_precache()
  112. {
  113.     static i
  114.  
  115.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  116.         precache_model(BOMB_MODEL[i])
  117.  
  118.     for(i = 0; i < sizeof frogbomb_sound; i++)
  119.         precache_sound(frogbomb_sound[i])
  120.  
  121.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  122.         precache_sound(frogbomb_sound_idle[i])
  123.  
  124.     precache_sound(g_SoundGrenadeBuy)
  125.     precache_sound(g_SoundAmmoPurchase)
  126.     precache_sound(g_SoundBombExplode)
  127.  
  128.     #if defined WEAPONLIST
  129.     register_clcmd(WEAPON_NEW, "hook")
  130.  
  131.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  132.         precache_generic(WeaponList_Sprite[i])
  133.  
  134.     #endif
  135.  
  136.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  137.  
  138.     #if defined TRAIL
  139.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  140.     #endif
  141. }
  142.  
  143. public plugin_init()
  144. {
  145.     register_plugin(PLUGIN, VERSION, AUTHOR)
  146.  
  147.     //Ham
  148.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  149.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  150.  
  151.     //Forward
  152.     register_forward(FM_SetModel, "fw_SetModel")
  153.  
  154.     //Event
  155.     register_event("DeathMsg", "DeathMsg", "a")
  156.  
  157.     #if defined GRENADE_ICON
  158.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  159.     #endif
  160.  
  161.     //Extra Item
  162.     g_itemid = ze_register_item(ITEM_NAME, ITEM_COST, MAX_GRENADE)
  163.     ze_set_item_vip(g_itemid, VIP_FLAGS)
  164. }
  165.  
  166. #if defined WEAPONLIST
  167. public hook(id)
  168. {
  169.     if(!is_user_connected(id))
  170.         return PLUGIN_CONTINUE
  171.        
  172.     engclient_cmd(id, WEAPON_DEFAULT)
  173.    
  174.     return PLUGIN_HANDLED
  175. }
  176. #endif
  177.  
  178. public ze_select_item_preo(id, item)
  179. {
  180.     if (item != g_itemid)
  181.         return ZE_ITEM_AVAILABLE
  182.  
  183.     if (ze_is_user_zombie(id))
  184.         return ZE_ITEM_DONT_SHOW
  185.  
  186.     return ZE_ITEM_AVAILABLE
  187. }
  188.  
  189. public ze_select_item_post(id, Item)
  190. {
  191.     if(Item == g_itemid)
  192.     {
  193.         new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  194.         if(g_JumpGrenadeCount[id] >= 1)
  195.         {
  196.             cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  197.             emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  198.             g_JumpGrenadeCount[id]++
  199.         }
  200.         else
  201.         {
  202.             fm_give_item(id, WEAPON_DEFAULT)
  203.             client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
  204.             emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.             g_JumpGrenadeCount[id] = 1
  206.         }
  207.  
  208.         AmmoPickup(id)
  209.         #if defined WEAPONLIST
  210.         WeaponList(id, 1)
  211.         #endif
  212.     }
  213.     return PLUGIN_HANDLED
  214. }
  215.  
  216. public ze_user_infected(id)
  217. {
  218.     g_JumpGrenadeCount[id] = 0
  219.  
  220.     fm_give_item(id, WEAPON_DEFAULT)    
  221.     cs_set_user_bpammo(id, DEFAULT_CSW, 1)
  222.     emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)      
  223.  
  224.     AmmoPickup(id)
  225.  
  226.     g_JumpGrenadeCount[id] = 1
  227.     #if defined WEAPONLIST
  228.     WeaponList(id, 1)
  229.     #endif
  230. }
  231.  
  232. public ze_user_humanized(id)
  233. {
  234.     g_JumpGrenadeCount[id] = 0
  235.     #if defined WEAPONLIST
  236.     WeaponList(id, 0)
  237.     #endif
  238. }
  239.  
  240. public DeployPost(entity)
  241. {
  242.     static id
  243.     id = get_pdata_cbase(entity, 41, 4)
  244.  
  245.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  246.         return PLUGIN_CONTINUE
  247.  
  248.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  249.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  250.  
  251.     return PLUGIN_CONTINUE
  252. }
  253.  
  254. public fw_SetModel(Entity, const Model[])
  255. {
  256.     if (Entity < 0)
  257.         return FMRES_IGNORED
  258.  
  259.     if (pev(Entity, pev_dmgtime) == 0.0)
  260.         return FMRES_IGNORED
  261.  
  262.     new iOwner = pev(Entity, pev_owner)
  263.  
  264.     if(!ze_is_user_zombie(iOwner))
  265.         return FMRES_IGNORED
  266.            
  267.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  268.     {
  269.         g_JumpGrenadeCount[iOwner]--
  270.  
  271.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  272.         set_pev(Entity, pev_body, 23)
  273.  
  274.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  275.  
  276.         #if defined TRAIL
  277.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  278.         write_byte(TE_BEAMFOLLOW)
  279.         write_short(Entity)         // entity
  280.         write_short(g_trailSpr)     // sprite
  281.         write_byte(2)           // life
  282.         write_byte(5)           // width
  283.         write_byte(0)           // r
  284.         write_byte(200)         // g
  285.         write_byte(0)           // b
  286.         write_byte(200)         // brightness
  287.         message_end()
  288.         #endif
  289.  
  290.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  291.  
  292.         return FMRES_SUPERCEDE    
  293.     }
  294.     return FMRES_IGNORED
  295. }
  296.  
  297. public fw_ThinkGrenade(Entity)
  298. {
  299.     if(!pev_valid(Entity))
  300.         return HAM_IGNORED
  301.        
  302.     static Float:dmg_time
  303.     pev(Entity, pev_dmgtime, dmg_time)
  304.        
  305.     if(dmg_time > get_gametime())
  306.         return HAM_IGNORED
  307.        
  308.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  309.     {
  310.         JumpBombExplode(Entity)
  311.         return HAM_SUPERCEDE
  312.     }
  313.     return HAM_IGNORED
  314. }
  315.  
  316. public JumpBombExplode(Entity)
  317. {
  318.     if(Entity < 0)
  319.         return
  320.        
  321.     static Float:Origin[3]
  322.     pev(Entity, pev_origin, Origin)
  323.  
  324.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  325.     write_byte(TE_SPRITE)
  326.     engfunc(EngFunc_WriteCoord, Origin[0])
  327.     engfunc(EngFunc_WriteCoord, Origin[1])
  328.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  329.     write_short(g_iExplo)
  330.     write_byte(35)
  331.     write_byte(186)
  332.     message_end()
  333.            
  334.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  335.      
  336.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  337.     {
  338.         if (!is_user_alive(victim))
  339.             continue
  340.                  
  341.         new Float:VictimOrigin[3]
  342.         pev(victim, pev_origin, VictimOrigin)
  343.                    
  344.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  345.                    
  346.         if(Distance <= RADIUS)
  347.         {
  348.             static Float:NewSpeed
  349.  
  350.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  351.                            
  352.             static Float:Velocity[3]
  353.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  354.                            
  355.             set_pev(victim, pev_velocity, Velocity)
  356.            
  357.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  358.             write_short(1<<12 * 10)      
  359.             write_short(1<<12 * 10)
  360.             write_short(1<<12 * 10)
  361.             message_end()
  362.  
  363.             if(ze_is_user_zombie(victim))
  364.                 set_user_takedamage(victim, JUMP_DAMAGE)
  365.  
  366.         }
  367.     }
  368.     engfunc(EngFunc_RemoveEntity, Entity)
  369. }      
  370. #if defined GRENADE_ICON
  371. public grenade_icon(id)
  372. {
  373.     remove_grenade_icon(id)
  374.        
  375.     if(is_user_bot(id))
  376.         return
  377.  
  378.     static igrenade, grenade_sprite[16], grenade_color[3]
  379.     igrenade = get_user_weapon(id)
  380.    
  381.     switch(igrenade)
  382.     {
  383.         case DEFAULT_CSW:
  384.         {
  385.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  386.             {
  387.                 grenade_sprite = "dmg_gas"
  388.                 grenade_color = {255, 165, 0}
  389.             }
  390.             else
  391.             {
  392.                 grenade_sprite = ""
  393.                 grenade_color = {0, 0, 0}
  394.             }
  395.         }
  396.         default: return
  397.     }
  398.     grenade_icons[id] = grenade_sprite
  399.    
  400.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  401.     write_byte(1)
  402.     write_string(grenade_icons[id])
  403.     write_byte(grenade_color[0])
  404.     write_byte(grenade_color[1])
  405.     write_byte(grenade_color[2])
  406.     message_end()
  407.  
  408.     return
  409. }
  410. #endif
  411. public ze_roundend()
  412. {
  413.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  414.     {
  415.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  416.             continue
  417.  
  418.         ham_strip_weapon(id, WEAPON_DEFAULT)
  419.         g_JumpGrenadeCount[id] = 0
  420.     }
  421. }
  422.  
  423. public DeathMsg()
  424. {
  425.     new attacker = read_data(1)
  426.     new victim = read_data(2)
  427.  
  428.     if(!is_user_connected(attacker))
  429.         return HAM_IGNORED
  430.  
  431.     if(victim == attacker || !victim)
  432.         return HAM_IGNORED
  433.  
  434.     if(!ze_is_user_zombie(victim))
  435.         return HAM_IGNORED
  436.  
  437.     #if defined GRENADE_ICON
  438.     remove_grenade_icon(victim)
  439.     #endif
  440.  
  441.     #if defined WEAPONLIST
  442.     WeaponList(victim, 0)
  443.     #endif
  444.  
  445.     g_JumpGrenadeCount[victim] = 0
  446.  
  447.         return HAM_HANDLED
  448. }
  449.  
  450. public client_connect(id) g_JumpGrenadeCount[id] = 0
  451.  
  452. #if defined WEAPONLIST
  453. WeaponList(index, mode = 0)
  454. {
  455.     if (!is_user_connected(index))
  456.         return
  457.    
  458.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  459.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  460.     write_byte(prim_ammoid)
  461.     write_byte(prim_ammomaxamount)
  462.     write_byte(sec_ammoid)
  463.     write_byte(sec_ammomaxamount)
  464.     write_byte(slotid)
  465.     write_byte(number_in_slot)
  466.     write_byte(weaponid)
  467.     write_byte(flags)
  468.     message_end()
  469. }
  470. #endif
  471.  
  472. #if defined GRENADE_ICON
  473. static remove_grenade_icon(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  476.     write_byte(0)
  477.     write_string(grenade_icons[index])
  478.     message_end()
  479. }
  480. #endif
  481.  
  482. stock set_user_takedamage(index, damage)
  483. {
  484.     if(!is_user_alive(index))
  485.         return
  486.  
  487.     new vec[3]
  488.     FVecIVec(get_target_origin_f(index), vec)
  489.  
  490.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  491.     write_byte(0)
  492.     write_byte(damage)
  493.     write_long(DMG_CRUSH)
  494.     write_coord(vec[0])
  495.     write_coord(vec[1])
  496.     write_coord(vec[2])
  497.     message_end()
  498.  
  499.     if(pev(index, pev_health) - 20.0 <= 0)
  500.         ExecuteHamB(Ham_Killed, index, index, 1)
  501.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  502. }
  503.  
  504. stock AmmoPickup(index)
  505. {
  506.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  507.     write_byte(13)
  508.     write_byte(1)
  509.     message_end()
  510. }
  511.  
  512. stock Float:get_target_origin_f(index)
  513. {
  514.     new Float:orig[3]
  515.     pev(index, pev_origin, orig)
  516.  
  517.     if(index > get_maxplayers())
  518.     {
  519.         new Float:mins[3], Float:maxs[3]
  520.         pev(index, pev_mins, mins)
  521.         pev(index, pev_maxs, maxs)
  522.        
  523.         if(!mins[2]) orig[2] += maxs[2] / 2
  524.     }
  525.     return orig
  526. }
  527.  
  528. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  529. {
  530.     new_velocity[0] = origin2[0] - origin1[0]
  531.     new_velocity[1] = origin2[1] - origin1[1]
  532.     new_velocity[2] = origin2[2] - origin1[2]
  533.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  534.     new_velocity[0] *= num
  535.     new_velocity[1] *= num
  536.     new_velocity[2] *= num
  537.  
  538.     return 1
  539. }
  540.  
  541. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  542. {
  543.     new Float:RenderColor[3]
  544.     RenderColor[0] = float(r)
  545.     RenderColor[1] = float(g)
  546.     RenderColor[2] = float(b)
  547.  
  548.     set_pev(entity, pev_renderfx, fx)
  549.     set_pev(entity, pev_rendercolor, RenderColor)
  550.     set_pev(entity, pev_rendermode, render)
  551.     set_pev(entity, pev_renderamt, float(amount))
  552.  
  553.     return 1
  554. }
  555.  
  556. stock fm_give_item(index, const item[])
  557. {
  558.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  559.         return 0
  560.  
  561.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  562.     if (!pev_valid(ent))
  563.         return 0
  564.  
  565.     new Float:origin[3]
  566.     pev(index, pev_origin, origin)
  567.     set_pev(ent, pev_origin, origin)
  568.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  569.     dllfunc(DLLFunc_Spawn, ent)
  570.  
  571.     new save = pev(ent, pev_solid)
  572.     dllfunc(DLLFunc_Touch, ent, index)
  573.     if (pev(ent, pev_solid) != save)
  574.         return ent
  575.  
  576.     engfunc(EngFunc_RemoveEntity, ent)
  577.  
  578.     return -1
  579. }
  580.  
  581. stock ham_strip_weapon(index, weapon[])
  582. {
  583.     if(!equal(weapon, "weapon_", 7))
  584.         return 0
  585.  
  586.         new wId = get_weaponid(weapon)
  587.         if(!wId) return 0
  588.  
  589.         new wEnt
  590.         while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  591.  
  592.         if(!wEnt)
  593.         return 0
  594.  
  595.         if(get_user_weapon(index) == wId)
  596.         ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  597.  
  598.         if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  599.         return 0
  600.  
  601.         ExecuteHamB(Ham_Item_Kill, wEnt)
  602.  
  603.         set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  604.  
  605.         return 1
  606. }
it still shows it on the human extra items menu

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#8

Post by Mark » 5 years ago

shady101852 wrote: 5 years ago
Mark wrote: 5 years ago
shady101852 wrote: 5 years ago

I tried this and the jump nade shows in the extra items menu when I'm a human, and it lets me buy it also and turns into a frost nade.
  1. /*
  2. - Создание плагинов на закз:
  3.  
  4. - Контакты:
  5. - Vk: http://vk.com/Opo4uMapy
  6. - ICQ: 585552410
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fakemeta >
  11.  
  12. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  13. #define VERSION     "1.0"
  14. #define AUTHOR      "Opo4uMapy"
  15.  
  16. #define VIP_FLAGS "VIP_A"
  17.  
  18. native cs_get_user_bpammo(index, weapon)
  19. native cs_set_user_bpammo(index, weapon, amount)
  20.  
  21. #define JUMPBOMB_ID     55556
  22.  
  23. /////////////////////////////////////Cvars/////////////////////////////////////
  24.  
  25. #define ITEM_NAME       "Jump Grenade"  // Имя айтема
  26. #define ITEM_COST       6       // Стоимость за 1 бомбу
  27. #define MAX_GRENADE         5       // Лимит гранат
  28. #define RADIUS          300.0       // Радиус взрыва
  29. #define JUMP_DAMAGE     20      // Урон
  30. #define JUMP_EXP        500.0       // Сила отдачи от гранаты  
  31.  
  32. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  33.  
  34. #define BUY_GRENADE_MSG     "[ZP] Вы купили гранату джамп"
  35. #define MAX_GRENADE_MSG     "[ZP] Вы купили маскимум гранат"
  36.  
  37. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  38.  
  39. /////////////////////////////////////WeaponList/////////////////////////////////////
  40.  
  41. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  42.  
  43. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  44. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  45.  
  46. #if defined WEAPONLIST
  47. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  48.  
  49. new const WeaponList_Sprite[][] =
  50. {
  51.     "sprites/weapon_zombj1_sisa.txt",
  52.     "sprites/640hud61.spr",
  53.     "sprites/640hud7x.spr"
  54. }
  55.  
  56. enum
  57. {
  58.     prim_ammoid         = 13,
  59.     prim_ammomaxamount  = 1,
  60.     sec_ammoid      = -1,
  61.     sec_ammomaxamount   = -1,
  62.     slotid          = 3,
  63.     number_in_slot      = 3,
  64.     weaponid        = 9,
  65.     flags           = 24
  66. }
  67. #endif
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. // Модели гранаты
  72. new const BOMB_MODEL[][] =
  73. {
  74.     "models/v_zombibomb.mdl",
  75.     "models/p_zombibomb.mdl",
  76.     "models/w_zombibomb.mdl"
  77. }
  78.  
  79. //Звуки покупки
  80. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  81. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  82.    
  83. //Звук взрыва
  84. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  85.  
  86. //Не изменять! Звуки прописаны в модели.
  87. new const frogbomb_sound[][] =
  88. {
  89.     "nst_zombie/zombi_bomb_pull_1.wav",
  90.     "nst_zombie/zombi_bomb_deploy.wav",
  91.     "nst_zombie/zombi_bomb_throw.wav"
  92. }
  93.  
  94. new const frogbomb_sound_idle[][] =
  95. {
  96.     "nst_zombie/zombi_bomb_idle_1.wav",
  97.     "nst_zombie/zombi_bomb_idle_2.wav",
  98.     "nst_zombie/zombi_bomb_idle_3.wav",
  99.     "nst_zombie/zombi_bomb_idle_4.wav"
  100. }
  101. new g_itemid
  102.  
  103. new g_JumpGrenadeCount[33], g_iExplo
  104. #if defined TRAIL
  105. new g_trailSpr
  106. #endif
  107. #if defined GRENADE_ICON
  108. new grenade_icons[33][32]
  109. #endif
  110.  
  111. public plugin_precache()
  112. {
  113.     static i
  114.  
  115.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  116.         precache_model(BOMB_MODEL[i])
  117.  
  118.     for(i = 0; i < sizeof frogbomb_sound; i++)
  119.         precache_sound(frogbomb_sound[i])
  120.  
  121.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  122.         precache_sound(frogbomb_sound_idle[i])
  123.  
  124.     precache_sound(g_SoundGrenadeBuy)
  125.     precache_sound(g_SoundAmmoPurchase)
  126.     precache_sound(g_SoundBombExplode)
  127.  
  128.     #if defined WEAPONLIST
  129.     register_clcmd(WEAPON_NEW, "hook")
  130.  
  131.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  132.         precache_generic(WeaponList_Sprite[i])
  133.  
  134.     #endif
  135.  
  136.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  137.  
  138.     #if defined TRAIL
  139.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  140.     #endif
  141. }
  142.  
  143. public plugin_init()
  144. {
  145.     register_plugin(PLUGIN, VERSION, AUTHOR)
  146.  
  147.     //Ham
  148.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  149.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  150.  
  151.     //Forward
  152.     register_forward(FM_SetModel, "fw_SetModel")
  153.  
  154.     //Event
  155.     register_event("DeathMsg", "DeathMsg", "a")
  156.  
  157.     #if defined GRENADE_ICON
  158.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  159.     #endif
  160.  
  161.     //Extra Item
  162.     g_itemid = ze_register_item(ITEM_NAME, ITEM_COST, MAX_GRENADE)
  163.     ze_set_item_vip(g_itemid, VIP_FLAGS)
  164. }
  165.  
  166. #if defined WEAPONLIST
  167. public hook(id)
  168. {
  169.     if(!is_user_connected(id))
  170.         return PLUGIN_CONTINUE
  171.        
  172.     engclient_cmd(id, WEAPON_DEFAULT)
  173.    
  174.     return PLUGIN_HANDLED
  175. }
  176. #endif
  177.  
  178. public ze_select_item_preo(id, item)
  179. {
  180.     if (item != g_itemid)
  181.         return ZE_ITEM_AVAILABLE
  182.  
  183.     if (ze_is_user_zombie(id))
  184.         return ZE_ITEM_DONT_SHOW
  185.  
  186.     return ZE_ITEM_AVAILABLE
  187. }
  188.  
  189. public ze_select_item_post(id, Item)
  190. {
  191.     if(Item == g_itemid)
  192.     {
  193.         new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  194.         if(g_JumpGrenadeCount[id] >= 1)
  195.         {
  196.             cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  197.             emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  198.             g_JumpGrenadeCount[id]++
  199.         }
  200.         else
  201.         {
  202.             fm_give_item(id, WEAPON_DEFAULT)
  203.             client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
  204.             emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.             g_JumpGrenadeCount[id] = 1
  206.         }
  207.  
  208.         AmmoPickup(id)
  209.         #if defined WEAPONLIST
  210.         WeaponList(id, 1)
  211.         #endif
  212.     }
  213.     return PLUGIN_HANDLED
  214. }
  215.  
  216. public ze_user_infected(id)
  217. {
  218.     g_JumpGrenadeCount[id] = 0
  219.  
  220.     fm_give_item(id, WEAPON_DEFAULT)    
  221.     cs_set_user_bpammo(id, DEFAULT_CSW, 1)
  222.     emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)      
  223.  
  224.     AmmoPickup(id)
  225.  
  226.     g_JumpGrenadeCount[id] = 1
  227.     #if defined WEAPONLIST
  228.     WeaponList(id, 1)
  229.     #endif
  230. }
  231.  
  232. public ze_user_humanized(id)
  233. {
  234.     g_JumpGrenadeCount[id] = 0
  235.     #if defined WEAPONLIST
  236.     WeaponList(id, 0)
  237.     #endif
  238. }
  239.  
  240. public DeployPost(entity)
  241. {
  242.     static id
  243.     id = get_pdata_cbase(entity, 41, 4)
  244.  
  245.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  246.         return PLUGIN_CONTINUE
  247.  
  248.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  249.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  250.  
  251.     return PLUGIN_CONTINUE
  252. }
  253.  
  254. public fw_SetModel(Entity, const Model[])
  255. {
  256.     if (Entity < 0)
  257.         return FMRES_IGNORED
  258.  
  259.     if (pev(Entity, pev_dmgtime) == 0.0)
  260.         return FMRES_IGNORED
  261.  
  262.     new iOwner = pev(Entity, pev_owner)
  263.  
  264.     if(!ze_is_user_zombie(iOwner))
  265.         return FMRES_IGNORED
  266.            
  267.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  268.     {
  269.         g_JumpGrenadeCount[iOwner]--
  270.  
  271.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  272.         set_pev(Entity, pev_body, 23)
  273.  
  274.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  275.  
  276.         #if defined TRAIL
  277.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  278.         write_byte(TE_BEAMFOLLOW)
  279.         write_short(Entity)         // entity
  280.         write_short(g_trailSpr)     // sprite
  281.         write_byte(2)           // life
  282.         write_byte(5)           // width
  283.         write_byte(0)           // r
  284.         write_byte(200)         // g
  285.         write_byte(0)           // b
  286.         write_byte(200)         // brightness
  287.         message_end()
  288.         #endif
  289.  
  290.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  291.  
  292.         return FMRES_SUPERCEDE    
  293.     }
  294.     return FMRES_IGNORED
  295. }
  296.  
  297. public fw_ThinkGrenade(Entity)
  298. {
  299.     if(!pev_valid(Entity))
  300.         return HAM_IGNORED
  301.        
  302.     static Float:dmg_time
  303.     pev(Entity, pev_dmgtime, dmg_time)
  304.        
  305.     if(dmg_time > get_gametime())
  306.         return HAM_IGNORED
  307.        
  308.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  309.     {
  310.         JumpBombExplode(Entity)
  311.         return HAM_SUPERCEDE
  312.     }
  313.     return HAM_IGNORED
  314. }
  315.  
  316. public JumpBombExplode(Entity)
  317. {
  318.     if(Entity < 0)
  319.         return
  320.        
  321.     static Float:Origin[3]
  322.     pev(Entity, pev_origin, Origin)
  323.  
  324.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  325.     write_byte(TE_SPRITE)
  326.     engfunc(EngFunc_WriteCoord, Origin[0])
  327.     engfunc(EngFunc_WriteCoord, Origin[1])
  328.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  329.     write_short(g_iExplo)
  330.     write_byte(35)
  331.     write_byte(186)
  332.     message_end()
  333.            
  334.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  335.      
  336.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  337.     {
  338.         if (!is_user_alive(victim))
  339.             continue
  340.                  
  341.         new Float:VictimOrigin[3]
  342.         pev(victim, pev_origin, VictimOrigin)
  343.                    
  344.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  345.                    
  346.         if(Distance <= RADIUS)
  347.         {
  348.             static Float:NewSpeed
  349.  
  350.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  351.                            
  352.             static Float:Velocity[3]
  353.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  354.                            
  355.             set_pev(victim, pev_velocity, Velocity)
  356.            
  357.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  358.             write_short(1<<12 * 10)      
  359.             write_short(1<<12 * 10)
  360.             write_short(1<<12 * 10)
  361.             message_end()
  362.  
  363.             if(ze_is_user_zombie(victim))
  364.                 set_user_takedamage(victim, JUMP_DAMAGE)
  365.  
  366.         }
  367.     }
  368.     engfunc(EngFunc_RemoveEntity, Entity)
  369. }      
  370. #if defined GRENADE_ICON
  371. public grenade_icon(id)
  372. {
  373.     remove_grenade_icon(id)
  374.        
  375.     if(is_user_bot(id))
  376.         return
  377.  
  378.     static igrenade, grenade_sprite[16], grenade_color[3]
  379.     igrenade = get_user_weapon(id)
  380.    
  381.     switch(igrenade)
  382.     {
  383.         case DEFAULT_CSW:
  384.         {
  385.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  386.             {
  387.                 grenade_sprite = "dmg_gas"
  388.                 grenade_color = {255, 165, 0}
  389.             }
  390.             else
  391.             {
  392.                 grenade_sprite = ""
  393.                 grenade_color = {0, 0, 0}
  394.             }
  395.         }
  396.         default: return
  397.     }
  398.     grenade_icons[id] = grenade_sprite
  399.    
  400.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  401.     write_byte(1)
  402.     write_string(grenade_icons[id])
  403.     write_byte(grenade_color[0])
  404.     write_byte(grenade_color[1])
  405.     write_byte(grenade_color[2])
  406.     message_end()
  407.  
  408.     return
  409. }
  410. #endif
  411. public ze_roundend()
  412. {
  413.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  414.     {
  415.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  416.             continue
  417.  
  418.         ham_strip_weapon(id, WEAPON_DEFAULT)
  419.         g_JumpGrenadeCount[id] = 0
  420.     }
  421. }
  422.  
  423. public DeathMsg()
  424. {
  425.     new attacker = read_data(1)
  426.     new victim = read_data(2)
  427.  
  428.     if(!is_user_connected(attacker))
  429.         return HAM_IGNORED
  430.  
  431.     if(victim == attacker || !victim)
  432.         return HAM_IGNORED
  433.  
  434.     if(!ze_is_user_zombie(victim))
  435.         return HAM_IGNORED
  436.  
  437.     #if defined GRENADE_ICON
  438.     remove_grenade_icon(victim)
  439.     #endif
  440.  
  441.     #if defined WEAPONLIST
  442.     WeaponList(victim, 0)
  443.     #endif
  444.  
  445.     g_JumpGrenadeCount[victim] = 0
  446.  
  447.         return HAM_HANDLED
  448. }
  449.  
  450. public client_connect(id) g_JumpGrenadeCount[id] = 0
  451.  
  452. #if defined WEAPONLIST
  453. WeaponList(index, mode = 0)
  454. {
  455.     if (!is_user_connected(index))
  456.         return
  457.    
  458.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  459.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  460.     write_byte(prim_ammoid)
  461.     write_byte(prim_ammomaxamount)
  462.     write_byte(sec_ammoid)
  463.     write_byte(sec_ammomaxamount)
  464.     write_byte(slotid)
  465.     write_byte(number_in_slot)
  466.     write_byte(weaponid)
  467.     write_byte(flags)
  468.     message_end()
  469. }
  470. #endif
  471.  
  472. #if defined GRENADE_ICON
  473. static remove_grenade_icon(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  476.     write_byte(0)
  477.     write_string(grenade_icons[index])
  478.     message_end()
  479. }
  480. #endif
  481.  
  482. stock set_user_takedamage(index, damage)
  483. {
  484.     if(!is_user_alive(index))
  485.         return
  486.  
  487.     new vec[3]
  488.     FVecIVec(get_target_origin_f(index), vec)
  489.  
  490.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  491.     write_byte(0)
  492.     write_byte(damage)
  493.     write_long(DMG_CRUSH)
  494.     write_coord(vec[0])
  495.     write_coord(vec[1])
  496.     write_coord(vec[2])
  497.     message_end()
  498.  
  499.     if(pev(index, pev_health) - 20.0 <= 0)
  500.         ExecuteHamB(Ham_Killed, index, index, 1)
  501.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  502. }
  503.  
  504. stock AmmoPickup(index)
  505. {
  506.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  507.     write_byte(13)
  508.     write_byte(1)
  509.     message_end()
  510. }
  511.  
  512. stock Float:get_target_origin_f(index)
  513. {
  514.     new Float:orig[3]
  515.     pev(index, pev_origin, orig)
  516.  
  517.     if(index > get_maxplayers())
  518.     {
  519.         new Float:mins[3], Float:maxs[3]
  520.         pev(index, pev_mins, mins)
  521.         pev(index, pev_maxs, maxs)
  522.        
  523.         if(!mins[2]) orig[2] += maxs[2] / 2
  524.     }
  525.     return orig
  526. }
  527.  
  528. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  529. {
  530.     new_velocity[0] = origin2[0] - origin1[0]
  531.     new_velocity[1] = origin2[1] - origin1[1]
  532.     new_velocity[2] = origin2[2] - origin1[2]
  533.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  534.     new_velocity[0] *= num
  535.     new_velocity[1] *= num
  536.     new_velocity[2] *= num
  537.  
  538.     return 1
  539. }
  540.  
  541. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  542. {
  543.     new Float:RenderColor[3]
  544.     RenderColor[0] = float(r)
  545.     RenderColor[1] = float(g)
  546.     RenderColor[2] = float(b)
  547.  
  548.     set_pev(entity, pev_renderfx, fx)
  549.     set_pev(entity, pev_rendercolor, RenderColor)
  550.     set_pev(entity, pev_rendermode, render)
  551.     set_pev(entity, pev_renderamt, float(amount))
  552.  
  553.     return 1
  554. }
  555.  
  556. stock fm_give_item(index, const item[])
  557. {
  558.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  559.         return 0
  560.  
  561.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  562.     if (!pev_valid(ent))
  563.         return 0
  564.  
  565.     new Float:origin[3]
  566.     pev(index, pev_origin, origin)
  567.     set_pev(ent, pev_origin, origin)
  568.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  569.     dllfunc(DLLFunc_Spawn, ent)
  570.  
  571.     new save = pev(ent, pev_solid)
  572.     dllfunc(DLLFunc_Touch, ent, index)
  573.     if (pev(ent, pev_solid) != save)
  574.         return ent
  575.  
  576.     engfunc(EngFunc_RemoveEntity, ent)
  577.  
  578.     return -1
  579. }
  580.  
  581. stock ham_strip_weapon(index, weapon[])
  582. {
  583.     if(!equal(weapon, "weapon_", 7))
  584.         return 0
  585.  
  586.         new wId = get_weaponid(weapon)
  587.         if(!wId) return 0
  588.  
  589.         new wEnt
  590.         while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  591.  
  592.         if(!wEnt)
  593.         return 0
  594.  
  595.         if(get_user_weapon(index) == wId)
  596.         ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  597.  
  598.         if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  599.         return 0
  600.  
  601.         ExecuteHamB(Ham_Item_Kill, wEnt)
  602.  
  603.         set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  604.  
  605.         return 1
  606. }
it still shows it on the human extra items menu
Use this one...

  1. #include < zombie_escape >
  2. #include < fakemeta >
  3.  
  4.  
  5. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  6. #define VERSION     "1.0"
  7. #define AUTHOR      "Opo4uMapy"
  8.  
  9. native cs_get_user_bpammo(index, weapon)
  10. native cs_set_user_bpammo(index, weapon, amount)
  11.  
  12.  
  13. #define JUMPBOMB_ID     55556
  14.  
  15. /////////////////////////////////////Cvars/////////////////////////////////////
  16.  
  17. #define RADIUS          300.0       // Radius of explosion
  18. #define JUMP_DAMAGE     200      // Damage
  19. #define JUMP_EXP        1000.0       // Grenade recoil force  
  20.  
  21. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  22.  
  23. #define MAX_GRENADE_MSG     "[ZP] You are at the max!"
  24.  
  25. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  26.  
  27. /////////////////////////////////////WeaponList/////////////////////////////////////
  28.  
  29. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  30.  
  31. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  32. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  33.  
  34.  
  35. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  36.  
  37. new const WeaponList_Sprite[][] =
  38. {
  39.     "sprites/weapon_zombj1_sisa.txt",
  40.     "sprites/640hud61.spr",
  41.     "sprites/640hud7x.spr"
  42. }
  43.  
  44. enum
  45. {
  46.     prim_ammoid         = 13,
  47.     prim_ammomaxamount  = 1,
  48.     sec_ammoid      = -1,
  49.     sec_ammomaxamount   = -1,
  50.     slotid          = 3,
  51.     number_in_slot      = 3,
  52.     weaponid        = 9,
  53.     flags           = 24
  54. }
  55.  
  56.  
  57. ////////////////////////////////////////////////////////////////////////////////////
  58.  
  59. // Модели гранаты
  60. new const BOMB_MODEL[][] =
  61. {
  62.     "models/v_zombibomb.mdl",
  63.     "models/p_zombibomb.mdl",
  64.     "models/w_zombibomb.mdl"
  65. }
  66.  
  67. //Звуки покупки
  68. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  69. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  70.    
  71. //Звук взрыва
  72. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  73.  
  74. //Не изменять! Звуки прописаны в модели.
  75. new const frogbomb_sound[][] =
  76. {
  77.     "nst_zombie/zombi_bomb_pull_1.wav",
  78.     "nst_zombie/zombi_bomb_deploy.wav",
  79.     "nst_zombie/zombi_bomb_throw.wav"
  80. }
  81.  
  82. new const frogbomb_sound_idle[][] =
  83. {
  84.     "nst_zombie/zombi_bomb_idle_1.wav",
  85.     "nst_zombie/zombi_bomb_idle_2.wav",
  86.     "nst_zombie/zombi_bomb_idle_3.wav",
  87.     "nst_zombie/zombi_bomb_idle_4.wav"
  88. }
  89. new g_itemid
  90.  
  91. new g_JumpGrenadeCount[33], g_iExplo
  92.  
  93. new g_trailSpr
  94.  
  95. new grenade_icons[33][32]
  96.  
  97.  
  98. public plugin_precache()
  99. {
  100.     static i
  101.  
  102.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  103.         precache_model(BOMB_MODEL[i])
  104.  
  105.     for(i = 0; i < sizeof frogbomb_sound; i++)
  106.         precache_sound(frogbomb_sound[i])
  107.  
  108.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  109.         precache_sound(frogbomb_sound_idle[i])
  110.  
  111.     precache_sound(g_SoundGrenadeBuy)
  112.     precache_sound(g_SoundAmmoPurchase)
  113.     precache_sound(g_SoundBombExplode)
  114.  
  115.  
  116.     register_clcmd(WEAPON_NEW, "hook")
  117.  
  118.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  119.         precache_generic(WeaponList_Sprite[i])
  120.  
  121.  
  122.  
  123.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  124.  
  125.  
  126.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  127.  
  128. }
  129.  
  130. public plugin_natives()
  131. {
  132.     register_native("ze_give_jumpnade", "native_ze_give_jumpnade", 1)
  133. }
  134.  
  135. public plugin_init()
  136. {
  137.     register_plugin(PLUGIN, VERSION, AUTHOR)
  138.  
  139.     //Ham
  140.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  141.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  142.  
  143.     //Forward
  144.     register_forward(FM_SetModel, "fw_SetModel")
  145.  
  146.     //Event
  147.     register_event("DeathMsg", "DeathMsg", "a")
  148.  
  149.  
  150.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  151.  
  152.  
  153.     //Extra Item
  154.     g_itemid = ze_register_item("Jump Grenade", 100, 0)
  155.  
  156. }
  157.  
  158.  
  159. public hook(id)
  160. {
  161.     if(!is_user_connected(id))
  162.         return PLUGIN_CONTINUE
  163.        
  164.     engclient_cmd(id, WEAPON_DEFAULT)
  165.    
  166.     return PLUGIN_HANDLED
  167. }
  168.  
  169.  
  170. public ze_select_item_pre(id, itemid)
  171. {
  172.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  173.     if (itemid != g_itemid)
  174.         return ZE_ITEM_AVAILABLE
  175.    
  176.     // Available for Zombies only, So don't show it for Humans
  177.     if (!ze_is_user_zombie(id))
  178.         return ZE_ITEM_DONT_SHOW
  179.    
  180.     return ZE_ITEM_AVAILABLE
  181. }
  182.  
  183. public ze_select_item_post(id, itemid)
  184. {
  185.     // This is not our item, Block it here and don't execute the blew code
  186.     if (itemid != g_itemid)
  187.         return
  188.    
  189.     Get_Base(id)        
  190. }
  191.  
  192. public Get_Base(id)
  193. {
  194.     new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  195.     if(g_JumpGrenadeCount[id] >= 1)
  196.     {
  197.         cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  198.         emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  199.         g_JumpGrenadeCount[id]++
  200.     }
  201.     else
  202.     {
  203.         fm_give_item(id, WEAPON_DEFAULT)
  204.         emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.         g_JumpGrenadeCount[id] = 1
  206.     }
  207.  
  208.     AmmoPickup(id)
  209.     WeaponList(id, 1)
  210. }
  211.  
  212. public ze_user_humanized(id)
  213. {
  214.     g_JumpGrenadeCount[id] = 0
  215.     WeaponList(id, 0)
  216. }
  217.  
  218. public DeployPost(entity)
  219. {
  220.     static id
  221.     id = get_pdata_cbase(entity, 41, 4)
  222.  
  223.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  224.         return PLUGIN_CONTINUE
  225.  
  226.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  227.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  228.  
  229.     return PLUGIN_CONTINUE
  230. }
  231.  
  232. public fw_SetModel(Entity, const Model[])
  233. {
  234.     if (Entity < 0)
  235.         return FMRES_IGNORED
  236.  
  237.     if (pev(Entity, pev_dmgtime) == 0.0)
  238.         return FMRES_IGNORED
  239.  
  240.     new iOwner = pev(Entity, pev_owner)
  241.  
  242.     if(!ze_is_user_zombie(iOwner))
  243.         return FMRES_IGNORED
  244.            
  245.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  246.     {
  247.         g_JumpGrenadeCount[iOwner]--
  248.  
  249.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  250.         set_pev(Entity, pev_body, 23)
  251.  
  252.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  253.  
  254.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  255.         write_byte(TE_BEAMFOLLOW)
  256.         write_short(Entity)         // entity
  257.         write_short(g_trailSpr)     // sprite
  258.         write_byte(2)           // life
  259.         write_byte(5)           // width
  260.         write_byte(0)           // r
  261.         write_byte(200)         // g
  262.         write_byte(0)           // b
  263.         write_byte(200)         // brightness
  264.         message_end()
  265.  
  266.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  267.  
  268.         return FMRES_SUPERCEDE    
  269.     }
  270.     return FMRES_IGNORED
  271. }
  272.  
  273. public fw_ThinkGrenade(Entity)
  274. {
  275.     if(!pev_valid(Entity))
  276.         return HAM_IGNORED
  277.        
  278.     static Float:dmg_time
  279.     pev(Entity, pev_dmgtime, dmg_time)
  280.        
  281.     if(dmg_time > get_gametime())
  282.         return HAM_IGNORED
  283.        
  284.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  285.     {
  286.         JumpBombExplode(Entity)
  287.         return HAM_SUPERCEDE
  288.     }
  289.     return HAM_IGNORED
  290. }
  291.  
  292. public JumpBombExplode(Entity)
  293. {
  294.     if(Entity < 0)
  295.         return
  296.        
  297.     static Float:Origin[3]
  298.     pev(Entity, pev_origin, Origin)
  299.  
  300.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  301.     write_byte(TE_SPRITE)
  302.     engfunc(EngFunc_WriteCoord, Origin[0])
  303.     engfunc(EngFunc_WriteCoord, Origin[1])
  304.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  305.     write_short(g_iExplo)
  306.     write_byte(35)
  307.     write_byte(186)
  308.     message_end()
  309.            
  310.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  311.      
  312.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  313.     {
  314.         if (!is_user_alive(victim))
  315.             continue
  316.                  
  317.         new Float:VictimOrigin[3]
  318.         pev(victim, pev_origin, VictimOrigin)
  319.                    
  320.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  321.                    
  322.         if(Distance <= RADIUS)
  323.         {
  324.             static Float:NewSpeed
  325.  
  326.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  327.                            
  328.             static Float:Velocity[3]
  329.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  330.                            
  331.             set_pev(victim, pev_velocity, Velocity)
  332.            
  333.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  334.             write_short(1<<12 * 10)      
  335.             write_short(1<<12 * 10)
  336.             write_short(1<<12 * 10)
  337.             message_end()
  338.  
  339.             if(ze_is_user_zombie(victim))
  340.                 set_user_takedamage(victim, JUMP_DAMAGE)
  341.  
  342.         }
  343.     }
  344.     engfunc(EngFunc_RemoveEntity, Entity)
  345. }      
  346.  
  347. public grenade_icon(id)
  348. {
  349.     remove_grenade_icon(id)
  350.        
  351.     if(is_user_bot(id))
  352.         return
  353.  
  354.     static igrenade, grenade_sprite[16], grenade_color[3]
  355.     igrenade = get_user_weapon(id)
  356.    
  357.     switch(igrenade)
  358.     {
  359.         case DEFAULT_CSW:
  360.         {
  361.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  362.             {
  363.                 grenade_sprite = "dmg_gas"
  364.                 grenade_color = {255, 165, 0}
  365.             }
  366.             else
  367.             {
  368.                 grenade_sprite = ""
  369.                 grenade_color = {0, 0, 0}
  370.             }
  371.         }
  372.         default: return
  373.     }
  374.     grenade_icons[id] = grenade_sprite
  375.    
  376.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  377.     write_byte(1)
  378.     write_string(grenade_icons[id])
  379.     write_byte(grenade_color[0])
  380.     write_byte(grenade_color[1])
  381.     write_byte(grenade_color[2])
  382.     message_end()
  383.  
  384.     return
  385. }
  386.  
  387. public ze_roundend()
  388. {
  389.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  390.     {
  391.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  392.             continue
  393.  
  394.         ham_strip_weapon(id, WEAPON_DEFAULT)
  395.         g_JumpGrenadeCount[id] = 0
  396.     }
  397. }
  398.  
  399. public DeathMsg()
  400. {
  401.     new attacker = read_data(1)
  402.     new victim = read_data(2)
  403.  
  404.     if(!is_user_connected(attacker))
  405.         return HAM_IGNORED
  406.  
  407.     if(victim == attacker || !victim)
  408.         return HAM_IGNORED
  409.  
  410.     if(!ze_is_user_zombie(victim))
  411.         return HAM_IGNORED
  412.  
  413.     remove_grenade_icon(victim)
  414.  
  415.     WeaponList(victim, 0)
  416.  
  417.     g_JumpGrenadeCount[victim] = 0
  418.  
  419.     return HAM_HANDLED
  420. }
  421.  
  422. public client_connect(id) g_JumpGrenadeCount[id] = 0
  423.  
  424. WeaponList(index, mode = 0)
  425. {
  426.     if (!is_user_connected(index))
  427.         return
  428.    
  429.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  430.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  431.     write_byte(prim_ammoid)
  432.     write_byte(prim_ammomaxamount)
  433.     write_byte(sec_ammoid)
  434.     write_byte(sec_ammomaxamount)
  435.     write_byte(slotid)
  436.     write_byte(number_in_slot)
  437.     write_byte(weaponid)
  438.     write_byte(flags)
  439.     message_end()
  440. }
  441.  
  442. static remove_grenade_icon(index)
  443. {
  444.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  445.     write_byte(0)
  446.     write_string(grenade_icons[index])
  447.     message_end()
  448. }
  449.  
  450.  
  451. stock set_user_takedamage(index, damage)
  452. {
  453.     if(!is_user_alive(index))
  454.         return
  455.  
  456.     new vec[3]
  457.     FVecIVec(get_target_origin_f(index), vec)
  458.  
  459.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  460.     write_byte(0)
  461.     write_byte(damage)
  462.     write_long(DMG_CRUSH)
  463.     write_coord(vec[0])
  464.     write_coord(vec[1])
  465.     write_coord(vec[2])
  466.     message_end()
  467.  
  468.     if(pev(index, pev_health) - 20.0 <= 0)
  469.         ExecuteHamB(Ham_Killed, index, index, 1)
  470.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  471. }
  472.  
  473. stock AmmoPickup(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  476.     write_byte(13)
  477.     write_byte(1)
  478.     message_end()
  479. }
  480.  
  481. stock Float:get_target_origin_f(index)
  482. {
  483.     new Float:orig[3]
  484.     pev(index, pev_origin, orig)
  485.  
  486.     if(index > get_maxplayers())
  487.     {
  488.         new Float:mins[3], Float:maxs[3]
  489.         pev(index, pev_mins, mins)
  490.         pev(index, pev_maxs, maxs)
  491.        
  492.         if(!mins[2]) orig[2] += maxs[2] / 2
  493.     }
  494.     return orig
  495. }
  496.  
  497. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  498. {
  499.     new_velocity[0] = origin2[0] - origin1[0]
  500.     new_velocity[1] = origin2[1] - origin1[1]
  501.     new_velocity[2] = origin2[2] - origin1[2]
  502.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  503.     new_velocity[0] *= num
  504.     new_velocity[1] *= num
  505.     new_velocity[2] *= num
  506.  
  507.     return 1
  508. }
  509.  
  510. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  511. {
  512.     new Float:RenderColor[3]
  513.     RenderColor[0] = float(r)
  514.     RenderColor[1] = float(g)
  515.     RenderColor[2] = float(b)
  516.  
  517.     set_pev(entity, pev_renderfx, fx)
  518.     set_pev(entity, pev_rendercolor, RenderColor)
  519.     set_pev(entity, pev_rendermode, render)
  520.     set_pev(entity, pev_renderamt, float(amount))
  521.  
  522.     return 1
  523. }
  524.  
  525. stock fm_give_item(index, const item[])
  526. {
  527.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  528.         return 0
  529.  
  530.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  531.     if (!pev_valid(ent))
  532.         return 0
  533.  
  534.     new Float:origin[3]
  535.     pev(index, pev_origin, origin)
  536.     set_pev(ent, pev_origin, origin)
  537.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  538.     dllfunc(DLLFunc_Spawn, ent)
  539.  
  540.     new save = pev(ent, pev_solid)
  541.     dllfunc(DLLFunc_Touch, ent, index)
  542.     if (pev(ent, pev_solid) != save)
  543.         return ent
  544.  
  545.     engfunc(EngFunc_RemoveEntity, ent)
  546.  
  547.     return -1
  548. }
  549.  
  550. stock ham_strip_weapon(index, weapon[])
  551. {
  552.     if(!equal(weapon, "weapon_", 7))
  553.     return 0
  554.  
  555.     new wId = get_weaponid(weapon)
  556.     if(!wId) return 0
  557.  
  558.     new wEnt
  559.     while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  560.  
  561.     if(!wEnt)
  562.     return 0
  563.  
  564.     if(get_user_weapon(index) == wId)
  565.     ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  566.  
  567.     if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  568.     return 0
  569.  
  570.     ExecuteHamB(Ham_Item_Kill, wEnt)
  571.  
  572.     set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  573.  
  574.     return 1
  575. }
  576.  
  577. public native_ze_give_jumpnade(id)
  578. {
  579.     Get_Base(id)
  580. }

shady101852
Member
Member
United States of America
Posts: 27
Joined: 5 years ago
Contact:

#9

Post by shady101852 » 5 years ago

Mark wrote: 5 years ago
shady101852 wrote: 5 years ago
Mark wrote: 5 years ago
  1. /*
  2. - Создание плагинов на закз:
  3.  
  4. - Контакты:
  5. - Vk: http://vk.com/Opo4uMapy
  6. - ICQ: 585552410
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fakemeta >
  11.  
  12. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  13. #define VERSION     "1.0"
  14. #define AUTHOR      "Opo4uMapy"
  15.  
  16. #define VIP_FLAGS "VIP_A"
  17.  
  18. native cs_get_user_bpammo(index, weapon)
  19. native cs_set_user_bpammo(index, weapon, amount)
  20.  
  21. #define JUMPBOMB_ID     55556
  22.  
  23. /////////////////////////////////////Cvars/////////////////////////////////////
  24.  
  25. #define ITEM_NAME       "Jump Grenade"  // Имя айтема
  26. #define ITEM_COST       6       // Стоимость за 1 бомбу
  27. #define MAX_GRENADE         5       // Лимит гранат
  28. #define RADIUS          300.0       // Радиус взрыва
  29. #define JUMP_DAMAGE     20      // Урон
  30. #define JUMP_EXP        500.0       // Сила отдачи от гранаты  
  31.  
  32. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  33.  
  34. #define BUY_GRENADE_MSG     "[ZP] Вы купили гранату джамп"
  35. #define MAX_GRENADE_MSG     "[ZP] Вы купили маскимум гранат"
  36.  
  37. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  38.  
  39. /////////////////////////////////////WeaponList/////////////////////////////////////
  40.  
  41. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  42.  
  43. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  44. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  45.  
  46. #if defined WEAPONLIST
  47. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  48.  
  49. new const WeaponList_Sprite[][] =
  50. {
  51.     "sprites/weapon_zombj1_sisa.txt",
  52.     "sprites/640hud61.spr",
  53.     "sprites/640hud7x.spr"
  54. }
  55.  
  56. enum
  57. {
  58.     prim_ammoid         = 13,
  59.     prim_ammomaxamount  = 1,
  60.     sec_ammoid      = -1,
  61.     sec_ammomaxamount   = -1,
  62.     slotid          = 3,
  63.     number_in_slot      = 3,
  64.     weaponid        = 9,
  65.     flags           = 24
  66. }
  67. #endif
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////
  70.  
  71. // Модели гранаты
  72. new const BOMB_MODEL[][] =
  73. {
  74.     "models/v_zombibomb.mdl",
  75.     "models/p_zombibomb.mdl",
  76.     "models/w_zombibomb.mdl"
  77. }
  78.  
  79. //Звуки покупки
  80. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  81. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  82.    
  83. //Звук взрыва
  84. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  85.  
  86. //Не изменять! Звуки прописаны в модели.
  87. new const frogbomb_sound[][] =
  88. {
  89.     "nst_zombie/zombi_bomb_pull_1.wav",
  90.     "nst_zombie/zombi_bomb_deploy.wav",
  91.     "nst_zombie/zombi_bomb_throw.wav"
  92. }
  93.  
  94. new const frogbomb_sound_idle[][] =
  95. {
  96.     "nst_zombie/zombi_bomb_idle_1.wav",
  97.     "nst_zombie/zombi_bomb_idle_2.wav",
  98.     "nst_zombie/zombi_bomb_idle_3.wav",
  99.     "nst_zombie/zombi_bomb_idle_4.wav"
  100. }
  101. new g_itemid
  102.  
  103. new g_JumpGrenadeCount[33], g_iExplo
  104. #if defined TRAIL
  105. new g_trailSpr
  106. #endif
  107. #if defined GRENADE_ICON
  108. new grenade_icons[33][32]
  109. #endif
  110.  
  111. public plugin_precache()
  112. {
  113.     static i
  114.  
  115.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  116.         precache_model(BOMB_MODEL[i])
  117.  
  118.     for(i = 0; i < sizeof frogbomb_sound; i++)
  119.         precache_sound(frogbomb_sound[i])
  120.  
  121.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  122.         precache_sound(frogbomb_sound_idle[i])
  123.  
  124.     precache_sound(g_SoundGrenadeBuy)
  125.     precache_sound(g_SoundAmmoPurchase)
  126.     precache_sound(g_SoundBombExplode)
  127.  
  128.     #if defined WEAPONLIST
  129.     register_clcmd(WEAPON_NEW, "hook")
  130.  
  131.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  132.         precache_generic(WeaponList_Sprite[i])
  133.  
  134.     #endif
  135.  
  136.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  137.  
  138.     #if defined TRAIL
  139.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  140.     #endif
  141. }
  142.  
  143. public plugin_init()
  144. {
  145.     register_plugin(PLUGIN, VERSION, AUTHOR)
  146.  
  147.     //Ham
  148.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  149.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  150.  
  151.     //Forward
  152.     register_forward(FM_SetModel, "fw_SetModel")
  153.  
  154.     //Event
  155.     register_event("DeathMsg", "DeathMsg", "a")
  156.  
  157.     #if defined GRENADE_ICON
  158.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  159.     #endif
  160.  
  161.     //Extra Item
  162.     g_itemid = ze_register_item(ITEM_NAME, ITEM_COST, MAX_GRENADE)
  163.     ze_set_item_vip(g_itemid, VIP_FLAGS)
  164. }
  165.  
  166. #if defined WEAPONLIST
  167. public hook(id)
  168. {
  169.     if(!is_user_connected(id))
  170.         return PLUGIN_CONTINUE
  171.        
  172.     engclient_cmd(id, WEAPON_DEFAULT)
  173.    
  174.     return PLUGIN_HANDLED
  175. }
  176. #endif
  177.  
  178. public ze_select_item_preo(id, item)
  179. {
  180.     if (item != g_itemid)
  181.         return ZE_ITEM_AVAILABLE
  182.  
  183.     if (ze_is_user_zombie(id))
  184.         return ZE_ITEM_DONT_SHOW
  185.  
  186.     return ZE_ITEM_AVAILABLE
  187. }
  188.  
  189. public ze_select_item_post(id, Item)
  190. {
  191.     if(Item == g_itemid)
  192.     {
  193.         new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  194.         if(g_JumpGrenadeCount[id] >= 1)
  195.         {
  196.             cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  197.             emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  198.             g_JumpGrenadeCount[id]++
  199.         }
  200.         else
  201.         {
  202.             fm_give_item(id, WEAPON_DEFAULT)
  203.             client_print(id, print_chat, "%s", BUY_GRENADE_MSG)
  204.             emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.             g_JumpGrenadeCount[id] = 1
  206.         }
  207.  
  208.         AmmoPickup(id)
  209.         #if defined WEAPONLIST
  210.         WeaponList(id, 1)
  211.         #endif
  212.     }
  213.     return PLUGIN_HANDLED
  214. }
  215.  
  216. public ze_user_infected(id)
  217. {
  218.     g_JumpGrenadeCount[id] = 0
  219.  
  220.     fm_give_item(id, WEAPON_DEFAULT)    
  221.     cs_set_user_bpammo(id, DEFAULT_CSW, 1)
  222.     emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)      
  223.  
  224.     AmmoPickup(id)
  225.  
  226.     g_JumpGrenadeCount[id] = 1
  227.     #if defined WEAPONLIST
  228.     WeaponList(id, 1)
  229.     #endif
  230. }
  231.  
  232. public ze_user_humanized(id)
  233. {
  234.     g_JumpGrenadeCount[id] = 0
  235.     #if defined WEAPONLIST
  236.     WeaponList(id, 0)
  237.     #endif
  238. }
  239.  
  240. public DeployPost(entity)
  241. {
  242.     static id
  243.     id = get_pdata_cbase(entity, 41, 4)
  244.  
  245.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  246.         return PLUGIN_CONTINUE
  247.  
  248.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  249.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  250.  
  251.     return PLUGIN_CONTINUE
  252. }
  253.  
  254. public fw_SetModel(Entity, const Model[])
  255. {
  256.     if (Entity < 0)
  257.         return FMRES_IGNORED
  258.  
  259.     if (pev(Entity, pev_dmgtime) == 0.0)
  260.         return FMRES_IGNORED
  261.  
  262.     new iOwner = pev(Entity, pev_owner)
  263.  
  264.     if(!ze_is_user_zombie(iOwner))
  265.         return FMRES_IGNORED
  266.            
  267.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  268.     {
  269.         g_JumpGrenadeCount[iOwner]--
  270.  
  271.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  272.         set_pev(Entity, pev_body, 23)
  273.  
  274.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  275.  
  276.         #if defined TRAIL
  277.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  278.         write_byte(TE_BEAMFOLLOW)
  279.         write_short(Entity)         // entity
  280.         write_short(g_trailSpr)     // sprite
  281.         write_byte(2)           // life
  282.         write_byte(5)           // width
  283.         write_byte(0)           // r
  284.         write_byte(200)         // g
  285.         write_byte(0)           // b
  286.         write_byte(200)         // brightness
  287.         message_end()
  288.         #endif
  289.  
  290.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  291.  
  292.         return FMRES_SUPERCEDE    
  293.     }
  294.     return FMRES_IGNORED
  295. }
  296.  
  297. public fw_ThinkGrenade(Entity)
  298. {
  299.     if(!pev_valid(Entity))
  300.         return HAM_IGNORED
  301.        
  302.     static Float:dmg_time
  303.     pev(Entity, pev_dmgtime, dmg_time)
  304.        
  305.     if(dmg_time > get_gametime())
  306.         return HAM_IGNORED
  307.        
  308.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  309.     {
  310.         JumpBombExplode(Entity)
  311.         return HAM_SUPERCEDE
  312.     }
  313.     return HAM_IGNORED
  314. }
  315.  
  316. public JumpBombExplode(Entity)
  317. {
  318.     if(Entity < 0)
  319.         return
  320.        
  321.     static Float:Origin[3]
  322.     pev(Entity, pev_origin, Origin)
  323.  
  324.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  325.     write_byte(TE_SPRITE)
  326.     engfunc(EngFunc_WriteCoord, Origin[0])
  327.     engfunc(EngFunc_WriteCoord, Origin[1])
  328.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  329.     write_short(g_iExplo)
  330.     write_byte(35)
  331.     write_byte(186)
  332.     message_end()
  333.            
  334.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  335.      
  336.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  337.     {
  338.         if (!is_user_alive(victim))
  339.             continue
  340.                  
  341.         new Float:VictimOrigin[3]
  342.         pev(victim, pev_origin, VictimOrigin)
  343.                    
  344.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  345.                    
  346.         if(Distance <= RADIUS)
  347.         {
  348.             static Float:NewSpeed
  349.  
  350.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  351.                            
  352.             static Float:Velocity[3]
  353.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  354.                            
  355.             set_pev(victim, pev_velocity, Velocity)
  356.            
  357.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  358.             write_short(1<<12 * 10)      
  359.             write_short(1<<12 * 10)
  360.             write_short(1<<12 * 10)
  361.             message_end()
  362.  
  363.             if(ze_is_user_zombie(victim))
  364.                 set_user_takedamage(victim, JUMP_DAMAGE)
  365.  
  366.         }
  367.     }
  368.     engfunc(EngFunc_RemoveEntity, Entity)
  369. }      
  370. #if defined GRENADE_ICON
  371. public grenade_icon(id)
  372. {
  373.     remove_grenade_icon(id)
  374.        
  375.     if(is_user_bot(id))
  376.         return
  377.  
  378.     static igrenade, grenade_sprite[16], grenade_color[3]
  379.     igrenade = get_user_weapon(id)
  380.    
  381.     switch(igrenade)
  382.     {
  383.         case DEFAULT_CSW:
  384.         {
  385.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  386.             {
  387.                 grenade_sprite = "dmg_gas"
  388.                 grenade_color = {255, 165, 0}
  389.             }
  390.             else
  391.             {
  392.                 grenade_sprite = ""
  393.                 grenade_color = {0, 0, 0}
  394.             }
  395.         }
  396.         default: return
  397.     }
  398.     grenade_icons[id] = grenade_sprite
  399.    
  400.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  401.     write_byte(1)
  402.     write_string(grenade_icons[id])
  403.     write_byte(grenade_color[0])
  404.     write_byte(grenade_color[1])
  405.     write_byte(grenade_color[2])
  406.     message_end()
  407.  
  408.     return
  409. }
  410. #endif
  411. public ze_roundend()
  412. {
  413.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  414.     {
  415.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  416.             continue
  417.  
  418.         ham_strip_weapon(id, WEAPON_DEFAULT)
  419.         g_JumpGrenadeCount[id] = 0
  420.     }
  421. }
  422.  
  423. public DeathMsg()
  424. {
  425.     new attacker = read_data(1)
  426.     new victim = read_data(2)
  427.  
  428.     if(!is_user_connected(attacker))
  429.         return HAM_IGNORED
  430.  
  431.     if(victim == attacker || !victim)
  432.         return HAM_IGNORED
  433.  
  434.     if(!ze_is_user_zombie(victim))
  435.         return HAM_IGNORED
  436.  
  437.     #if defined GRENADE_ICON
  438.     remove_grenade_icon(victim)
  439.     #endif
  440.  
  441.     #if defined WEAPONLIST
  442.     WeaponList(victim, 0)
  443.     #endif
  444.  
  445.     g_JumpGrenadeCount[victim] = 0
  446.  
  447.         return HAM_HANDLED
  448. }
  449.  
  450. public client_connect(id) g_JumpGrenadeCount[id] = 0
  451.  
  452. #if defined WEAPONLIST
  453. WeaponList(index, mode = 0)
  454. {
  455.     if (!is_user_connected(index))
  456.         return
  457.    
  458.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  459.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  460.     write_byte(prim_ammoid)
  461.     write_byte(prim_ammomaxamount)
  462.     write_byte(sec_ammoid)
  463.     write_byte(sec_ammomaxamount)
  464.     write_byte(slotid)
  465.     write_byte(number_in_slot)
  466.     write_byte(weaponid)
  467.     write_byte(flags)
  468.     message_end()
  469. }
  470. #endif
  471.  
  472. #if defined GRENADE_ICON
  473. static remove_grenade_icon(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  476.     write_byte(0)
  477.     write_string(grenade_icons[index])
  478.     message_end()
  479. }
  480. #endif
  481.  
  482. stock set_user_takedamage(index, damage)
  483. {
  484.     if(!is_user_alive(index))
  485.         return
  486.  
  487.     new vec[3]
  488.     FVecIVec(get_target_origin_f(index), vec)
  489.  
  490.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  491.     write_byte(0)
  492.     write_byte(damage)
  493.     write_long(DMG_CRUSH)
  494.     write_coord(vec[0])
  495.     write_coord(vec[1])
  496.     write_coord(vec[2])
  497.     message_end()
  498.  
  499.     if(pev(index, pev_health) - 20.0 <= 0)
  500.         ExecuteHamB(Ham_Killed, index, index, 1)
  501.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  502. }
  503.  
  504. stock AmmoPickup(index)
  505. {
  506.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  507.     write_byte(13)
  508.     write_byte(1)
  509.     message_end()
  510. }
  511.  
  512. stock Float:get_target_origin_f(index)
  513. {
  514.     new Float:orig[3]
  515.     pev(index, pev_origin, orig)
  516.  
  517.     if(index > get_maxplayers())
  518.     {
  519.         new Float:mins[3], Float:maxs[3]
  520.         pev(index, pev_mins, mins)
  521.         pev(index, pev_maxs, maxs)
  522.        
  523.         if(!mins[2]) orig[2] += maxs[2] / 2
  524.     }
  525.     return orig
  526. }
  527.  
  528. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  529. {
  530.     new_velocity[0] = origin2[0] - origin1[0]
  531.     new_velocity[1] = origin2[1] - origin1[1]
  532.     new_velocity[2] = origin2[2] - origin1[2]
  533.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  534.     new_velocity[0] *= num
  535.     new_velocity[1] *= num
  536.     new_velocity[2] *= num
  537.  
  538.     return 1
  539. }
  540.  
  541. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  542. {
  543.     new Float:RenderColor[3]
  544.     RenderColor[0] = float(r)
  545.     RenderColor[1] = float(g)
  546.     RenderColor[2] = float(b)
  547.  
  548.     set_pev(entity, pev_renderfx, fx)
  549.     set_pev(entity, pev_rendercolor, RenderColor)
  550.     set_pev(entity, pev_rendermode, render)
  551.     set_pev(entity, pev_renderamt, float(amount))
  552.  
  553.     return 1
  554. }
  555.  
  556. stock fm_give_item(index, const item[])
  557. {
  558.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  559.         return 0
  560.  
  561.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  562.     if (!pev_valid(ent))
  563.         return 0
  564.  
  565.     new Float:origin[3]
  566.     pev(index, pev_origin, origin)
  567.     set_pev(ent, pev_origin, origin)
  568.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  569.     dllfunc(DLLFunc_Spawn, ent)
  570.  
  571.     new save = pev(ent, pev_solid)
  572.     dllfunc(DLLFunc_Touch, ent, index)
  573.     if (pev(ent, pev_solid) != save)
  574.         return ent
  575.  
  576.     engfunc(EngFunc_RemoveEntity, ent)
  577.  
  578.     return -1
  579. }
  580.  
  581. stock ham_strip_weapon(index, weapon[])
  582. {
  583.     if(!equal(weapon, "weapon_", 7))
  584.         return 0
  585.  
  586.         new wId = get_weaponid(weapon)
  587.         if(!wId) return 0
  588.  
  589.         new wEnt
  590.         while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  591.  
  592.         if(!wEnt)
  593.         return 0
  594.  
  595.         if(get_user_weapon(index) == wId)
  596.         ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  597.  
  598.         if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  599.         return 0
  600.  
  601.         ExecuteHamB(Ham_Item_Kill, wEnt)
  602.  
  603.         set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  604.  
  605.         return 1
  606. }
it still shows it on the human extra items menu
Use this one...

  1. #include < zombie_escape >
  2. #include < fakemeta >
  3.  
  4.  
  5. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  6. #define VERSION     "1.0"
  7. #define AUTHOR      "Opo4uMapy"
  8.  
  9. native cs_get_user_bpammo(index, weapon)
  10. native cs_set_user_bpammo(index, weapon, amount)
  11.  
  12.  
  13. #define JUMPBOMB_ID     55556
  14.  
  15. /////////////////////////////////////Cvars/////////////////////////////////////
  16.  
  17. #define RADIUS          300.0       // Radius of explosion
  18. #define JUMP_DAMAGE     200      // Damage
  19. #define JUMP_EXP        1000.0       // Grenade recoil force  
  20.  
  21. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  22.  
  23. #define MAX_GRENADE_MSG     "[ZP] You are at the max!"
  24.  
  25. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  26.  
  27. /////////////////////////////////////WeaponList/////////////////////////////////////
  28.  
  29. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  30.  
  31. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  32. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  33.  
  34.  
  35. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  36.  
  37. new const WeaponList_Sprite[][] =
  38. {
  39.     "sprites/weapon_zombj1_sisa.txt",
  40.     "sprites/640hud61.spr",
  41.     "sprites/640hud7x.spr"
  42. }
  43.  
  44. enum
  45. {
  46.     prim_ammoid         = 13,
  47.     prim_ammomaxamount  = 1,
  48.     sec_ammoid      = -1,
  49.     sec_ammomaxamount   = -1,
  50.     slotid          = 3,
  51.     number_in_slot      = 3,
  52.     weaponid        = 9,
  53.     flags           = 24
  54. }
  55.  
  56.  
  57. ////////////////////////////////////////////////////////////////////////////////////
  58.  
  59. // Модели гранаты
  60. new const BOMB_MODEL[][] =
  61. {
  62.     "models/v_zombibomb.mdl",
  63.     "models/p_zombibomb.mdl",
  64.     "models/w_zombibomb.mdl"
  65. }
  66.  
  67. //Звуки покупки
  68. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  69. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  70.    
  71. //Звук взрыва
  72. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  73.  
  74. //Не изменять! Звуки прописаны в модели.
  75. new const frogbomb_sound[][] =
  76. {
  77.     "nst_zombie/zombi_bomb_pull_1.wav",
  78.     "nst_zombie/zombi_bomb_deploy.wav",
  79.     "nst_zombie/zombi_bomb_throw.wav"
  80. }
  81.  
  82. new const frogbomb_sound_idle[][] =
  83. {
  84.     "nst_zombie/zombi_bomb_idle_1.wav",
  85.     "nst_zombie/zombi_bomb_idle_2.wav",
  86.     "nst_zombie/zombi_bomb_idle_3.wav",
  87.     "nst_zombie/zombi_bomb_idle_4.wav"
  88. }
  89. new g_itemid
  90.  
  91. new g_JumpGrenadeCount[33], g_iExplo
  92.  
  93. new g_trailSpr
  94.  
  95. new grenade_icons[33][32]
  96.  
  97.  
  98. public plugin_precache()
  99. {
  100.     static i
  101.  
  102.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  103.         precache_model(BOMB_MODEL[i])
  104.  
  105.     for(i = 0; i < sizeof frogbomb_sound; i++)
  106.         precache_sound(frogbomb_sound[i])
  107.  
  108.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  109.         precache_sound(frogbomb_sound_idle[i])
  110.  
  111.     precache_sound(g_SoundGrenadeBuy)
  112.     precache_sound(g_SoundAmmoPurchase)
  113.     precache_sound(g_SoundBombExplode)
  114.  
  115.  
  116.     register_clcmd(WEAPON_NEW, "hook")
  117.  
  118.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  119.         precache_generic(WeaponList_Sprite[i])
  120.  
  121.  
  122.  
  123.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  124.  
  125.  
  126.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  127.  
  128. }
  129.  
  130. public plugin_natives()
  131. {
  132.     register_native("ze_give_jumpnade", "native_ze_give_jumpnade", 1)
  133. }
  134.  
  135. public plugin_init()
  136. {
  137.     register_plugin(PLUGIN, VERSION, AUTHOR)
  138.  
  139.     //Ham
  140.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  141.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  142.  
  143.     //Forward
  144.     register_forward(FM_SetModel, "fw_SetModel")
  145.  
  146.     //Event
  147.     register_event("DeathMsg", "DeathMsg", "a")
  148.  
  149.  
  150.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  151.  
  152.  
  153.     //Extra Item
  154.     g_itemid = ze_register_item("Jump Grenade", 100, 0)
  155.  
  156. }
  157.  
  158.  
  159. public hook(id)
  160. {
  161.     if(!is_user_connected(id))
  162.         return PLUGIN_CONTINUE
  163.        
  164.     engclient_cmd(id, WEAPON_DEFAULT)
  165.    
  166.     return PLUGIN_HANDLED
  167. }
  168.  
  169.  
  170. public ze_select_item_pre(id, itemid)
  171. {
  172.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  173.     if (itemid != g_itemid)
  174.         return ZE_ITEM_AVAILABLE
  175.    
  176.     // Available for Zombies only, So don't show it for Humans
  177.     if (!ze_is_user_zombie(id))
  178.         return ZE_ITEM_DONT_SHOW
  179.    
  180.     return ZE_ITEM_AVAILABLE
  181. }
  182.  
  183. public ze_select_item_post(id, itemid)
  184. {
  185.     // This is not our item, Block it here and don't execute the blew code
  186.     if (itemid != g_itemid)
  187.         return
  188.    
  189.     Get_Base(id)        
  190. }
  191.  
  192. public Get_Base(id)
  193. {
  194.     new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  195.     if(g_JumpGrenadeCount[id] >= 1)
  196.     {
  197.         cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  198.         emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  199.         g_JumpGrenadeCount[id]++
  200.     }
  201.     else
  202.     {
  203.         fm_give_item(id, WEAPON_DEFAULT)
  204.         emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.         g_JumpGrenadeCount[id] = 1
  206.     }
  207.  
  208.     AmmoPickup(id)
  209.     WeaponList(id, 1)
  210. }
  211.  
  212. public ze_user_humanized(id)
  213. {
  214.     g_JumpGrenadeCount[id] = 0
  215.     WeaponList(id, 0)
  216. }
  217.  
  218. public DeployPost(entity)
  219. {
  220.     static id
  221.     id = get_pdata_cbase(entity, 41, 4)
  222.  
  223.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  224.         return PLUGIN_CONTINUE
  225.  
  226.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  227.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  228.  
  229.     return PLUGIN_CONTINUE
  230. }
  231.  
  232. public fw_SetModel(Entity, const Model[])
  233. {
  234.     if (Entity < 0)
  235.         return FMRES_IGNORED
  236.  
  237.     if (pev(Entity, pev_dmgtime) == 0.0)
  238.         return FMRES_IGNORED
  239.  
  240.     new iOwner = pev(Entity, pev_owner)
  241.  
  242.     if(!ze_is_user_zombie(iOwner))
  243.         return FMRES_IGNORED
  244.            
  245.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  246.     {
  247.         g_JumpGrenadeCount[iOwner]--
  248.  
  249.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  250.         set_pev(Entity, pev_body, 23)
  251.  
  252.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  253.  
  254.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  255.         write_byte(TE_BEAMFOLLOW)
  256.         write_short(Entity)         // entity
  257.         write_short(g_trailSpr)     // sprite
  258.         write_byte(2)           // life
  259.         write_byte(5)           // width
  260.         write_byte(0)           // r
  261.         write_byte(200)         // g
  262.         write_byte(0)           // b
  263.         write_byte(200)         // brightness
  264.         message_end()
  265.  
  266.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  267.  
  268.         return FMRES_SUPERCEDE    
  269.     }
  270.     return FMRES_IGNORED
  271. }
  272.  
  273. public fw_ThinkGrenade(Entity)
  274. {
  275.     if(!pev_valid(Entity))
  276.         return HAM_IGNORED
  277.        
  278.     static Float:dmg_time
  279.     pev(Entity, pev_dmgtime, dmg_time)
  280.        
  281.     if(dmg_time > get_gametime())
  282.         return HAM_IGNORED
  283.        
  284.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  285.     {
  286.         JumpBombExplode(Entity)
  287.         return HAM_SUPERCEDE
  288.     }
  289.     return HAM_IGNORED
  290. }
  291.  
  292. public JumpBombExplode(Entity)
  293. {
  294.     if(Entity < 0)
  295.         return
  296.        
  297.     static Float:Origin[3]
  298.     pev(Entity, pev_origin, Origin)
  299.  
  300.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  301.     write_byte(TE_SPRITE)
  302.     engfunc(EngFunc_WriteCoord, Origin[0])
  303.     engfunc(EngFunc_WriteCoord, Origin[1])
  304.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  305.     write_short(g_iExplo)
  306.     write_byte(35)
  307.     write_byte(186)
  308.     message_end()
  309.            
  310.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  311.      
  312.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  313.     {
  314.         if (!is_user_alive(victim))
  315.             continue
  316.                  
  317.         new Float:VictimOrigin[3]
  318.         pev(victim, pev_origin, VictimOrigin)
  319.                    
  320.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  321.                    
  322.         if(Distance <= RADIUS)
  323.         {
  324.             static Float:NewSpeed
  325.  
  326.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  327.                            
  328.             static Float:Velocity[3]
  329.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  330.                            
  331.             set_pev(victim, pev_velocity, Velocity)
  332.            
  333.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  334.             write_short(1<<12 * 10)      
  335.             write_short(1<<12 * 10)
  336.             write_short(1<<12 * 10)
  337.             message_end()
  338.  
  339.             if(ze_is_user_zombie(victim))
  340.                 set_user_takedamage(victim, JUMP_DAMAGE)
  341.  
  342.         }
  343.     }
  344.     engfunc(EngFunc_RemoveEntity, Entity)
  345. }      
  346.  
  347. public grenade_icon(id)
  348. {
  349.     remove_grenade_icon(id)
  350.        
  351.     if(is_user_bot(id))
  352.         return
  353.  
  354.     static igrenade, grenade_sprite[16], grenade_color[3]
  355.     igrenade = get_user_weapon(id)
  356.    
  357.     switch(igrenade)
  358.     {
  359.         case DEFAULT_CSW:
  360.         {
  361.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  362.             {
  363.                 grenade_sprite = "dmg_gas"
  364.                 grenade_color = {255, 165, 0}
  365.             }
  366.             else
  367.             {
  368.                 grenade_sprite = ""
  369.                 grenade_color = {0, 0, 0}
  370.             }
  371.         }
  372.         default: return
  373.     }
  374.     grenade_icons[id] = grenade_sprite
  375.    
  376.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  377.     write_byte(1)
  378.     write_string(grenade_icons[id])
  379.     write_byte(grenade_color[0])
  380.     write_byte(grenade_color[1])
  381.     write_byte(grenade_color[2])
  382.     message_end()
  383.  
  384.     return
  385. }
  386.  
  387. public ze_roundend()
  388. {
  389.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  390.     {
  391.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  392.             continue
  393.  
  394.         ham_strip_weapon(id, WEAPON_DEFAULT)
  395.         g_JumpGrenadeCount[id] = 0
  396.     }
  397. }
  398.  
  399. public DeathMsg()
  400. {
  401.     new attacker = read_data(1)
  402.     new victim = read_data(2)
  403.  
  404.     if(!is_user_connected(attacker))
  405.         return HAM_IGNORED
  406.  
  407.     if(victim == attacker || !victim)
  408.         return HAM_IGNORED
  409.  
  410.     if(!ze_is_user_zombie(victim))
  411.         return HAM_IGNORED
  412.  
  413.     remove_grenade_icon(victim)
  414.  
  415.     WeaponList(victim, 0)
  416.  
  417.     g_JumpGrenadeCount[victim] = 0
  418.  
  419.     return HAM_HANDLED
  420. }
  421.  
  422. public client_connect(id) g_JumpGrenadeCount[id] = 0
  423.  
  424. WeaponList(index, mode = 0)
  425. {
  426.     if (!is_user_connected(index))
  427.         return
  428.    
  429.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  430.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  431.     write_byte(prim_ammoid)
  432.     write_byte(prim_ammomaxamount)
  433.     write_byte(sec_ammoid)
  434.     write_byte(sec_ammomaxamount)
  435.     write_byte(slotid)
  436.     write_byte(number_in_slot)
  437.     write_byte(weaponid)
  438.     write_byte(flags)
  439.     message_end()
  440. }
  441.  
  442. static remove_grenade_icon(index)
  443. {
  444.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  445.     write_byte(0)
  446.     write_string(grenade_icons[index])
  447.     message_end()
  448. }
  449.  
  450.  
  451. stock set_user_takedamage(index, damage)
  452. {
  453.     if(!is_user_alive(index))
  454.         return
  455.  
  456.     new vec[3]
  457.     FVecIVec(get_target_origin_f(index), vec)
  458.  
  459.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  460.     write_byte(0)
  461.     write_byte(damage)
  462.     write_long(DMG_CRUSH)
  463.     write_coord(vec[0])
  464.     write_coord(vec[1])
  465.     write_coord(vec[2])
  466.     message_end()
  467.  
  468.     if(pev(index, pev_health) - 20.0 <= 0)
  469.         ExecuteHamB(Ham_Killed, index, index, 1)
  470.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  471. }
  472.  
  473. stock AmmoPickup(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  476.     write_byte(13)
  477.     write_byte(1)
  478.     message_end()
  479. }
  480.  
  481. stock Float:get_target_origin_f(index)
  482. {
  483.     new Float:orig[3]
  484.     pev(index, pev_origin, orig)
  485.  
  486.     if(index > get_maxplayers())
  487.     {
  488.         new Float:mins[3], Float:maxs[3]
  489.         pev(index, pev_mins, mins)
  490.         pev(index, pev_maxs, maxs)
  491.        
  492.         if(!mins[2]) orig[2] += maxs[2] / 2
  493.     }
  494.     return orig
  495. }
  496.  
  497. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  498. {
  499.     new_velocity[0] = origin2[0] - origin1[0]
  500.     new_velocity[1] = origin2[1] - origin1[1]
  501.     new_velocity[2] = origin2[2] - origin1[2]
  502.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  503.     new_velocity[0] *= num
  504.     new_velocity[1] *= num
  505.     new_velocity[2] *= num
  506.  
  507.     return 1
  508. }
  509.  
  510. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  511. {
  512.     new Float:RenderColor[3]
  513.     RenderColor[0] = float(r)
  514.     RenderColor[1] = float(g)
  515.     RenderColor[2] = float(b)
  516.  
  517.     set_pev(entity, pev_renderfx, fx)
  518.     set_pev(entity, pev_rendercolor, RenderColor)
  519.     set_pev(entity, pev_rendermode, render)
  520.     set_pev(entity, pev_renderamt, float(amount))
  521.  
  522.     return 1
  523. }
  524.  
  525. stock fm_give_item(index, const item[])
  526. {
  527.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  528.         return 0
  529.  
  530.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  531.     if (!pev_valid(ent))
  532.         return 0
  533.  
  534.     new Float:origin[3]
  535.     pev(index, pev_origin, origin)
  536.     set_pev(ent, pev_origin, origin)
  537.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  538.     dllfunc(DLLFunc_Spawn, ent)
  539.  
  540.     new save = pev(ent, pev_solid)
  541.     dllfunc(DLLFunc_Touch, ent, index)
  542.     if (pev(ent, pev_solid) != save)
  543.         return ent
  544.  
  545.     engfunc(EngFunc_RemoveEntity, ent)
  546.  
  547.     return -1
  548. }
  549.  
  550. stock ham_strip_weapon(index, weapon[])
  551. {
  552.     if(!equal(weapon, "weapon_", 7))
  553.     return 0
  554.  
  555.     new wId = get_weaponid(weapon)
  556.     if(!wId) return 0
  557.  
  558.     new wEnt
  559.     while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  560.  
  561.     if(!wEnt)
  562.     return 0
  563.  
  564.     if(get_user_weapon(index) == wId)
  565.     ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  566.  
  567.     if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  568.     return 0
  569.  
  570.     ExecuteHamB(Ham_Item_Kill, wEnt)
  571.  
  572.     set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  573.  
  574.     return 1
  575. }
  576.  
  577. public native_ze_give_jumpnade(id)
  578. {
  579.     Get_Base(id)
  580. }
this one works good, thank you

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#10

Post by Mark » 5 years ago

shady101852 wrote: 5 years ago
Mark wrote: 5 years ago
shady101852 wrote: 5 years ago
it still shows it on the human extra items menu
Use this one...

  1. #include < zombie_escape >
  2. #include < fakemeta >
  3.  
  4.  
  5. #define PLUGIN      "[ZP] Extra Item: Jump Bomb"
  6. #define VERSION     "1.0"
  7. #define AUTHOR      "Opo4uMapy"
  8.  
  9. native cs_get_user_bpammo(index, weapon)
  10. native cs_set_user_bpammo(index, weapon, amount)
  11.  
  12.  
  13. #define JUMPBOMB_ID     55556
  14.  
  15. /////////////////////////////////////Cvars/////////////////////////////////////
  16.  
  17. #define RADIUS          300.0       // Radius of explosion
  18. #define JUMP_DAMAGE     200      // Damage
  19. #define JUMP_EXP        1000.0       // Grenade recoil force  
  20.  
  21. #define GRENADE_ICON                //Иконка с лева. Что бы отключить поставьте //
  22.  
  23. #define MAX_GRENADE_MSG     "[ZP] You are at the max!"
  24.  
  25. #define TRAIL       //Трайл за гранатой. Что бы отключить закоментируем ( //#define TRAIL )
  26.  
  27. /////////////////////////////////////WeaponList/////////////////////////////////////
  28.  
  29. #define WEAPONLIST  // WeaponList. Что бы отключить закоментируем ( //#define WEAPONLIST )
  30.  
  31. #define WEAPON_DEFAULT      "weapon_smokegrenade"   //Weapon под которую сделана граната
  32. #define DEFAULT_CSW     CSW_SMOKEGRENADE    //CSW под которую сделана граната
  33.  
  34.  
  35. #define WEAPON_NEW      "weapon_zombj1_sisa"    //Название WeaponList'a новой гранаты
  36.  
  37. new const WeaponList_Sprite[][] =
  38. {
  39.     "sprites/weapon_zombj1_sisa.txt",
  40.     "sprites/640hud61.spr",
  41.     "sprites/640hud7x.spr"
  42. }
  43.  
  44. enum
  45. {
  46.     prim_ammoid         = 13,
  47.     prim_ammomaxamount  = 1,
  48.     sec_ammoid      = -1,
  49.     sec_ammomaxamount   = -1,
  50.     slotid          = 3,
  51.     number_in_slot      = 3,
  52.     weaponid        = 9,
  53.     flags           = 24
  54. }
  55.  
  56.  
  57. ////////////////////////////////////////////////////////////////////////////////////
  58.  
  59. // Модели гранаты
  60. new const BOMB_MODEL[][] =
  61. {
  62.     "models/v_zombibomb.mdl",
  63.     "models/p_zombibomb.mdl",
  64.     "models/w_zombibomb.mdl"
  65. }
  66.  
  67. //Звуки покупки
  68. #define g_SoundGrenadeBuy   "items/gunpickup2.wav"
  69. #define g_SoundAmmoPurchase "items/9mmclip1.wav"
  70.    
  71. //Звук взрыва
  72. #define g_SoundBombExplode  "nst_zombie/zombi_bomb_exp.wav"
  73.  
  74. //Не изменять! Звуки прописаны в модели.
  75. new const frogbomb_sound[][] =
  76. {
  77.     "nst_zombie/zombi_bomb_pull_1.wav",
  78.     "nst_zombie/zombi_bomb_deploy.wav",
  79.     "nst_zombie/zombi_bomb_throw.wav"
  80. }
  81.  
  82. new const frogbomb_sound_idle[][] =
  83. {
  84.     "nst_zombie/zombi_bomb_idle_1.wav",
  85.     "nst_zombie/zombi_bomb_idle_2.wav",
  86.     "nst_zombie/zombi_bomb_idle_3.wav",
  87.     "nst_zombie/zombi_bomb_idle_4.wav"
  88. }
  89. new g_itemid
  90.  
  91. new g_JumpGrenadeCount[33], g_iExplo
  92.  
  93. new g_trailSpr
  94.  
  95. new grenade_icons[33][32]
  96.  
  97.  
  98. public plugin_precache()
  99. {
  100.     static i
  101.  
  102.     for(i = 0; i < sizeof BOMB_MODEL; i++)
  103.         precache_model(BOMB_MODEL[i])
  104.  
  105.     for(i = 0; i < sizeof frogbomb_sound; i++)
  106.         precache_sound(frogbomb_sound[i])
  107.  
  108.     for(i = 0; i < sizeof frogbomb_sound_idle; i++)
  109.         precache_sound(frogbomb_sound_idle[i])
  110.  
  111.     precache_sound(g_SoundGrenadeBuy)
  112.     precache_sound(g_SoundAmmoPurchase)
  113.     precache_sound(g_SoundBombExplode)
  114.  
  115.  
  116.     register_clcmd(WEAPON_NEW, "hook")
  117.  
  118.     for(i = 0; i < sizeof WeaponList_Sprite; i++)
  119.         precache_generic(WeaponList_Sprite[i])
  120.  
  121.  
  122.  
  123.     g_iExplo = precache_model("sprites/zombiebomb_exp.spr")
  124.  
  125.  
  126.     g_trailSpr = precache_model("sprites/laserbeam.spr")
  127.  
  128. }
  129.  
  130. public plugin_natives()
  131. {
  132.     register_native("ze_give_jumpnade", "native_ze_give_jumpnade", 1)
  133. }
  134.  
  135. public plugin_init()
  136. {
  137.     register_plugin(PLUGIN, VERSION, AUTHOR)
  138.  
  139.     //Ham
  140.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  141.     RegisterHam(Ham_Item_Deploy, WEAPON_DEFAULT, "DeployPost", 1)
  142.  
  143.     //Forward
  144.     register_forward(FM_SetModel, "fw_SetModel")
  145.  
  146.     //Event
  147.     register_event("DeathMsg", "DeathMsg", "a")
  148.  
  149.  
  150.     register_event("CurWeapon", "grenade_icon", "be", "1=1")
  151.  
  152.  
  153.     //Extra Item
  154.     g_itemid = ze_register_item("Jump Grenade", 100, 0)
  155.  
  156. }
  157.  
  158.  
  159. public hook(id)
  160. {
  161.     if(!is_user_connected(id))
  162.         return PLUGIN_CONTINUE
  163.        
  164.     engclient_cmd(id, WEAPON_DEFAULT)
  165.    
  166.     return PLUGIN_HANDLED
  167. }
  168.  
  169.  
  170. public ze_select_item_pre(id, itemid)
  171. {
  172.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  173.     if (itemid != g_itemid)
  174.         return ZE_ITEM_AVAILABLE
  175.    
  176.     // Available for Zombies only, So don't show it for Humans
  177.     if (!ze_is_user_zombie(id))
  178.         return ZE_ITEM_DONT_SHOW
  179.    
  180.     return ZE_ITEM_AVAILABLE
  181. }
  182.  
  183. public ze_select_item_post(id, itemid)
  184. {
  185.     // This is not our item, Block it here and don't execute the blew code
  186.     if (itemid != g_itemid)
  187.         return
  188.    
  189.     Get_Base(id)        
  190. }
  191.  
  192. public Get_Base(id)
  193. {
  194.     new Ammo = cs_get_user_bpammo(id, DEFAULT_CSW)
  195.     if(g_JumpGrenadeCount[id] >= 1)
  196.     {
  197.         cs_set_user_bpammo(id, DEFAULT_CSW, Ammo + 1)
  198.         emit_sound(id, CHAN_ITEM, g_SoundAmmoPurchase, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  199.         g_JumpGrenadeCount[id]++
  200.     }
  201.     else
  202.     {
  203.         fm_give_item(id, WEAPON_DEFAULT)
  204.         emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  205.         g_JumpGrenadeCount[id] = 1
  206.     }
  207.  
  208.     AmmoPickup(id)
  209.     WeaponList(id, 1)
  210. }
  211.  
  212. public ze_user_humanized(id)
  213. {
  214.     g_JumpGrenadeCount[id] = 0
  215.     WeaponList(id, 0)
  216. }
  217.  
  218. public DeployPost(entity)
  219. {
  220.     static id
  221.     id = get_pdata_cbase(entity, 41, 4)
  222.  
  223.     if(!is_user_alive(id) || !ze_is_user_zombie(id))
  224.         return PLUGIN_CONTINUE
  225.  
  226.     set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
  227.     set_pev(id, pev_weaponmodel2, BOMB_MODEL[1])
  228.  
  229.     return PLUGIN_CONTINUE
  230. }
  231.  
  232. public fw_SetModel(Entity, const Model[])
  233. {
  234.     if (Entity < 0)
  235.         return FMRES_IGNORED
  236.  
  237.     if (pev(Entity, pev_dmgtime) == 0.0)
  238.         return FMRES_IGNORED
  239.  
  240.     new iOwner = pev(Entity, pev_owner)
  241.  
  242.     if(!ze_is_user_zombie(iOwner))
  243.         return FMRES_IGNORED
  244.            
  245.     if(g_JumpGrenadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  246.     {
  247.         g_JumpGrenadeCount[iOwner]--
  248.  
  249.         set_pev(Entity, pev_flTimeStepSound, JUMPBOMB_ID)
  250.         set_pev(Entity, pev_body, 23)
  251.  
  252.         fm_set_rendering(Entity, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16)
  253.  
  254.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  255.         write_byte(TE_BEAMFOLLOW)
  256.         write_short(Entity)         // entity
  257.         write_short(g_trailSpr)     // sprite
  258.         write_byte(2)           // life
  259.         write_byte(5)           // width
  260.         write_byte(0)           // r
  261.         write_byte(200)         // g
  262.         write_byte(0)           // b
  263.         write_byte(200)         // brightness
  264.         message_end()
  265.  
  266.         engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])
  267.  
  268.         return FMRES_SUPERCEDE    
  269.     }
  270.     return FMRES_IGNORED
  271. }
  272.  
  273. public fw_ThinkGrenade(Entity)
  274. {
  275.     if(!pev_valid(Entity))
  276.         return HAM_IGNORED
  277.        
  278.     static Float:dmg_time
  279.     pev(Entity, pev_dmgtime, dmg_time)
  280.        
  281.     if(dmg_time > get_gametime())
  282.         return HAM_IGNORED
  283.        
  284.     if(pev(Entity, pev_flTimeStepSound) == JUMPBOMB_ID)
  285.     {
  286.         JumpBombExplode(Entity)
  287.         return HAM_SUPERCEDE
  288.     }
  289.     return HAM_IGNORED
  290. }
  291.  
  292. public JumpBombExplode(Entity)
  293. {
  294.     if(Entity < 0)
  295.         return
  296.        
  297.     static Float:Origin[3]
  298.     pev(Entity, pev_origin, Origin)
  299.  
  300.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  301.     write_byte(TE_SPRITE)
  302.     engfunc(EngFunc_WriteCoord, Origin[0])
  303.     engfunc(EngFunc_WriteCoord, Origin[1])
  304.     engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  305.     write_short(g_iExplo)
  306.     write_byte(35)
  307.     write_byte(186)
  308.     message_end()
  309.            
  310.     emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  311.      
  312.     for(new victim = 1; victim <= get_maxplayers(); victim++)
  313.     {
  314.         if (!is_user_alive(victim))
  315.             continue
  316.                  
  317.         new Float:VictimOrigin[3]
  318.         pev(victim, pev_origin, VictimOrigin)
  319.                    
  320.         new Float:Distance = get_distance_f(Origin, VictimOrigin)  
  321.                    
  322.         if(Distance <= RADIUS)
  323.         {
  324.             static Float:NewSpeed
  325.  
  326.             NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))
  327.                            
  328.             static Float:Velocity[3]
  329.             get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
  330.                            
  331.             set_pev(victim, pev_velocity, Velocity)
  332.            
  333.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
  334.             write_short(1<<12 * 10)      
  335.             write_short(1<<12 * 10)
  336.             write_short(1<<12 * 10)
  337.             message_end()
  338.  
  339.             if(ze_is_user_zombie(victim))
  340.                 set_user_takedamage(victim, JUMP_DAMAGE)
  341.  
  342.         }
  343.     }
  344.     engfunc(EngFunc_RemoveEntity, Entity)
  345. }      
  346.  
  347. public grenade_icon(id)
  348. {
  349.     remove_grenade_icon(id)
  350.        
  351.     if(is_user_bot(id))
  352.         return
  353.  
  354.     static igrenade, grenade_sprite[16], grenade_color[3]
  355.     igrenade = get_user_weapon(id)
  356.    
  357.     switch(igrenade)
  358.     {
  359.         case DEFAULT_CSW:
  360.         {
  361.             if(!is_user_alive(id) || ze_is_user_zombie(id))
  362.             {
  363.                 grenade_sprite = "dmg_gas"
  364.                 grenade_color = {255, 165, 0}
  365.             }
  366.             else
  367.             {
  368.                 grenade_sprite = ""
  369.                 grenade_color = {0, 0, 0}
  370.             }
  371.         }
  372.         default: return
  373.     }
  374.     grenade_icons[id] = grenade_sprite
  375.    
  376.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"),{0, 0, 0}, id)
  377.     write_byte(1)
  378.     write_string(grenade_icons[id])
  379.     write_byte(grenade_color[0])
  380.     write_byte(grenade_color[1])
  381.     write_byte(grenade_color[2])
  382.     message_end()
  383.  
  384.     return
  385. }
  386.  
  387. public ze_roundend()
  388. {
  389.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  390.     {
  391.         if(!is_user_alive(id) || !ze_is_user_zombie(id))
  392.             continue
  393.  
  394.         ham_strip_weapon(id, WEAPON_DEFAULT)
  395.         g_JumpGrenadeCount[id] = 0
  396.     }
  397. }
  398.  
  399. public DeathMsg()
  400. {
  401.     new attacker = read_data(1)
  402.     new victim = read_data(2)
  403.  
  404.     if(!is_user_connected(attacker))
  405.         return HAM_IGNORED
  406.  
  407.     if(victim == attacker || !victim)
  408.         return HAM_IGNORED
  409.  
  410.     if(!ze_is_user_zombie(victim))
  411.         return HAM_IGNORED
  412.  
  413.     remove_grenade_icon(victim)
  414.  
  415.     WeaponList(victim, 0)
  416.  
  417.     g_JumpGrenadeCount[victim] = 0
  418.  
  419.     return HAM_HANDLED
  420. }
  421.  
  422. public client_connect(id) g_JumpGrenadeCount[id] = 0
  423.  
  424. WeaponList(index, mode = 0)
  425. {
  426.     if (!is_user_connected(index))
  427.         return
  428.    
  429.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
  430.     write_string(mode ? WEAPON_NEW : WEAPON_DEFAULT)
  431.     write_byte(prim_ammoid)
  432.     write_byte(prim_ammomaxamount)
  433.     write_byte(sec_ammoid)
  434.     write_byte(sec_ammomaxamount)
  435.     write_byte(slotid)
  436.     write_byte(number_in_slot)
  437.     write_byte(weaponid)
  438.     write_byte(flags)
  439.     message_end()
  440. }
  441.  
  442. static remove_grenade_icon(index)
  443. {
  444.     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), {0, 0, 0}, index)
  445.     write_byte(0)
  446.     write_string(grenade_icons[index])
  447.     message_end()
  448. }
  449.  
  450.  
  451. stock set_user_takedamage(index, damage)
  452. {
  453.     if(!is_user_alive(index))
  454.         return
  455.  
  456.     new vec[3]
  457.     FVecIVec(get_target_origin_f(index), vec)
  458.  
  459.     message_begin(MSG_ONE, get_user_msgid("Damage"), _, index)
  460.     write_byte(0)
  461.     write_byte(damage)
  462.     write_long(DMG_CRUSH)
  463.     write_coord(vec[0])
  464.     write_coord(vec[1])
  465.     write_coord(vec[2])
  466.     message_end()
  467.  
  468.     if(pev(index, pev_health) - 20.0 <= 0)
  469.         ExecuteHamB(Ham_Killed, index, index, 1)
  470.     else ExecuteHamB(Ham_TakeDamage, index, 0, index, float(damage), DMG_BLAST)
  471. }
  472.  
  473. stock AmmoPickup(index)
  474. {
  475.     message_begin(MSG_ONE, get_user_msgid("AmmoPickup"), _, index)
  476.     write_byte(13)
  477.     write_byte(1)
  478.     message_end()
  479. }
  480.  
  481. stock Float:get_target_origin_f(index)
  482. {
  483.     new Float:orig[3]
  484.     pev(index, pev_origin, orig)
  485.  
  486.     if(index > get_maxplayers())
  487.     {
  488.         new Float:mins[3], Float:maxs[3]
  489.         pev(index, pev_mins, mins)
  490.         pev(index, pev_maxs, maxs)
  491.        
  492.         if(!mins[2]) orig[2] += maxs[2] / 2
  493.     }
  494.     return orig
  495. }
  496.  
  497. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  498. {
  499.     new_velocity[0] = origin2[0] - origin1[0]
  500.     new_velocity[1] = origin2[1] - origin1[1]
  501.     new_velocity[2] = origin2[2] - origin1[2]
  502.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  503.     new_velocity[0] *= num
  504.     new_velocity[1] *= num
  505.     new_velocity[2] *= num
  506.  
  507.     return 1
  508. }
  509.  
  510. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  511. {
  512.     new Float:RenderColor[3]
  513.     RenderColor[0] = float(r)
  514.     RenderColor[1] = float(g)
  515.     RenderColor[2] = float(b)
  516.  
  517.     set_pev(entity, pev_renderfx, fx)
  518.     set_pev(entity, pev_rendercolor, RenderColor)
  519.     set_pev(entity, pev_rendermode, render)
  520.     set_pev(entity, pev_renderamt, float(amount))
  521.  
  522.     return 1
  523. }
  524.  
  525. stock fm_give_item(index, const item[])
  526. {
  527.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5))
  528.         return 0
  529.  
  530.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  531.     if (!pev_valid(ent))
  532.         return 0
  533.  
  534.     new Float:origin[3]
  535.     pev(index, pev_origin, origin)
  536.     set_pev(ent, pev_origin, origin)
  537.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  538.     dllfunc(DLLFunc_Spawn, ent)
  539.  
  540.     new save = pev(ent, pev_solid)
  541.     dllfunc(DLLFunc_Touch, ent, index)
  542.     if (pev(ent, pev_solid) != save)
  543.         return ent
  544.  
  545.     engfunc(EngFunc_RemoveEntity, ent)
  546.  
  547.     return -1
  548. }
  549.  
  550. stock ham_strip_weapon(index, weapon[])
  551. {
  552.     if(!equal(weapon, "weapon_", 7))
  553.     return 0
  554.  
  555.     new wId = get_weaponid(weapon)
  556.     if(!wId) return 0
  557.  
  558.     new wEnt
  559.     while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt,pev_owner) != index) {}
  560.  
  561.     if(!wEnt)
  562.     return 0
  563.  
  564.     if(get_user_weapon(index) == wId)
  565.     ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  566.  
  567.     if(!ExecuteHamB(Ham_RemovePlayerItem, index, wEnt))
  568.     return 0
  569.  
  570.     ExecuteHamB(Ham_Item_Kill, wEnt)
  571.  
  572.     set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<wId))
  573.  
  574.     return 1
  575. }
  576.  
  577. public native_ze_give_jumpnade(id)
  578. {
  579.     Get_Base(id)
  580. }
this one works good, thank you
Your welcome!

Post Reply

Create an account or sign in to join the discussion

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

Create an account

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

Register

Sign in

Who is online

Users browsing this forum: No registered users and 3 guests