It works, though, 5 feet(?) aint a far range. ^^
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
new const PLUGIN[] = "Explosive Flashbangs"
new const VERSION[] = "0.1.0"
new const AUTHOR[] = "SAMURAI"
#define TE_EXPLOSION 3
new explode;
new g_MaxPlayers
new pCvar;
new g_msgScreenFade
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
pCvar = register_cvar("explosive_flashbangs","1");
register_forward(FM_EmitSound,"fw_emitsound");
g_MaxPlayers = get_maxplayers()
register_event("ScreenFade", "event_ScreenFade", "b", "4=255", "5=255", "6=255")
g_msgScreenFade = get_user_msgid("ScreenFade")
}
public event_ScreenFade(id) {
if ( ! get_pcvar_num(pCvar) )
return PLUGIN_CONTINUE
message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, {0,0,0}, id)
write_short(read_data(1))
write_short(read_data(2))
write_short(read_data(3))
write_byte(0)
write_byte(0)
write_byte(0)
write_byte(0)
message_end()
}
public plugin_precache()
explode = precache_model("sprites/explode1.spr");
public fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch) {
if( get_pcvar_num(pCvar) && ( equali(sample,"weapons/flashbang-1.wav") || equali(sample,"weapons/flashbang-2.wav") ) )
flashbang_explode(entity);
return FMRES_IGNORED;
}
public flashbang_explode(greindex) {
new Float:origin[3];
pev(greindex,pev_origin,origin);
message_begin( MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(TE_EXPLOSION);
write_coord(floatround(origin[0]));
write_coord(floatround(origin[1]));
write_coord(floatround(origin[2]));
write_short(explode);
write_byte(80);
write_byte(10);
write_byte(0);
message_end();
flashbang_damage(origin, "flashbang", 50.0, 300.0)
}
public flashbang_damage(Float:origin[3], const classname[], Float:damage, Float:range) {
new Float:pOrigin[3]
new Float:dist
new Float:tmpdmg
for ( new i = 1 ; i < g_MaxPlayers ; i++) {
if ( is_user_alive(i) ) {
pev(i,pev_origin,pOrigin)
dist = get_distance_f(origin,pOrigin)
if ( dist <= range ) {
tmpdmg = damage - ( damage / range ) * dist
fm_fakedamage(i, classname, tmpdmg, DMG_BLAST)
}
}
}
}