Raised This Month: $51 Target: $400
 12% 

anti bunny hop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
serhat2110
Junior Member
Join Date: May 2020
Old 12-19-2020 , 17:40   anti bunny hop
Reply With Quote #1

hi i want to block bunny for my soccerjam mod server. Normally, bunny is off, some open cfg and some make bunny with macro. Can we prevent this? i saw it on a server. The game slowed you down when you used macro or cfg. I need something like that. Or the jump limit may be imposed. The player can jump up to 2 times in a row.
serhat2110 is offline
serhat2110
Junior Member
Join Date: May 2020
Old 12-21-2020 , 17:23   Re: anti bunny hop
Reply With Quote #2

Can anyone help
serhat2110 is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 12-22-2020 , 13:06   Re: anti bunny hop
Reply With Quote #3

Plugin 1:

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

#define PLUGIN "BhopHack Detector"
#define VERSION "0.1"
#define AUTHOR "Mistrick"

#pragma semicolon 1

#define LOGFILE "bhopdetector.log"

enum _:PLAYER_DATA
{
    
m_GroundFrames,
    
m_OldGroundFrames,
    
m_PreJumpGroundFrames,
    
m_OldPreJumpGroundFrames,
    
m_AirFrames,//useless
    
m_JumpHoldFrames,
    
m_JumpPressCount,
    
m_DuckHoldFrames,
    
Float:m_Velocity//useless
};
enum _:WARNINGS_DATA
{
    
m_WarnEqualFrames,
    
m_WarnGroundEqualFrames,
    
m_WarnJumpSpam
}

#define MAX_JUMPCOUNT 16
#define MAX_GROUND_FRAME_COINCIDENCE 16
#define MAX_JUMP_SPAM 8

new g_ePlayerInfo[33][PLAYER_DATA];
new 
g_ePlayerWarn[33][WARNINGS_DATA];
new 
g_ePlayerWarnMax[33][WARNINGS_DATA];


new 
g_szLogFile[128];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_forward(FM_PlayerPreThink"FM_PlayerPreThink_Pre"false);    
}
public 
plugin_cfg()
{
    
get_localinfo("amxx_logs"g_szLogFilecharsmax(g_szLogFile));
    
format(g_szLogFilecharsmax(g_szLogFile), "/%s/%s"g_szLogFileLOGFILE);
}
public 
client_putinserver(id)
{
    
g_ePlayerWarn[id][m_WarnEqualFrames] = 0;
    
g_ePlayerWarn[id][m_WarnGroundEqualFrames] = 0;
    
g_ePlayerWarn[id][m_WarnJumpSpam] = 0;
}
public 
client_disconnect(id)
{
    
UTIL_LogUser(id"onground %d, equaljump %d, jumpspam %d"g_ePlayerWarnMax[id][m_WarnGroundEqualFrames], g_ePlayerWarnMax[id][m_WarnEqualFrames], g_ePlayerWarnMax[id][m_WarnJumpSpam]);
    
    
g_ePlayerWarnMax[id][m_WarnEqualFrames] = 0;
    
g_ePlayerWarnMax[id][m_WarnGroundEqualFrames] = 0;
    
g_ePlayerWarnMax[id][m_WarnJumpSpam] = 0;
}
public 
FM_PlayerPreThink_Pre(id)
{
    if(!
is_user_alive(id)) return FMRES_IGNORED;
    
    new 
buttons pev(idpev_button);
    new 
oldbuttons pev(idpev_oldbuttons);
    
    if(
buttons IN_JUMP)
    {
        
g_ePlayerInfo[id][m_JumpHoldFrames]++;
    }
    if(
buttons IN_JUMP && ~oldbuttons IN_JUMP)
    {
        
g_ePlayerInfo[id][m_JumpPressCount]++;
    }
    if(~
buttons IN_JUMP && oldbuttons IN_JUMP)
    {
        
///**************************************
    
}
    if(
buttons IN_DUCK)
    {
        
g_ePlayerInfo[id][m_DuckHoldFrames]++;
    }
    
    new 
on_ground bool:(pev(idpev_flags) & FL_ONGROUND);
    
    if(
on_ground)
    {
        
g_ePlayerInfo[id][m_GroundFrames]++;
    }
    else
    {
        if(
g_ePlayerInfo[id][m_GroundFrames])
        {
            new 
Float:velocity[3]; pev(idpev_velocityvelocity); velocity[2] = 0.0;
            
g_ePlayerInfo[id][m_Velocity] = _:vector_length(velocity);
            
g_ePlayerInfo[id][m_PreJumpGroundFrames] = g_ePlayerInfo[id][m_GroundFrames];
        }
        
g_ePlayerInfo[id][m_GroundFrames] = 0;
        
g_ePlayerInfo[id][m_AirFrames]++;
    }
    
    if(
g_ePlayerInfo[id][m_OldGroundFrames] == && g_ePlayerInfo[id][m_GroundFrames])
    {
        if(
g_ePlayerInfo[id][m_JumpPressCount] == && g_ePlayerInfo[id][m_JumpHoldFrames] == && g_ePlayerInfo[id][m_DuckHoldFrames] == 0)
        {
            
//console_print(id, "wtf? JumpPressCount 0, JumpHoldFrames 0, DuckHoldFrames 0");
        
}
        if(
g_ePlayerInfo[id][m_JumpPressCount] > 0)
        {
            
/// if g_ePlayerInfo[id][m_JumpHoldFrames] == g_ePlayerInfo[id][m_JumpPressCount] cheat
            /// if g_ePlayerInfo[id][m_JumpPressCount] > 16 script
            
            //console_print(id, "ground [%d], air [%d], jumphold [%d], jumpcount [%d], velocity [%.3f]", g_ePlayerInfo[id][m_PreJumpGroundFrames],  g_ePlayerInfo[id][m_AirFrames], g_ePlayerInfo[id][m_JumpHoldFrames], g_ePlayerInfo[id][m_JumpPressCount], g_ePlayerInfo[id][m_Velocity]);
            
            /// TODO: сделать цикл
            
if(g_ePlayerInfo[id][m_JumpHoldFrames] == g_ePlayerInfo[id][m_JumpPressCount])
            {
                
g_ePlayerWarn[id][m_WarnEqualFrames]++;
                if(
g_ePlayerWarn[id][m_WarnEqualFrames] > g_ePlayerWarnMax[id][m_WarnEqualFrames])
                {
                    
g_ePlayerWarnMax[id][m_WarnEqualFrames] = g_ePlayerWarn[id][m_WarnEqualFrames];
                }
            }
            else if(
g_ePlayerWarn[id][m_WarnEqualFrames])
            {
                
g_ePlayerWarn[id][m_WarnEqualFrames]--;
            }
            
            if(
g_ePlayerInfo[id][m_PreJumpGroundFrames] == g_ePlayerInfo[id][m_OldPreJumpGroundFrames])
            {
                
g_ePlayerWarn[id][m_WarnGroundEqualFrames]++;
                if(
g_ePlayerWarn[id][m_WarnGroundEqualFrames] > g_ePlayerWarnMax[id][m_WarnGroundEqualFrames])
                {
                    
g_ePlayerWarnMax[id][m_WarnGroundEqualFrames] = g_ePlayerWarn[id][m_WarnGroundEqualFrames];
                }
            }
            else if(
g_ePlayerWarn[id][m_WarnGroundEqualFrames])
            {
                
g_ePlayerWarn[id][m_WarnGroundEqualFrames]--;
            }
            
            if(
g_ePlayerInfo[id][m_JumpPressCount] >= MAX_JUMPCOUNT)
            {
                
g_ePlayerWarn[id][m_WarnJumpSpam]++;
                if(
g_ePlayerWarn[id][m_WarnJumpSpam] > g_ePlayerWarnMax[id][m_WarnJumpSpam])
                {
                    
g_ePlayerWarnMax[id][m_WarnJumpSpam] = g_ePlayerWarn[id][m_WarnJumpSpam];
                }
            }
            else if(
g_ePlayerWarn[id][m_WarnJumpSpam])
            {
                
g_ePlayerWarn[id][m_WarnJumpSpam]--;
            }
            
            
//console_print(id, "groundequal [%d], jumpequal[%d], jumpspam [%d]", g_ePlayerWarn[id][m_WarnGroundEqualFrames], g_ePlayerWarn[id][m_WarnEqualFrames], g_ePlayerWarn[id][m_WarnJumpSpam]);
            
            
if(g_ePlayerWarn[id][m_WarnGroundEqualFrames] >= MAX_GROUND_FRAME_COINCIDENCE)
            {
                
PunishPlayer(id"BhopHack[g]");
                
g_ePlayerWarn[id][m_WarnGroundEqualFrames] = 0;
            }
            if(
g_ePlayerWarn[id][m_WarnJumpSpam] >= MAX_JUMP_SPAM)
            {
                
PunishPlayer(id"BhopHack[s]");
                
g_ePlayerWarn[id][m_WarnJumpSpam] = 0;
            }
        }
        
        
g_ePlayerInfo[id][m_AirFrames] = 0;
        
g_ePlayerInfo[id][m_JumpHoldFrames] = 0;
        
g_ePlayerInfo[id][m_JumpPressCount] = 0;
        
g_ePlayerInfo[id][m_DuckHoldFrames] = 0;
        
g_ePlayerInfo[id][m_OldPreJumpGroundFrames] = g_ePlayerInfo[id][m_PreJumpGroundFrames];
    }
    
    
g_ePlayerInfo[id][m_OldGroundFrames] = g_ePlayerInfo[id][m_GroundFrames];
    
    return 
FMRES_IGNORED;
}
PunishPlayer(idreason[])
{
    new 
name[32]; get_user_name(idnamecharsmax(name));
    
client_print(0print_chat"[BH Detector] %s using %s"namereason);
    
server_cmd("amx_ban 0 #%d %s"get_user_userid(id), reason);
    
    
UTIL_LogUser(id"using %s"reason);
}
stock UTIL_LogUser(const id, const szCvar[], any:...)
{
    new 
iFile;
    if( (
iFile fopen(g_szLogFile"a")) )
    {
        new 
szName[32], szAuthid[32], szIp[32], szTime[22];
        new 
message[128]; vformat(messagecharsmax(message), szCvar3);
        
        
get_user_name(idszNamecharsmax(szName));
        
get_user_authid(idszAuthidcharsmax(szAuthid));
        
get_user_ip(idszIpcharsmax(szIp), 1);
        
get_time("%m/%d/%Y - %H:%M:%S"szTimecharsmax(szTime));
        
        
fprintf(iFile"L %s: <%s><%s><%s> %s^n"szTimeszNameszAuthidszIpmessage);
        
fclose(iFile);
    }

Plugin 2:

PHP Code:
#include <amxmodx>
#include <reapi>

#pragma semicolon 1

new g_iPlayerGround[MAX_PLAYERS 1];

public 
plugin_init()
{
    
register_plugin("No Bhop and SGS/DDRun""1.1""Denzer");

    
RegisterHookChain(RG_CBasePlayer_Jump"CBasePlayer_Jump");
    
RegisterHookChain(RG_CBasePlayer_Duck"CBasePlayer_Duck");
    
RegisterHookChain(RG_CBasePlayer_PreThink"CBasePlayer_PreThink");
}

public 
client_putinserver(id)
{
    
g_iPlayerGround[id] = 0;
}

public 
CBasePlayer_Jump(id)
{
    if(
g_iPlayerGround[id] && g_iPlayerGround[id] < 5)
        
set_entvar(idvar_oldbuttonsget_entvar(idvar_oldbuttons) | IN_JUMP);
}

public 
CBasePlayer_Duck(id)
{
    if(
g_iPlayerGround[id] && g_iPlayerGround[id] < 5)
        
set_entvar(idvar_oldbuttonsget_entvar(idvar_oldbuttons) | IN_DUCK);
}

public 
CBasePlayer_PreThink(id)
{
    if(
get_entvar(idvar_flags) & FL_ONGROUND)
        
g_iPlayerGround[id]++;
    else
        
g_iPlayerGround[id] = 0;

ReApi needed.
Godofwar 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 05:10.


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