Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#define PLUGIN "Advanced Bullet Damage"
#define VERSION "2.0" ///1.0 to 2.0 is Half-Life port along with SFX. Both by SPiNX.
#define AUTHOR "Sn!ff3r & SPiNX"
//Conners contstant
new const Float:g_flCoords[][] =
{
{0.50, 0.40},
{0.56, 0.44},
{0.60, 0.50},
{0.56, 0.56},
{0.50, 0.60},
{0.44, 0.56},
{0.40, 0.50},
{0.44, 0.44}
}
new g_iPlayerPos[MAX_PLAYERS+1]
new g_iMaxPlayers
new g_pCvarEnabled
//end conner's constant
new g_type, g_enabled, g_recieved, bool:g_showrecieved, g_hudmsg1, g_hudmsg2
public plugin_init()
{
//conner mccloud
g_pCvarEnabled = register_cvar("bullet_damage", "1")
register_event("Damage", "Event_Damage", "b", "2>0", "3=0")
g_iMaxPlayers = get_maxplayers()
//conner end
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")
if ( cstrike_running() )register_event("HLTV", "on_new_round", "a", "1=0", "2=0");
g_type = register_cvar("amx_bulletdamage","1")
g_recieved = register_cvar("amx_bulletdamage_recieved","1")
g_hudmsg1 = CreateHudSyncObj()
g_hudmsg2 = CreateHudSyncObj()
/////*//*//*/////
///*//half-life/*///
/////*//*//*////
/*HL PORT*/
register_event("Damage", "got_hit", "b")
register_cvar("hn_human","1") //fadescreen or 'hit notify' from human attacker's landed hits.
register_cvar("hn_npc", "1") //fadescreen from bot or npc attacker's landed hits.
register_cvar("hn_dam_hum","1") //screenshake effect on or off from human attacker's landed hits.
register_cvar("hn_dam_npc","1") //screenshake effect on or off from bot attacker's landed hits.
register_cvar("hn_cry","1") //victim cries out each time you shoot them and land a shot! Different sound if human or bot. Human's squeek and bots make a short cowardly scientist cry.
if ( cstrike_running() ) return;
else
{
g_enabled = get_pcvar_num(g_type)
if(get_pcvar_num(g_recieved)) g_showrecieved = true
}
/*HL PORT*/
/////*//*//*/////
///*//halflife/*///
/////*//*//*////
}
public on_new_round()
{
g_enabled = get_pcvar_num(g_type)
if(get_pcvar_num(g_recieved)) g_showrecieved = true
}
//Conner's
public Event_Damage( iVictim )
{
if( get_pcvar_num(g_pCvarEnabled) && (read_data(4) || read_data(5) || read_data(6)) )
{
new id = get_user_attacker(iVictim)
if( (1 <= id <= g_iMaxPlayers) && is_user_connected(id) )
{
new iPos = ++g_iPlayerPos[id]
if( iPos == sizeof(g_flCoords) )
{
iPos = g_iPlayerPos[id] = 0
}
set_hudmessage(0, 40, 80, Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
show_hudmessage(id, "%d", read_data(2))
}
}
}
//Conner's
///arcade classic effects
#include <engine>
#include <fun>
public plugin_precache()
{
precache_sound("misc/ni1.wav")
precache_sound("scientist/scream19.wav")
}
public on_damage(id)
{
if(g_enabled)
{
static attacker; attacker = get_user_attacker(id)
static damage; damage = read_data(2)
if(g_showrecieved)
{
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1)
ShowSyncHudMsg(id, g_hudmsg2, "%i^n", damage)
}
if(is_user_connected(attacker))
{
switch(g_enabled)
{
case 1: {
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(attacker, g_hudmsg1, "%i^n", damage)
}
case 2: {
if(fm_is_ent_visible(attacker,id))
{
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(attacker, g_hudmsg1, "%i^n", damage)
}
}
}
}
}
}
public got_hit(id)
{
if(!is_user_bot(id) && is_user_alive(id) && is_user_connected(id))
{
if(get_cvar_num("hn_npc")) {
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenFade"),{0,0,0},id)
write_short(300) // was 0 //duration
write_short(350) //hold time
write_short(0x0001) //flags
write_byte(0) //rgb alpha
write_byte(119)
write_byte(190)
write_byte(300)
message_end()
}
if(get_cvar_num("hn_dam_npc")) {
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenShake"),{0,0,0},id)
write_short(5000)
write_short(1000)
write_short(1000)
message_end()
}
if(get_cvar_num("hn_cry")) {
new attacker=get_user_attacker(id)
if(is_user_connected(attacker)) {
client_cmd(attacker,"spk scientist/scream19.wav")
return PLUGIN_HANDLED
}
}
}
if(is_user_alive(id) && is_user_connected(id)) {
if(get_cvar_num("hn_human")) {
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenFade"),{0,0,0},id)
write_short(300) // was 0 //duration
write_short(350) //hold time
write_short(0x0001) //flags
write_byte(248) //rgb alpha
write_byte(24)
write_byte(148)
write_byte(150)
message_end()
}
if(get_cvar_num("hn_dam_human")) {
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenShake"),{0,0,0},id)
write_short(0)
write_short(10000)
write_short(1000)
message_end()
}
if(get_cvar_num("hn_cry")) {
new attacker=get_user_attacker(id)
if(is_user_connected(attacker)) {
client_cmd(attacker,"spk misc/ni1.wav")
}
}
}
return PLUGIN_HANDLED
}