LamdaProCS - Gaming Community - Forum

Full Version: Anti Team Flash
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Need anti team flash plugin . Bug free
PHP Code:
#include <amxmodx>

new g_msgScreenFadegrenade[32], last
new Float:g_gametimeg_owner

public plugin_init()
{
    
register_plugin("No Team Flash""0.2""Krotal")
    
register_cvar("no_team_flash""1")
    
register_event("ScreenFade""eventFlash""be""4=255""5=255""6=255""7>199")
    
register_event("TextMsg""fire_in_the_hole""b""2&#Game_radio""4&#Fire_in_the_hole")
    
register_event("TextMsg""fire_in_the_hole2""b""3&#Game_radio""5&#Fire_in_the_hole")
    
register_event("99""grenade_throw""b")
    
g_msgScreenFade get_user_msgid("ScreenFade")
}

public 
eventFlash(id)
{
 
 new Float:gametime get_gametime()
 
 if(gametime != g_gametime)
 
 {
 
   g_owner get_grenade_owner()
 
   g_gametime gametime
  
}
 
 if(is_user_connected(g_owner) && g_owner != id && get_user_team(id) == get_user_team(g_owner))
 
 {
 
     message_begin(MSG_ONEg_msgScreenFade, {0,0,0}, id)
 
     write_short(1)
 
     write_short(1)
 
     write_short(1)
 
     write_byte(0)
 
     write_byte(0)
 
     write_byte(0)
 
     write_byte(255)
 
     message_end()
    }
}

public 
grenade_throw()
{
    if(
read_datanum() < 2)
 
   return PLUGIN_HANDLED_MAIN

    
if(read_data(1) == 11 && (read_data(2) == || read_data(2) == 1))
    {
        
add_grenade_owner(last)
    }

    return 
PLUGIN_CONTINUE
}

public 
fire_in_the_hole()
{
    new 
name[32]
    
read_data(3name31)
    
last get_user_index(name)

    return 
PLUGIN_CONTINUE
}

public 
fire_in_the_hole2()
{
    new 
name[32]
    
read_data(4name31)
    
last get_user_index(name)

    return 
PLUGIN_CONTINUE
}

add_grenade_owner(owner)
{
    for(new 
032i++)
 
 {
        if(
grenade[i] == 0)
 
   {
            
grenade[i] = owner
            
return
        }
    }
}

get_grenade_owner()
{
    new 
which grenade[0]
    for(new 
132i++)
 
 {
        
grenade[i-1] = grenade[i]
    }
    
grenade[31] = 0
    
return which


Includes:
#include <amxmodx>


Cvar:
no_team_flash "1"
0: Disables the plugin
1: Enables the plugin

Sma file: http://www91.zippyshare.com/v/bcjhD7b6/file.html

Try plugin and tell Smile
(not sure if it have bugs, most of anti tm flash don't works every time)
Code:
#include <amxmodx>
#include <fakemeta>

//x>0 messages, x>1 treat self as a different member of the same team
#define FLASH_DEBUG 0

//new enabled_cvar;
new g_msgScreenFade, grenade[32], last;
new Float:g_gametime, g_owner;
new g_sync_check_data = 0; //note: after 1 hole is two throws, the second throw calls add

new Float:g_gametime2;
new temp_cvar;

new bool:g_track[33] = false;
new bool:g_track_enemy = false;

public plugin_init()
{
register_plugin("No Team Flash", "0.2", "KRoTaL")
/*enabled_cvar = */
register_cvar("no_team_flash", "2");
register_event("ScreenFade", "eventFlash", "be", "4=255", "5=255", "6=255", "7>199")
register_event("TextMsg", "fire_in_the_hole", "b", "2&#Game_radio", "4&#Fire_in_the_hole")
register_event("TextMsg", "fire_in_the_hole2", "b", "3&#Game_radio", "5&#Fire_in_the_hole")
register_event("99", "grenade_throw", "b")
register_forward(FM_EmitSound,"fw_emitsound");
set_task( 2.0, "bad_fix2",_,_,_, "b" )
g_msgScreenFade = get_user_msgid("ScreenFade")
}

//if no nades have been thrown for a long time, clear the nade owner list
//keep in mind that nades can also get destroyed at end of round
public bad_fix2()
{
new Float:gametime = get_gametime()
if(gametime - g_gametime2 > 2.5)
{
for(new i = 0; i < 32; i++)
{
grenade[i] = 0
}
}
}

public eventFlash(id)
{
 new Float:gametime = get_gametime()
 if(gametime != g_gametime)
 {
g_owner = get_grenade_owner()
g_gametime = gametime
temp_cvar = get_cvar_num("no_team_flash")
for(new i = 0; i < 33; i++)
{
g_track[i] = false
}
g_track_enemy = false
//if(temp_cvar == 2)
// set_task(0.01, "flash_delay")
 }
 if(is_user_connected(g_owner) && get_user_team(id) != get_user_team(g_owner))
g_track_enemy = true
 #if FLASH_DEBUG > 1
 if(is_user_connected(g_owner) && get_user_team(id) == get_user_team(g_owner))
 #else
 if(g_owner != id && is_user_connected(g_owner) && get_user_team(id) == get_user_team(g_owner))
 #endif
 {
   
if(temp_cvar == 1)
{
  message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, id)
  write_short(1)
  write_short(1)
  write_short(1)
  write_byte(0)
  write_byte(0)
  write_byte(0)
  write_byte(255)
  message_end()
}
if(temp_cvar == 2)
{
g_track[id] = true
}
 }
}

public flash_delay()
{
if(g_track_enemy == false)
for(new i = 0; i < 33; i++)
if(g_track[i] == true && is_user_connected(i))
{
message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, i)
  write_short(1)
  write_short(1)
  write_short(1)
  write_byte(0)
  write_byte(0)
  write_byte(0)
  write_byte(255)
  message_end()
}
}

public grenade_throw()
{
if(g_sync_check_data == 0)
return PLUGIN_CONTINUE
g_sync_check_data--;
if(read_datanum() < 2)
   return PLUGIN_HANDLED_MAIN


if(read_data(1) == 11 && (read_data(2) == 0 || read_data(2) == 1))
{
add_grenade_owner(last)
//set_task(1.9, "bad_fix1")
}

return PLUGIN_CONTINUE
}
//if no recent flash, take off an owner, the flash must have not flashed anyone
/*public bad_fix1()
{
new Float:gametime = get_gametime()
if(gametime - g_gametime > 0.4)
get_grenade_owner()
}*/

public fire_in_the_hole()
{
new name[32]
read_data(3, name, 31)
new temp_last = get_user_index(name)
new junk
if((temp_last == 0) || (!is_user_connected(temp_last)))
return PLUGIN_CONTINUE;
if(get_user_weapon(temp_last,junk,junk) == CSW_FLASHBANG)
{
last = temp_last
g_sync_check_data = 2;
}
return PLUGIN_CONTINUE
}

public fire_in_the_hole2()
{
new name[32]
read_data(4, name, 31)
new temp_last = get_user_index(name)
new junk
if((temp_last == 0) || (!is_user_connected(temp_last)))
return PLUGIN_CONTINUE;
if(get_user_weapon(temp_last,junk,junk) == CSW_FLASHBANG)
{
last = temp_last
g_sync_check_data = 2;
}
return PLUGIN_CONTINUE
}


add_grenade_owner(owner)
{
new Float:gametime = get_gametime()
g_gametime2 = gametime
#if FLASH_DEBUG > 0
client_print(0, print_chat, "add time: %f", gametime);
client_print(0, print_chat, "add owner: %d", owner);
#endif
for(new i = 0; i < 32; i++)
{
if(grenade[i] == 0)
   {
grenade[i] = owner
return
}
}
}
//also removes the owner from the list
get_grenade_owner()
{
#if FLASH_DEBUG > 0
new Float:gametime = get_gametime()
client_print(0, print_chat, "get time: %f", gametime);
client_print(0, print_chat, "get owner: %d", grenade[0]);
//server_print("GET");
#endif
new which = grenade[0]
for(new i = 1; i < 32; i++)
{
grenade[i-1] = grenade[i]
}
grenade[31] = 0
return which
}

//from XxAvalanchexX "Flashbang Dynamic Light" http://forums.alliedmods.net/showthread.php?t=46258
public fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
{
// not a flashbang exploding
if(!equali(sample,"weapons/flashbang-1.wav") && !equali(sample,"weapons/flashbang-2.wav"))
return FMRES_IGNORED;

new Float:gametime = get_gametime()
#if FLASH_DEBUG > 0
client_print(0, print_chat, "sound time: %f", gametime);
#endif

//in case no one got flashed, the sound happens after all the flashes, same game time
if(gametime != g_gametime)
{
g_owner = get_grenade_owner()
return FMRES_IGNORED;
}

//now that all the flashes have been registered lets apply them
if(get_cvar_num("no_team_flash") == 2)
flash_delay();
return FMRES_IGNORED;
}

Fixed Version. 

Download SMA :  http://node1.lamdaprocs.com/index.php/s/CHMckar8DevHmvJ
(11-29-2016, 06:01 PM)Umbrella Hunter Wrote: [ -> ]Fixed Version.

Compiled plugin:
Download-> http://www.amxmodx.org/webcompiler.cgi?go=dl&id=1901873
he can compile it alone Smile