Code:
#include <amxmodx>
#include <fakemeta>
#include <tsfun>
#include <tsx>
#include <engine>
#define PLUGIN "Brass Knuckles"
#define VERSION "1.0"
#define AUTHOR "Calimaw/stupok69/Da_Ghost/XxAvalanchexX"
new bool:g_brassknuckles[33]
new bool:g_is_in_kungfu[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")
register_event("DeathMsg", "Event_Death", "a")
register_clcmd("say /brassknuckles", "cmdBrassKnuckles")
register_forward(FM_EmitSound, "EmitSound")
}
public plugin_precache()
{
precache_sound("bknuckles/hit_01.wav")
}
public client_connect(id)
{
g_brassknuckles[id] = false
g_is_in_kungfu[id] = true
}
public Event_Death()
{
new id = read_data(2)
g_brassknuckles[id] = false
g_is_in_kungfu[id] = true
}
public WeaponInfo_function(msg_id, msg_dest, msg_entity)
{
if(!get_msg_arg_int(1))
{
g_is_in_kungfu[msg_dest] = true
}
else
{
g_is_in_kungfu[msg_dest] = false
}
}
public cmdBrassKnuckles(id)
{
if(!is_user_alive(id))
client_print(id, print_chat, "The dead cannot buy items!")
else if(g_brassknuckles[id])
client_print(id, print_chat, "What good would that do?")
else
{
g_brassknuckles[id] = true
client_print(id, print_chat, "You bought a pair of brass knuckles!")
}
return PLUGIN_HANDLED
}
public EmitSound(id, channel, sample[], Float:volume, Float:att, flags, pitch)
{
if(!is_user_alive(id))
return FMRES_IGNORED
if(equal(sample,"player/kungfuhit.wav"))
{
new attacker = get_user_attacker(id);
if(is_user_connected(attacker) && attacker != id
&& g_brassknuckles[attacker] && g_is_in_kungfu[attacker])
{
emit_sound(id,channel,"bknuckles/hit_01.wav",volume,att,flags,pitch+random_num(-30,60));
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED
}
public client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{
if(!g_brassknuckles[attacker] || (wpnindex != 0 && wpnindex != TSW_KUNG_FU))
return PLUGIN_CONTINUE;
extra_damage(attacker,victim,random_float(18.0,36.0),"Brass Knuckles");
new Float:punch[3];
punch[0] = random_float(-30.0,30.0);
punch[1] = random_float(-15.0,15.0);
punch[2] = random_float(-20.0,20.0);
set_pev(victim,pev_punchangle,punch);
set_pev(victim,pev_fixangle,1);
return PLUGIN_CONTINUE;
}
public extra_damage(attacker,victim,Float:damage,weapon[])
{
if(pev(victim,pev_health) - damage <= 0.0)
{
new Float:frags;
pev(attacker,pev_frags,frags);
user_silentkill(victim);
set_pev(attacker,pev_frags,frags+1.0);
message_begin(MSG_ALL,get_user_msgid("DeathMsg"));
write_byte(attacker);
write_byte(victim);
write_string(weapon);
message_end();
pev(attacker,pev_frags,frags);
message_begin(MSG_ALL,get_user_msgid("ScoreInfo"));
write_byte(attacker);
write_short(floatround(frags));
write_short(get_user_deaths(attacker));
write_short(0);
write_short(0);
message_end();
pev(victim,pev_frags,frags);
message_begin(MSG_ALL,get_user_msgid("ScoreInfo"));
write_byte(victim);
write_short(floatround(frags));
write_short(get_user_deaths(victim));
write_short(0);
write_short(0);
message_end();
}
else fakedamage(victim,weapon,damage,0);
}
This is working fairly well for the most part, except that the damage, and sound will play on the 2nd hit, never the first. The hit_01.wav seems to be working normally, altho it takes a while to kick in or something, Im not sure. It's a bit strange.
The next step is to make it so that brass knuckles do not effect kicks (+attack2?) and stunts moves. Im still disecting the code to learn from the bits Avalanche added.