[ZP] Extra Items: Axe Knife

Pluginuri pentru modul AmxModX.

Moderators: Moderatori ajutatori, Moderatori

Post Reply
User avatar
Rainq
Moderator
Moderator
Posts: 2642
Joined: 21 Jul 2015, 18:50
Detinator Steam: Da
CS Status: Busy
Detinator server CS: ---
Reputatie: Moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucuresti
Has thanked: 1 time
Been thanked: 17 times
Contact:

17 Feb 2019, 13:13

Descriere: Knife special pentru oameni


Descarcare: LINK RESURSE!
| Afiseaza codul
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>

#define NAME		"zp_knife_axe"
#define VERSION		"1.0"
#define AUTHOR		"Tank1229 and Knife Generator"


#define KNIFE_NAME	"Axe Knife"
#define KNIFE_COST	5

#define KNIFE_GRAVITY	0.91
#define KNIFE_SPEED	290.0
#define SEC_DMG		2.5
#define PRIM_DMG	3.5
#define SEC_HEAD_DMG	4.5
#define PRIM_HEAD_DMG	5.5
#define	KNIFE_KNOCK	5
#define BLOOD		3
#define ADMIN		"1"

static const v_knife[] = "models/axe/v_axe.mdl"
static const p_knife[] = "models/axe/p_axe.mdl"

static const SoundList[][] =
{
	"axe/axe_deploy1.wav",	// 0
	"axe/axe_hwall.wav",	// 1
	"axe/axe_slash1.wav",	// 2
	"axe/axe_stab.wav",	// 3
	"axe/axe1.wav",	// 4
	"axe/axe2.wav"	// 5
}

static const Blood[][] =
{
	"sprites/blood.spr",
	"sprites/bloodspray.spr"
}
static g_Blood[sizeof Blood]
static g_Item_Knife
static bool:Knife[33]

public plugin_init()
{
	register_plugin(NAME, VERSION, AUTHOR)
	
	g_Item_Knife = zp_register_extra_item(KNIFE_NAME, KNIFE_COST, ZP_TEAM_HUMAN)
	
	register_event("CurWeapon", "ChangeModel", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage_Pre", 0)
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage_Post", 1)
	RegisterHam(Ham_Player_PreThink, "player", "PreThink")
	register_forward(FM_EmitSound, "KnifeSound")
}
public zp_user_infected_post(id) Knife[id] = false
public zp_extra_item_selected(id, itemid)
{
	if(itemid == g_Item_Knife)
	{	if(Knife[id]) return ZP_PLUGIN_HANDLED
		new num = str_to_num(ADMIN)
		if(num)
		{
			if(!is_user_admin(id))
			return ZP_PLUGIN_HANDLED
		}
		engclient_cmd(id, "weapon_knife")
		Knife[id] = true
		change(id)
	}
	return PLUGIN_CONTINUE
}

public ChangeModel(id)
{
	if(!is_user_alive(id) || zp_get_user_zombie(id))
		return
		
	static weaponid
	weaponid = read_data(2)
	
	if(!Knife[id] || weaponid != CSW_KNIFE)
		return
		
	change(id)
}

public KnifeSound(id, channel, sample[], Float:volume, Float:attn, flags, pitch)
{
	if(!equal(sample, "weapons/knife_", 14) || !Knife[id])
		return FMRES_IGNORED
			
	if(equal(sample[8], "knife_hitwall", 13))
		PlaySound(id, 1)	
	else
	if(equal(sample[8], "knife_hit", 9))
		switch(random(2))
		{
			case 0:PlaySound(id, 4)
			case 1:PlaySound(id, 5)
		}		
	if(equal(sample[8], "knife_slash", 11)) PlaySound(id, 2)
	if(equal(sample[8], "knife_stab", 10)) PlaySound(id, 3)
	if(equal(sample[8], "knife_deploy", 12)) PlaySound(id, 0)
	return FMRES_SUPERCEDE
}

public TakeDamage_Pre(victim, inflictor, attacker, Float:damage, damagetype)
{
	if(!is_user_alive(attacker))
	return HAM_IGNORED
		
	if(!Knife[attacker] || get_user_weapon(attacker) != CSW_KNIFE)
 	return HAM_IGNORED
	
	new hit, target
	get_user_aiming(attacker, target, hit)

	new bool:head = (hit == HIT_HEAD)
	new Float:mult_dmg = 1.0
	if(pev(attacker, pev_button, IN_ATTACK))
		mult_dmg = head ? PRIM_HEAD_DMG : PRIM_DMG
	else
		mult_dmg = head ? SEC_HEAD_DMG : SEC_DMG
	SetHamParamFloat(4, damage * mult_dmg)
	return HAM_HANDLED
}

public TakeDamage_Post(victim, inflictor, attacker, Float:damage, damagetype)
{
	if(!is_user_alive(attacker) || !is_user_alive(victim)) 
	return HAM_IGNORED
		
	if(!Knife[attacker] || get_user_weapon(attacker) != CSW_KNIFE)
 	return HAM_IGNORED
		
	new Float:Origin[3], Float:Origin2[3], Float:Velocity[3]
	pev(attacker, pev_origin, Origin)
	pev(victim, pev_origin, Origin2)
	xs_vec_sub(Origin2, Origin, Velocity)
	xs_vec_normalize(Velocity, Velocity)
	xs_vec_mul_scalar(Velocity, (KNIFE_KNOCK * 100.0), Velocity)
	if(Velocity[2] <= 100.0)
		Velocity[2] = random_float(150.0, 250.0)
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(TE_BLOODSPRITE);
	engfunc(EngFunc_WriteCoord, Origin2[0])
	engfunc(EngFunc_WriteCoord, Origin2[1])
	engfunc(EngFunc_WriteCoord, Origin2[2])
	write_short(g_Blood[0])
	write_short(g_Blood[1])
	write_byte(77)
	write_byte(BLOOD)
	message_end()
	set_pev(victim, pev_velocity, Velocity)
	return HAM_HANDLED
}

public PreThink(id)
{
	if(!is_user_alive(id)) return HAM_IGNORED
	if(!Knife[id]) return HAM_IGNORED
	if(get_user_weapon(id) != CSW_KNIFE) 
	{
		set_pev(id, pev_gravity, get_cvar_float("zp_human_gravity"))
		set_pev(id, pev_maxspeed, get_cvar_float("zp_human_speed"))
		return HAM_IGNORED
	}
	set_pev(id, pev_gravity, KNIFE_GRAVITY)
	set_pev(id, pev_maxspeed, KNIFE_SPEED)
	return HAM_HANDLED
}

public plugin_precache()
{
	precache_model(v_knife)
	precache_model(p_knife)
	
	static i
	for(i = 0; i <= charsmax(SoundList); i++)
		precache_sound(SoundList)
		
	for(i = 0; i <= charsmax(Blood); i++)
		g_Blood = precache_model(Blood)
}

change(id)
{
	set_pev(id, pev_viewmodel2, v_knife)
	set_pev(id, pev_weaponmodel2, p_knife)
}

stock PlaySound(Ent, Sound)
	engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, SoundList[_:Sound], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
stock is_user_admin(id)
{
	new __flags=get_user_flags(id);
	return (__flags>0 && !(__flags&ADMIN_USER));
}


Nume: [ZP] Extra Items: Axe Knife
Versiune: -
Link oficial: click


Instalare:
1. Fisierul zp_extra_axe.sma il puneti in addons/amxmodx/scripting
2. Fisierul zp_extra_axe.amxx il puneti in addons/amxmodx/plugins
3. Intrati in fisierul addons/amxmodx/configs/plugins-zplague.ini si adaugati la urma:

Code: Select all

zp_extra_axe.amxx
4. Alti pasi necesari....

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):
zp_human_gravity (aici setati ce gravitatie vreti la cutit)
zp_human_speed (aici setati ce viteza vreti la cutit)

Versiunea pentru VIP:
| Afiseaza codul
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>
#include <zmvip>

#pragma tabsize 0

#define NAME		"zp_knife_axe"
#define VERSION		"1.0"
#define AUTHOR		"Tank1229 and Knife Generator"


#define KNIFE_NAME	"Axe Knife"
#define KNIFE_COST	5

#define KNIFE_GRAVITY	0.91
#define KNIFE_SPEED	290.0
#define SEC_DMG		2.5
#define PRIM_DMG	3.5
#define SEC_HEAD_DMG	4.5
#define PRIM_HEAD_DMG	5.5
#define	KNIFE_KNOCK	5
#define BLOOD		3
#define ADMIN		"1"

static const v_knife[] = "models/axe/v_axe.mdl"
static const p_knife[] = "models/axe/p_axe.mdl"

static const SoundList[][] =
{
	"axe/axe_deploy1.wav",	// 0
	"axe/axe_hwall.wav",	// 1
	"axe/axe_slash1.wav",	// 2
	"axe/axe_stab.wav",	// 3
	"axe/axe1.wav",	// 4
	"axe/axe2.wav"	// 5
}

static const Blood[][] =
{
	"sprites/blood.spr",
	"sprites/bloodspray.spr"
}
static g_Blood[sizeof Blood]
static g_Item_Knife
static bool:Knife[33]

public plugin_init()
{
	register_plugin(NAME, VERSION, AUTHOR)
	
	g_Item_Knife = zv_register_extra_item("Axe Knife","Knife VIP", 50, ZV_TEAM_HUMAN)
	
	register_event("CurWeapon", "ChangeModel", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage_Pre", 0)
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage_Post", 1)
	RegisterHam(Ham_Player_PreThink, "player", "PreThink")
	register_forward(FM_EmitSound, "KnifeSound")
}
public zp_user_infected_post(id) Knife[id] = false
public zv_extra_item_selected(id, itemid)
{
	if(itemid == g_Item_Knife)
	{	if(Knife[id]) return ZP_PLUGIN_HANDLED
		new num = str_to_num(ADMIN)
		if(num)
		{
			if(!is_user_admin(id))
			return ZP_PLUGIN_HANDLED
		}
		engclient_cmd(id, "weapon_knife")
		Knife[id] = true
		change(id)
	}
	return PLUGIN_CONTINUE
}

public ChangeModel(id)
{
	if(!is_user_alive(id) || zp_get_user_zombie(id))
		return
		
	static weaponid
	weaponid = read_data(2)
	
	if(!Knife[id] || weaponid != CSW_KNIFE)
		return
		
	change(id)
}

public KnifeSound(id, channel, sample[], Float:volume, Float:attn, flags, pitch)
{
	if(!equal(sample, "weapons/knife_", 14) || !Knife[id])
		return FMRES_IGNORED
			
	if(equal(sample[8], "knife_hitwall", 13))
		PlaySound(id, 1)	
	else
	if(equal(sample[8], "knife_hit", 9))
		switch(random(2))
		{
			case 0:PlaySound(id, 4)
			case 1:PlaySound(id, 5)
		}		
	if(equal(sample[8], "knife_slash", 11)) PlaySound(id, 2)
	if(equal(sample[8], "knife_stab", 10)) PlaySound(id, 3)
	if(equal(sample[8], "knife_deploy", 12)) PlaySound(id, 0)
	return FMRES_SUPERCEDE
}

public TakeDamage_Pre(victim, inflictor, attacker, Float:damage, damagetype)
{
	if(!is_user_alive(attacker))
	return HAM_IGNORED
		
	if(!Knife[attacker] || get_user_weapon(attacker) != CSW_KNIFE)
 	return HAM_IGNORED
	
	new hit, target
	get_user_aiming(attacker, target, hit)

	new bool:head = (hit == HIT_HEAD)
	new Float:mult_dmg = 1.0
	if(pev(attacker, pev_button, IN_ATTACK))
		mult_dmg = head ? PRIM_HEAD_DMG : PRIM_DMG
	else
		mult_dmg = head ? SEC_HEAD_DMG : SEC_DMG
	SetHamParamFloat(4, damage * mult_dmg)
	return HAM_HANDLED
}

public TakeDamage_Post(victim, inflictor, attacker, Float:damage, damagetype)
{
	if(!is_user_alive(attacker) || !is_user_alive(victim)) 
	return HAM_IGNORED
		
	if(!Knife[attacker] || get_user_weapon(attacker) != CSW_KNIFE)
 	return HAM_IGNORED
		
	new Float:Origin[3], Float:Origin2[3], Float:Velocity[3]
	pev(attacker, pev_origin, Origin)
	pev(victim, pev_origin, Origin2)
	xs_vec_sub(Origin2, Origin, Velocity)
	xs_vec_normalize(Velocity, Velocity)
	xs_vec_mul_scalar(Velocity, (KNIFE_KNOCK * 100.0), Velocity)
	if(Velocity[2] <= 100.0)
		Velocity[2] = random_float(150.0, 250.0)
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(TE_BLOODSPRITE);
	engfunc(EngFunc_WriteCoord, Origin2[0])
	engfunc(EngFunc_WriteCoord, Origin2[1])
	engfunc(EngFunc_WriteCoord, Origin2[2])
	write_short(g_Blood[0])
	write_short(g_Blood[1])
	write_byte(77)
	write_byte(BLOOD)
	message_end()
	set_pev(victim, pev_velocity, Velocity)
	return HAM_HANDLED
}

public PreThink(id)
{
	if(!is_user_alive(id)) return HAM_IGNORED
	if(!Knife[id]) return HAM_IGNORED
	if(get_user_weapon(id) != CSW_KNIFE) 
	{
		set_pev(id, pev_gravity, get_cvar_float("zp_human_gravity"))
		set_pev(id, pev_maxspeed, get_cvar_float("zp_human_speed"))
		return HAM_IGNORED
	}
	set_pev(id, pev_gravity, KNIFE_GRAVITY)
	set_pev(id, pev_maxspeed, KNIFE_SPEED)
	return HAM_HANDLED
}

public plugin_precache()
{
	precache_model(v_knife)
	precache_model(p_knife)
	
	static i
	for(i = 0; i <= charsmax(SoundList); i++)
		precache_sound(SoundList)
		
	for(i = 0; i <= charsmax(Blood); i++)
		g_Blood = precache_model(Blood)
}

change(id)
{
	set_pev(id, pev_viewmodel2, v_knife)
	set_pev(id, pev_weaponmodel2, p_knife)
}

stock PlaySound(Ent, Sound)
	engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, SoundList[_:Sound], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
stock is_user_admin(id)
{
	new __flags=get_user_flags(id);
	return (__flags>0 && !(__flags&ADMIN_USER));
}

Imagini: Nu se vede prea bine dar asta e
Image
Image
Leul si tigru sunt mai puternici ca lupul,dar lupul la circ nu participa.
Post Reply

Return to “AmxModX”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests