#include <amxmodx>
#include <reapi>
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
#endif
#define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2) %1 |= (1 << (%2 & 31))
#define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31))
#define ALPHA 100
enum color_e { R, G, B }
new const FADE_COLORS[][color_e] =
{
{0, 0, 255}, // blue
{0, 255, 0}, // green
{255, 0, 0} // red
}
new bw_isBot,bw_isConnected;
public plugin_init()RegisterHookChain(RG_CSGameRules_PlayerKilled, "CSGameRules_PlayerKilled", .post = true)
public client_putinserver(pClient){
clr_bit(bw_isBot,pClient);
if(is_user_bot(pClient) || is_user_hltv(pClient))set_bit(bw_isBot,pClient);
set_bit(bw_isConnected,pClient);
}
public client_disconnected(id){//Fakemeta - better
clr_bit(bw_isBot,id);
clr_bit(bw_isConnected,id);
}
public CSGameRules_PlayerKilled(const pPlayer, const pKiller)
{
if(pPlayer == pKiller)return;
if(get_bit(bw_isBot,pPlayer))return;
__UTIL_ScreenFade(pPlayer,FADE_COLORS[2],ALPHA);
if(pKiller>32||pKiller<=0||!get_bit(bw_isConnected,pKiller))return;
if(get_member(pPlayer, m_bHeadshotKilled))__UTIL_ScreenFade(pPlayer,FADE_COLORS[1],ALPHA);
else __UTIL_ScreenFade(pPlayer,FADE_COLORS[0],ALPHA);
}
stock __UTIL_ScreenFade(const pPlayer, iColor[color_e], iAlpha, Float:flFxTime = 1.0, Float:flHoldTime = 1.0){
/* if(IsBlind(pPlayer))return; */
static iMsgIdScreenFade;if(!iMsgIdScreenFade)iMsgIdScreenFade = get_user_msgid("ScreenFade");
message_begin(MSG_ONE, iMsgIdScreenFade, .player = pPlayer);
write_short(FixedUnsigned16(flFxTime));
write_short(FixedUnsigned16(flHoldTime));
write_short(0x0000);
write_byte(iColor[R]);
write_byte(iColor[G]);
write_byte(iColor[B]);
write_byte(iAlpha);
message_end();
}
stock FixedUnsigned16(Float:flValue, iScale = (1 << 12)){return clamp(floatround(flValue * iScale), 0, 0xFFFF);}
/* stock bool:IsBlind(const pPlayer)return bool:(Float:get_member(pPlayer, m_blindStartTime) + Float:get_member(pPlayer, m_blindFadeTime) >= get_gametime()) */