#include < amxmodx >
#include < reapi >
/* *** SETTINGS *** */
//#define NOROUND //Для серверов с бесконечным раундом, раскоментируйте
#define ADMIN ADMIN_BAN //Функция плагина будет доступна только людям с этим флагом [закоментируйте, чтобы была доступна всем игрокам]
#define HUD_COLOR 0, 255, 0 //Цвет худ сообщения (R, G, B)
#define HUD_COORDS -1.0, 0.7 //Координаты худ сообщения (X (0.0 слева, 1.0 справа, -1.0 по центру), Y (0.0 сверху, 1.0 снизу, -1.0 по центру))
const Float: TIME_UPD = 0.5; //Раз в сколько секунд будет обновлять инфу о флеше? [меньше время - больше нагрузка]
const MAX_POLOS = 20; //Сколько полосочек в худе будет ([|||||||])
/* *** SETTINGS *** */
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
const MAX_PLAYERS = 32;
#endif
#if AMXX_VERSION_NUM < 190
#define arrasyet_f arrayset_float
#else
#define arrasyet_f arrayset
#endif
const TASK = 222;
const TASK2 = 333;
const Float: MIN_ALPHA = 1.0;
const MAX_TEXT_LEN = MAX_POLOS + 64;
#if defined ADMIN
const HC_WHAT = HC_CONTINUE;
#else
const HC_WHAT = HC_SUPERCEDE;
#endif
new gSyncHud, Float: TIME_DEL;
new Float:fAlpha[MAX_PLAYERS + 1], Float:fMinus[MAX_PLAYERS + 1];
public plugin_init(){
register_plugin("NoSpectFlash", "v3.1 [reapi]", "PAffAEJIkA :3");
#if defined ADMIN
RegisterHookChain(RG_CBasePlayer_Observer_IsValidTarget, "ObserverTarget", true);
RegisterHookChain(RG_PlayerBlind, "PlayerBlind", true);
#else
RegisterHookChain(RG_PlayerBlind, "PlayerBlind", false);
#endif
#if !defined NOROUND
RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStart");
#endif
RegisterHookChain(RG_CBasePlayer_Killed, "KillPlayer", true);
gSyncHud = CreateHudSyncObj();
TIME_DEL = 1.0 / TIME_UPD;
}
#if !defined NOROUND
public RoundStart()
arrasyet_f(fAlpha, 0.0, sizeof fAlpha);
#endif
public client_disconnected(id)
clear(id);
public KillPlayer(const victim, killer, gib){
if(fAlpha[victim] > MIN_ALPHA)
clear(victim);
}
public clear(id){
remove_task(id + TASK);
fAlpha[id] = 0.0;
fMinus[id] = 0.0;
}
#if defined ADMIN
public ObserverTarget(const index, iPlayerIndex, bool:bSameTeam){
if(fAlpha[iPlayerIndex] <= MIN_ALPHA)
return;
if(~get_user_flags(index) & ADMIN)
return;
set_task(0.1, "kostil", index + TASK2); //nu tut ya nu xz v obshem, mb you know how delete this task?
}
public kostil(id) ScreenFade(id-TASK2);
#endif
public PlayerBlind(const index, const inflictor, const attacker, const Float:fadeTime, const Float:fadeHold, const alpha, Float:color[3]){
if(fAlpha[index] > float(alpha))
return HC_WHAT;
fAlpha[index] = float(alpha);
fMinus[index] = alpha / fadeTime / TIME_DEL;
#if defined ADMIN
static pl[32], cnt, text[MAX_TEXT_LEN];
get_players(pl, cnt, "bch");
if(cnt){
get_text(index, text, charsmax(text));
for(new i; i < cnt; i ++){
if(~get_user_flags(pl[i]) & ADMIN || get_entvar(pl[i], var_iuser2) != index)
continue;
ScreenFade(pl[i]);
send_msg(pl[i], text);
}
}
#else
ScreenFade(index, fadeTime, fadeHold, 0x0000 /*FFADE_IN*/, floatround(color[0]), floatround(color[1]), floatround(color[2]), alpha);
#endif
new tid = index + TASK;
if(!task_exists(tid)){
#if !defined ADMIN
go_mess(index);
#endif
set_task(TIME_UPD, "task_msg", tid, .flags = "b");
}
return HC_WHAT;
}
public task_msg(id){
id -= TASK;
if((fAlpha[id] -= fMinus[id]) <= MIN_ALPHA)
clear(id);
else
go_mess(id);
}
public go_mess(id){
static pl[32], cnt, text[MAX_TEXT_LEN];
get_players(pl, cnt, "bch");
if(cnt){
get_text(id, text, charsmax(text));
for(new i; i < cnt; i ++){
#if defined ADMIN
if(~get_user_flags(pl[i]) & ADMIN)
continue;
#endif
if(get_entvar(pl[i], var_iuser2) == id)
send_msg(pl[i], text);
}
}
}
public get_text(id, txt[], len){
static Float: percent, polos, iLen;
percent = fAlpha[id] / 255.0, polos = floatround(percent * MAX_POLOS);
percent *= 100;
iLen = format(txt, len, "Игрок ослеплен^n[");
for(new i; i < MAX_POLOS; i ++)
iLen += format(txt[iLen], len - iLen, (i < polos) ? "|" : ".");
iLen = format(txt[iLen], len - iLen, "] %.0f%%", percent);
}
public send_msg(player, text[]){
set_hudmessage(HUD_COLOR, HUD_COORDS, 0, 0.0, TIME_UPD, 0.0, 0.0, -1);
ClearSyncHud(player, gSyncHud);
ShowSyncHudMsg(player, gSyncHud, text);
}
stock ScreenFade(id, Float:duration = 0.0, Float:holdtime = 0.0, flags = (1<<0), r = 0, g = 0, b = 0, alpha = 0){
static msg_screenfade;
if(msg_screenfade || (msg_screenfade = get_user_msgid("ScreenFade"))){
message_begin(MSG_ONE, msg_screenfade, .player = id);
write_short(UTIL_FixedUnsigned16(duration, 1<<12));
write_short(UTIL_FixedUnsigned16(holdtime, 1<<12));
write_short(flags);
write_byte(r);
write_byte(g);
write_byte(b);
write_byte(alpha);
message_end();
}
}
stock UTIL_FixedUnsigned16(Float:Value, Scale)
return clamp(floatround(Value * Scale), 0, 0xFFFF);
stock arrayset_float(Float: arr[], Float: value, size){
for(new i; i < size; i ++)
arr[i] = value;
}
#include < amxmodx >
#include < reapi >
/* *** SETTINGS *** */
//#define NOROUND //Для серверов с бесконечным раундом, раскоментируйте
#define ADMIN ADMIN_BAN //Функция плагина будет доступна только людям с этим флагом [закоментируйте, чтобы была доступна всем игрокам]
#define HUD_COLOR 0, 255, 0 //Цвет худ сообщения (R, G, B)
#define HUD_COORDS -1.0, 0.7 //Координаты худ сообщения (X (0.0 слева, 1.0 справа, -1.0 по центру), Y (0.0 сверху, 1.0 снизу, -1.0 по центру))
const Float: TIME_UPD = 0.5; //Раз в сколько секунд будет обновлять инфу о флеше? [меньше время - больше нагрузка]
const MAX_POLOS = 20; //Сколько полосочек в худе будет ([|||||||])
//#define NO_TEAM_FLASH ADMIN_ALL //Eto ne bylo protestirovano <3
/*
Если на Вашем сервере нет плагина, позволяющего не флешить тиммейтов, дальше можете и не читать,
а если есть, то сначала прочитайте и уже после разкоментируйте, и укажите нужный Вам флаг
========================================== let's go ==========================================
Здесь нужно указать флаг людей, которых не слепит от флешек тиммейтов.
(Если у Вас это работает на всех тиммейтов, укажите ADMIN_ALL)
======================================= NoTeamFlash end =======================================
*/
/* *** SETTINGS *** */
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
const MAX_PLAYERS = 32;
#endif
#if AMXX_VERSION_NUM < 190
#define arrasyet_f arrayset_float
#else
#define arrasyet_f arrayset
#endif
const TASK = 222;
const TASK2 = 333;
const Float: MIN_ALPHA = 1.0;
const MAX_TEXT_LEN = MAX_POLOS + 64;
#if defined ADMIN
const HC_WHAT = HC_CONTINUE;
#else
const HC_WHAT = HC_SUPERCEDE;
#endif
new gSyncHud, Float: TIME_DEL;
new Float:fAlpha[MAX_PLAYERS + 1], Float:fMinus[MAX_PLAYERS + 1];
public plugin_init(){
register_plugin("NoSpectFlash", "v3.2 [reapi]", "PAffAEJIkA :3");
#if defined ADMIN
RegisterHookChain(RG_CBasePlayer_Observer_IsValidTarget, "ObserverTarget", true);
RegisterHookChain(RG_PlayerBlind, "PlayerBlind", true);
#else
RegisterHookChain(RG_PlayerBlind, "PlayerBlind", false);
#endif
#if !defined NOROUND
RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStart");
#endif
RegisterHookChain(RG_CBasePlayer_Killed, "KillPlayer", true);
gSyncHud = CreateHudSyncObj();
TIME_DEL = 1.0 / TIME_UPD;
}
#if !defined NOROUND
public RoundStart()
arrasyet_f(fAlpha, 0.0, sizeof fAlpha);
#endif
public client_disconnected(id)
clear(id);
public KillPlayer(const victim, killer, gib){
if(fAlpha[victim] > MIN_ALPHA)
clear(victim);
}
public clear(id){
remove_task(id + TASK);
fAlpha[id] = 0.0;
fMinus[id] = 0.0;
}
#if defined ADMIN
public ObserverTarget(const index, iPlayerIndex, bool:bSameTeam){
if(fAlpha[iPlayerIndex] <= MIN_ALPHA)
return;
if(~get_user_flags(index) & ADMIN)
return;
set_task(0.1, "kostil", index + TASK2); //nu tut ya nu xz v obshem, mb you know how delete this task?
}
public kostil(id) ScreenFade(id-TASK2);
#endif
public PlayerBlind(const index, const inflictor, const attacker, const Float:fadeTime, const Float:fadeHold, const alpha, Float:color[3]){
if(fAlpha[index] > float(alpha))
return HC_WHAT;
#if defined NO_TEAM_FLASH
#if NO_TEAM_FLASH == ADMIN_ALL
if(get_member(index, m_iTeam) == get_member(attacker, m_iTeam))
return HC_CONTINUE;
#else
if(get_user_flags(index) & NO_TEAM_FLASH && get_member(index, m_iTeam) == get_member(attacker, m_iTeam))
return HC_CONTINUE;
#endif
#endif
fAlpha[index] = float(alpha);
fMinus[index] = alpha / fadeTime / TIME_DEL;
#if defined ADMIN
static pl[32], cnt, text[MAX_TEXT_LEN];
get_players(pl, cnt, "bch");
if(cnt){
get_text(index, text, charsmax(text));
for(new i; i < cnt; i ++){
if(~get_user_flags(pl[i]) & ADMIN || get_entvar(pl[i], var_iuser2) != index)
continue;
ScreenFade(pl[i]);
send_msg(pl[i], text);
}
}
#else
ScreenFade(index, fadeTime, fadeHold, 0x0000 /*FFADE_IN*/, floatround(color[0]), floatround(color[1]), floatround(color[2]), alpha);
#endif
new tid = index + TASK;
if(!task_exists(tid)){
#if !defined ADMIN
go_mess(index);
#endif
set_task(TIME_UPD, "task_msg", tid, .flags = "b");
}
return HC_WHAT;
}
public task_msg(id){
id -= TASK;
if((fAlpha[id] -= fMinus[id]) <= MIN_ALPHA)
clear(id);
else
go_mess(id);
}
public go_mess(id){
static pl[32], cnt, text[MAX_TEXT_LEN];
get_players(pl, cnt, "bch");
if(cnt){
get_text(id, text, charsmax(text));
for(new i; i < cnt; i ++){
#if defined ADMIN
if(~get_user_flags(pl[i]) & ADMIN)
continue;
#endif
if(get_entvar(pl[i], var_iuser2) == id)
send_msg(pl[i], text);
}
}
}
public get_text(id, txt[], len){
static Float: percent, polos, iLen;
percent = fAlpha[id] / 255.0, polos = floatround(percent * MAX_POLOS);
percent *= 100;
iLen = format(txt, len, "Игрок ослеплен^n[");
for(new i; i < MAX_POLOS; i ++)
iLen += format(txt[iLen], len - iLen, (i < polos) ? "|" : ".");
iLen = format(txt[iLen], len - iLen, "] %.0f%%", percent);
}
public send_msg(player, text[]){
set_hudmessage(HUD_COLOR, HUD_COORDS, 0, 0.0, TIME_UPD, 0.0, 0.0, -1);
ClearSyncHud(player, gSyncHud);
ShowSyncHudMsg(player, gSyncHud, text);
}
stock ScreenFade(id, Float:duration = 0.0, Float:holdtime = 0.0, flags = (1<<0), r = 0, g = 0, b = 0, alpha = 0){
static msg_screenfade;
if(msg_screenfade || (msg_screenfade = get_user_msgid("ScreenFade"))){
message_begin(MSG_ONE, msg_screenfade, .player = id);
write_short(UTIL_FixedUnsigned16(duration, 1<<12));
write_short(UTIL_FixedUnsigned16(holdtime, 1<<12));
write_short(flags);
write_byte(r);
write_byte(g);
write_byte(b);
write_byte(alpha);
message_end();
}
}
stock UTIL_FixedUnsigned16(Float:Value, Scale)
return clamp(floatround(Value * Scale), 0, 0xFFFF);
stock arrayset_float(Float: arr[], Float: value, size){
for(new i; i < size; i ++)
arr[i] = value;
}