/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#define PLUGIN "Anti-No Flash"
#define VERSION "1.0.7"
#define AUTHOR "Rul4"
new Float:g_flashed_until[33];
new pcv_on;
new pcv_demo;
new pcv_delay;
new pcv_ignore;
new g_msg_screen_fade;
new g_isBot[33];
new g_isAlive[33];
new CsTeams:g_team[33];
new g_plugin_on, CsTeams:g_ignore;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_cvar("anti_noflash_version", VERSION, FCVAR_SERVER);
pcv_on = register_cvar ("anti_noflash_on", "1");
pcv_demo = register_cvar ("anti_noflash_demo", "0");
pcv_delay = register_cvar ("anti_noflash_delay", "0.0");
pcv_ignore = register_cvar ("anti_noflash_ignore_team", "0");
register_event("ScreenFade", "event_flashed", "b", "7=255");
register_forward(FM_AddToFullPack, "fw_addtofullpack", 0);
g_msg_screen_fade = get_user_msgid("ScreenFade");
//Just for caching purposes
RegisterHam( Ham_Spawn, "player", "fw_PlayerSpawn", 1);
RegisterHam( Ham_Killed, "player", "fw_PlayerKilled", 1);
}
public event_flashed(id){
//Cache this value so it is not called in AddToFullPack
g_plugin_on = get_pcvar_num(pcv_on);
if (!g_plugin_on || !is_user_connected(id) )
return PLUGIN_CONTINUE;
g_ignore = CsTeams:get_pcvar_num(pcv_ignore);
//Up to when this player should be flashed
g_flashed_until[id] = read_data(2)/4096.0 + get_gametime() + get_pcvar_float(pcv_delay);
if(get_pcvar_num(pcv_demo)){
client_print(id, print_chat, "Gametime: %0.2f - Flashed until: %0.2f",get_gametime(),g_flashed_until[id]);
remove_flash(id);
}
return PLUGIN_CONTINUE;
}
public fw_addtofullpack(es, e, ent, host, flags, player, set){
//Bots and dead players get all the info
if (!g_plugin_on || !g_isAlive[host] || g_isBot[host])
return FMRES_IGNORED;
//Workaround for HnS plugin: ignore the anti no-flash effect according to the user's team
if(g_ignore==g_team[host])
return FMRES_IGNORED;
if(player)
{
//If it is a player, make sure it is not myself and it is alive
if(!g_isAlive[ent] || ent == host)
return FMRES_IGNORED;
} else
if(pev_valid(ent))
{
//If it is not a player, find out if this is a grenade
static Classname[33];
pev(ent, pev_classname, Classname,32);
new is_grenade = equal(Classname,"grenade");
//Skip this ent if it is not a grenade but skip own grenades
//so cheaters don't realize they are flashed when they throw one
if(!is_grenade || pev(ent, pev_owner)==host)
return FMRES_IGNORED;
} else
return FMRES_IGNORED;
//If the player is flashed, strip other player's information
if(get_gametime() < g_flashed_until[host])
{
//client_print(host, print_chat, "Gametime: %0.2f - Flashed until: %0.2f",get_gametime(),g_flashed_until[host]);
forward_return(FMV_CELL, 0);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public remove_flash(id){
//Remove flashing form target player for testing purposes
message_begin(MSG_ONE_UNRELIABLE, g_msg_screen_fade, {0, 0, 0}, id);
write_short(0);
write_short(0);
write_short(0);
write_byte(0);
write_byte(0);
write_byte(0);
write_byte(0);
message_end();
}
//Caching functions
public client_putinserver(id)
{
g_isBot[id] = is_user_bot(id);
}
public client_disconnect(id)
{
g_isAlive[id] = false;
g_isBot[id] = false;
}
public fw_PlayerSpawn(id)
{
if( is_user_alive(id) )
{
g_isAlive[id] = 1;
g_team[id] = cs_get_user_team(id);
}
else
{
g_isAlive[id] = 0;
g_team[id] = CS_TEAM_UNASSIGNED
}
}
public fw_PlayerKilled(id)
{
g_isAlive[id] = false;
}