View Single Post
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 09-05-2020 , 17:24   [CSGO] Double Jump bugging with sv_autobunnyhopping 1
Reply With Quote #1

I have a strange problem, I'm trying to make a double jump plugin, but if I enable sv_autobunnyhopping, double jump won't work on the first jump, but after I bunnyhop at least once.
That mean, I have to jump, land, then I'll be able to double jump. This is strange. I don't have any other plugin that modifies player's buttons.

Here is my code called on OnPlayerRunCmd()

PHP Code:
void DoubleJump(int Clientfloat vVel[3])
{
    static 
int CurFlags 0;
    static 
int CurButtons 0;
    
    
CurFlags GetEntityFlags(Client); 
    
CurButtons GetClientButtons(Client);

    if(
CurFlags FL_ONGROUND)
    {
        
g_iJumps[Client] = 0;    
        
PrintHintText(Client"DEBUG 1 [%i Jumps]"g_iJumps[Client]);
    }
    else if(!(
CurFlags FL_ONGROUND) && g_iJumps[Client] == 0)
    {
        
//PrintHintText(Client, "DEBUG 2 [%i Jumps]", g_iJumps[Client]);
        
if((CurButtons IN_JUMP) && !(g_iLastButtons[Client] & IN_JUMP))
        {
            
g_iJumps[Client] = g_iJumps[Client] + 1;
            
PrintHintText(Client"DEBUG 2 [%i Jumps]"g_iJumps[Client]);
            
vVel[2] = 300.0;
            
TeleportEntity(ClientNULL_VECTORNULL_VECTORvVel);
            
SetEntDataVector(Clientg_iVelocityvVel);        
        }
    }
    
g_iLastButtons[Client] = CurButtons;

I fixed it by myself
Here's the code in case anyone needs it

PHP Code:
void DoubleJump(int Clientfloat vVel[3])
{
    static 
int CurFlags 0;
    static 
int CurButtons 0;
    static 
int LastFlags[MAXPLAYERS 1];
    static 
int Jumps[MAXPLAYERS 1];
    static 
int LastButtons[MAXPLAYERS+1] = 0;
    
    
CurFlags GetEntityFlags(Client); 
    
CurButtons GetClientButtons(Client);

    if(
CurFlags FL_ONGROUND)
    {
        
Jumps[Client] = 0;
    }
    else if(!(
CurFlags FL_ONGROUND))
    {
        if((
CurButtons IN_JUMP) && !(LastFlags[Client] & FL_ONGROUND) && !(LastButtons[Client] & IN_JUMP))
        {
            if(
Jumps[Client] == 0)
            {
                
vVel[2] = 300.0;
                
TeleportEntity(ClientNULL_VECTORNULL_VECTORvVel);
                
SetEntDataVector(Clientg_iVelocityvVel);    
                
Jumps[Client]++;
            }
        }
    }
    
LastFlags[Client] = CurFlags;
    
LastButtons[Client] = CurButtons;

__________________

Last edited by kratoss1812; 09-10-2020 at 07:05.
kratoss1812 is offline