Raised This Month: $ Target: $400
 0% 

Team flash enable/disable by command.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
killergirl
Senior Member
Join Date: Jul 2010
Old 10-09-2010 , 05:45   Team flash enable/disable by command.
Reply With Quote #1

I've checked all anti team flash plugins and the best and works all the time is:
https://forums.alliedmods.net/showthread.php?t=70735 (antiflashbug) by MPNumB.

Can anyone make a command for players to enable/disable, beacause not anybody wants to play with "anti team flash".

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Flashbang Bug"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Numb"

new Float:old_gametime;
new 
mp_friendlyfire;
new 
owner;

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
RegisterHam(Ham_Think"grenade""Ham_FEThink_grenade"0);
    
    
register_forward(FM_FindEntityInSphere"fm_FEFindEntityInSphere"0);
    
    
mp_friendlyfire get_cvar_pointer("mp_friendlyfire");
}

public 
Ham_FEThink_grenade(ent)
{
    static 
model[32];
    
pev(entpev_modelmodel31);
    if( 
equal(model"models/w_flashbang.mdl") )
    {
        if( (
owner=pev(entpev_owner))<)
            
owner 0;
        
        
old_gametime get_gametime();
    }
    else
    {
        
owner 0;
        
old_gametime 0.0;
    }
}

public 
fm_FEFindEntityInSphere(startFloat:origin[3], Float:radius)
{
    if( 
radius!=1500.0 || old_gametime!=get_gametime() )
        return 
FMRES_IGNORED;
    
    static 
hittraceFloat:user_origin[3], Float:absmax[3], Float:fractionffowner_team;
    
hit start;
    
ff clamp(get_pcvar_num(mp_friendlyfire), 01);
    if( 
owner )
        
owner_team get_user_team(owner);
    else
        
owner_team = -1;
    
    
// run the same check to see what its result will be
    
while( (hit=engfunc(EngFunc_FindEntityInSpherehitoriginradius))>)
    {
        
// hit a non- or dead-player
        
if( !is_user_alive(hit) )
        {
            
forward_return(FMV_CELLhit);
            return 
FMRES_SUPERCEDE;
        }
        
        
// aim for the body eyes
        
pev(hitpev_originuser_origin);
        
pev(hitpev_absmaxabsmax);
        
user_origin[2] = (absmax[2]-20.0);
        
engfunc(EngFunc_TraceLineoriginuser_originDONT_IGNORE_MONSTERS0trace);
        
        
// hit player eyes, grenade ok
        
if( get_tr2(traceTR_pHit)==hit )
        {
            
// start backup check (de_dust2 B bug - outmap bug)
            
engfunc(EngFunc_TraceLineuser_originoriginDONT_IGNORE_MONSTERShittrace);
            
            
// hit player eyes with backup check
            
get_tr2(traceTR_flFractionfraction);
            if( 
fraction==1.0 )
            {
                if( 
ff || owner==hit || owner_team!=get_user_team(hit) )
                {
                    
forward_return(FMV_CELLhit);
                    return 
FMRES_SUPERCEDE;
                }
            }
        }
    }
    
    
// grenade could not hit anyones eyes, cancel the check
    
forward_return(FMV_CELL, -1);
    return 
FMRES_SUPERCEDE;

killergirl is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 12:03   Re: Team flash enable/disable by command.
Reply With Quote #2

amx_teamflash 0/1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Flashbang Bug"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Numb"

new Float:old_gametime;
new 
mp_friendlyfire;
new 
owner;
new 
pCvarEnabled;

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
    
RegisterHam(Ham_Think"grenade""Ham_FEThink_grenade"0);
    
    
register_forward(FM_FindEntityInSphere"fm_FEFindEntityInSphere"0);
    
    
mp_friendlyfire get_cvar_pointer("mp_friendlyfire");
    
pCvarEnabled register_cvar"amx_teamflash""1" );
}

public 
Ham_FEThink_grenade(ent)
{
    static 
model[32];
    
pev(entpev_modelmodel31);
    if( 
equal(model"models/w_flashbang.mdl") )
    {
        if( (
owner=pev(entpev_owner))<)
            
owner 0;
        
        
old_gametime get_gametime();
    }
    else
    {
        
owner 0;
        
old_gametime 0.0;
    }
}

public 
fm_FEFindEntityInSphere(startFloat:origin[3], Float:radius)
{
    if( 
radius!=1500.0 || old_gametime!=get_gametime() || !get_pcvar_numpCvarEnabled ) )
        return 
FMRES_IGNORED;
    
    static 
hittraceFloat:user_origin[3], Float:absmax[3], Float:fractionffowner_team;
    
hit start;
    
ff clamp(get_pcvar_num(mp_friendlyfire), 01);
    if( 
owner )
        
owner_team get_user_team(owner);
    else
        
owner_team = -1;
    
    
// run the same check to see what its result will be
    
while( (hit=engfunc(EngFunc_FindEntityInSpherehitoriginradius))>)
    {
        
// hit a non- or dead-player
        
if( !is_user_alive(hit) )
        {
            
forward_return(FMV_CELLhit);
            return 
FMRES_SUPERCEDE;
        }
        
        
// aim for the body eyes
        
pev(hitpev_originuser_origin);
        
pev(hitpev_absmaxabsmax);
        
user_origin[2] = (absmax[2]-20.0);
        
engfunc(EngFunc_TraceLineoriginuser_originDONT_IGNORE_MONSTERS0trace);
        
        
// hit player eyes, grenade ok
        
if( get_tr2(traceTR_pHit)==hit )
        {
            
// start backup check (de_dust2 B bug - outmap bug)
            
engfunc(EngFunc_TraceLineuser_originoriginDONT_IGNORE_MONSTERShittrace);
            
            
// hit player eyes with backup check
            
get_tr2(traceTR_flFractionfraction);
            if( 
fraction==1.0 )
            {
                if( 
ff || owner==hit || owner_team!=get_user_team(hit) )
                {
                    
forward_return(FMV_CELLhit);
                    return 
FMRES_SUPERCEDE;
                }
            }
        }
    }
    
    
// grenade could not hit anyones eyes, cancel the check
    
forward_return(FMV_CELL, -1);
    return 
FMRES_SUPERCEDE;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
killergirl
Senior Member
Join Date: Jul 2010
Old 10-09-2010 , 15:21   Re: Team flash enable/disable by command.
Reply With Quote #3

Thank you for helping me, but I've tried to explain a command for players, not a cvar, like chat command (say: /enable and say: /disable) or console command. If a player execute the command, just only for him will work the "antiflash".
killergirl is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode