AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [CSGO] Double Jump bugging with sv_autobunnyhopping 1 (https://forums.alliedmods.net/showthread.php?t=327204)

kratoss1812 09-05-2020 17:24

[CSGO] Double Jump bugging with sv_autobunnyhopping 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;




All times are GMT -4. The time now is 14:58.

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