Raised This Month: $32 Target: $400
 8% 

Need A Cvar to Enable/Disable The Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snake.
Senior Member
Join Date: Jul 2017
Old 11-23-2021 , 17:14   Need A Cvar to Enable/Disable The Plugin
Reply With Quote #1

If the cvar is 0, it will be disabled and if 1, will be enabled..
PHP Code:
/*
 *
 * HNS Block Return
 *
 * Copyright 2016 Garey <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new Array:g_arFlPlayerOrigin[33]
new Array:
g_arFlPlayerAngle[33]
new 
bool:g_bIsTouched[33];
new 
bool:g_bIsBlocked[33];
new 
iToucher[33];
new 
g_iMaxPlayers;

public 
plugin_init()
{
    
register_plugin("Block Return""0.1""Garey");

    
g_iMaxPlayers get_maxplayers();

    for(new 
1<= g_iMaxPlayersi++)
    {
        
g_arFlPlayerOrigin[i] = ArrayCreate(3);
        
g_arFlPlayerAngle[i] = ArrayCreate(3);
    }
    
    
RegisterHamHam_Player_PreThink"player""fwd_PlayerPreThink");
    
RegisterHamHam_Touch"player""fwd_TouchPlayer");
    
RegisterHamHam_TakeDamage"player""Ham_TakeDamagePlayer" );
}

public 
fwd_TouchPlayeridentity )
{
    if( 
get_user_teamid ) != || !is_user_aliveentity ))
        return;

    if( 
get_user_teamentity ) != )
        return;

    new 
flVelocity[3]
    
pev(idpev_velocityflVelocity);

    if(
flVelocity[2] != 0.0)
    {
        
g_bIsTouched[id] = true;
        
iToucher[id] = entity;
    }
}

public 
Ham_TakeDamagePlayer(iVictimiInflictoriAttackerFloat:flDamageiDamageBits)
{
    if( 
is_user_alive(iVictim) && flDamage >= 50.0 && iDamageBits DMG_FALL )
    {
        if( 
get_user_team(iVictim) == )
        {
            if(
g_bIsTouched[iVictim] && is_user_alive(iToucher[iVictim]))
            {
                
iToucher[iVictim] = 0;
                
g_bIsBlocked[iVictim] = true;
                
set_pev(iVictimpev_movetypeMOVETYPE_NOCLIP)
                return 
HAM_SUPERCEDE;
            }
        }
    }
    return 
HAM_IGNORED;
}

public 
fwd_PlayerPreThinkid )
{
    static 
flPlayerOrigin[3], flPlayerAngles[3], LastFrames[33]

    if(
is_user_alive(id))
    {
        if(!
g_bIsBlocked[id])
        {
            
pev(idpev_originflPlayerOrigin);
            
pev(idpev_v_angleflPlayerAngles);

            if((
pev(idpev_flags) & FL_ONGROUND) || pev(idpev_movetype) == MOVETYPE_FLY)
            {
                if(
LastFrames[id] > 10)
                {
                    
g_bIsTouched[id] = false;
                    
ArrayClear(g_arFlPlayerOrigin[id]);
                    
ArrayClear(g_arFlPlayerAngle[id]);
                    
LastFrames[id] = 0;
                }
                else
                {
                    
ArrayPushArray(g_arFlPlayerOrigin[id], flPlayerOrigin);
                    
ArrayPushArray(g_arFlPlayerAngle[id], flPlayerAngles);
                    
LastFrames[id]++;
                }
            }
            else
            {
                
ArrayPushArray(g_arFlPlayerOrigin[id], flPlayerOrigin);
                
ArrayPushArray(g_arFlPlayerAngle[id], flPlayerAngles);
            }
        }
        else
        {
            new 
Length ArraySize(g_arFlPlayerOrigin[id])-1;

            if(
Length)
            {
                
ArrayGetArray(g_arFlPlayerOrigin[id], LengthflPlayerOrigin);
                
ArrayGetArray(g_arFlPlayerAngle[id], LengthflPlayerAngles);

                
ArrayDeleteItem(g_arFlPlayerOrigin[id], Length);
                
ArrayDeleteItem(g_arFlPlayerAngle[id], Length);

                
set_pev(idpev_originflPlayerOrigin)
                
set_pev(idpev_anglesflPlayerAngles)
                
set_pev(idpev_fixangle1)
            }
            else
            {
                
set_pev(id,pev_movetype,MOVETYPE_WALK)
                
set_pev(id,pev_velocity,Float:{0.0,0.0,0.0})
                
set_pev(id,pev_flags,pev(id,pev_flags)|FL_DUCKING)
                
g_bIsBlocked[id] = false;
            }
        }
    }
    else
    {
        
LastFrames[id] = 0;
    }

Snake. is offline
Send a message via Skype™ to Snake.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-23-2021 , 22:00   Re: Need A Cvar to Enable/Disable The Plugin
Reply With Quote #2

Try this out. Cvar is block_return_enable.

PHP Code:
/*
 *
 * HNS Block Return
 *
 * Copyright 2016 Garey <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new Array:g_arFlPlayerOrigin[33]
new Array:
g_arFlPlayerAngle[33]
new 
bool:g_bIsTouched[33];
new 
bool:g_bIsBlocked[33];
new 
iToucher[33];
new 
g_iMaxPlayers;
new 
pEnable;

public 
plugin_init()
{
    
register_plugin("Block Return""0.1""Garey");

    
g_iMaxPlayers get_maxplayers();

    for(new 
1<= g_iMaxPlayersi++)
    {
        
g_arFlPlayerOrigin[i] = ArrayCreate(3);
        
g_arFlPlayerAngle[i] = ArrayCreate(3);
    }

    
pEnable register_cvar("block_return_enable""1");
    
    
RegisterHamHam_Player_PreThink"player""fwd_PlayerPreThink");
    
RegisterHamHam_Touch"player""fwd_TouchPlayer");
    
RegisterHamHam_TakeDamage"player""Ham_TakeDamagePlayer" );
}

public 
fwd_TouchPlayeridentity )
{
    if( !
get_pcvar_num(pEnable) )
        return;

    if( 
get_user_teamid ) != || !is_user_aliveentity ))
        return;

    if( 
get_user_teamentity ) != )
        return;

    new 
flVelocity[3]
    
pev(idpev_velocityflVelocity);

    if(
flVelocity[2] != 0.0)
    {
        
g_bIsTouched[id] = true;
        
iToucher[id] = entity;
    }
}

public 
Ham_TakeDamagePlayer(iVictimiInflictoriAttackerFloat:flDamageiDamageBits)
{
    if( 
get_pcvar_num(pEnable) && is_user_alive(iVictim) && flDamage >= 50.0 && iDamageBits DMG_FALL )
    {
        if( 
get_user_team(iVictim) == )
        {
            if(
g_bIsTouched[iVictim] && is_user_alive(iToucher[iVictim]))
            {
                
iToucher[iVictim] = 0;
                
g_bIsBlocked[iVictim] = true;
                
set_pev(iVictimpev_movetypeMOVETYPE_NOCLIP)
                return 
HAM_SUPERCEDE;
            }
        }
    }
    return 
HAM_IGNORED;
}

public 
fwd_PlayerPreThinkid )
{
    static 
flPlayerOrigin[3], flPlayerAngles[3], LastFrames[33]

    if( 
is_user_alive(id) && get_pcvar_num(pEnable) )
    {
        if(!
g_bIsBlocked[id])
        {
            
pev(idpev_originflPlayerOrigin);
            
pev(idpev_v_angleflPlayerAngles);

            if((
pev(idpev_flags) & FL_ONGROUND) || pev(idpev_movetype) == MOVETYPE_FLY)
            {
                if(
LastFrames[id] > 10)
                {
                    
g_bIsTouched[id] = false;
                    
ArrayClear(g_arFlPlayerOrigin[id]);
                    
ArrayClear(g_arFlPlayerAngle[id]);
                    
LastFrames[id] = 0;
                }
                else
                {
                    
ArrayPushArray(g_arFlPlayerOrigin[id], flPlayerOrigin);
                    
ArrayPushArray(g_arFlPlayerAngle[id], flPlayerAngles);
                    
LastFrames[id]++;
                }
            }
            else
            {
                
ArrayPushArray(g_arFlPlayerOrigin[id], flPlayerOrigin);
                
ArrayPushArray(g_arFlPlayerAngle[id], flPlayerAngles);
            }
        }
        else
        {
            new 
Length ArraySize(g_arFlPlayerOrigin[id])-1;

            if(
Length)
            {
                
ArrayGetArray(g_arFlPlayerOrigin[id], LengthflPlayerOrigin);
                
ArrayGetArray(g_arFlPlayerAngle[id], LengthflPlayerAngles);

                
ArrayDeleteItem(g_arFlPlayerOrigin[id], Length);
                
ArrayDeleteItem(g_arFlPlayerAngle[id], Length);

                
set_pev(idpev_originflPlayerOrigin)
                
set_pev(idpev_anglesflPlayerAngles)
                
set_pev(idpev_fixangle1)
            }
            else
            {
                
set_pev(id,pev_movetype,MOVETYPE_WALK)
                
set_pev(id,pev_velocity,Float:{0.0,0.0,0.0})
                
set_pev(id,pev_flags,pev(id,pev_flags)|FL_DUCKING)
                
g_bIsBlocked[id] = false;
            }
        }
    }
    else
    {
        
LastFrames[id] = 0;
    }

__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 20:56.


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