AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   First time landing (pev_flags) bug (https://forums.alliedmods.net/showthread.php?t=309573)

edon1337 07-30-2018 17:54

First time landing (pev_flags) bug
 
First of all, I know you'll ask why I didn't do any debugging, well, how am I supposed to?
Basically, this code checks 2 things:
- Player has landed on ground / in water, if so, stop changing his velocity
- Player's velocity[2] < 0.0, means he's still in the air

The problem is that sometimes even after I have landed on the ground, my velocity keeps getting changed (so check #2 gets executed)

Any ideas?
PHP Code:

public client_PreThinkid )
{
    if( ! 
is_user_aliveid ) )
    return 
PLUGIN_CONTINUE;
    
    if( 
g_bIsPlayerInParachuteid ] )
    {
        new 
Float:fVelocity]; 
        
pevidpev_velocityfVelocity ); 
        
        if( ! 
g_bLandedPlayerid ] && ( ( pevidpev_flags ) & FL_ONGROUND ) || ( pevidpev_flags ) & FL_INWATER ) ) ) // player has landed on ground/ in water
        
{
            
g_bIsPlayerInParachuteid ] = false// not in parachute anymore
            
set_pevidpev_sequencedetach );
            
set_pevidpev_movetypeMOVETYPE_WALK );
            
            
client_cmdid"spk sound/%s"g_iSoundsLanding_Sound ] ); // emit landing sound
            
            
g_bLandedPlayerid ] = true;
        }

        if( 
fVelocity] < 0.0 // still in air
        
{
            
fVelocity] = g_fCachedParachuteVelocity;
            
set_pevidpev_velocityfVelocity );
        } 
    }
    return 
PLUGIN_CONTINUE;



Bugsy 07-30-2018 22:20

Re: First time landing (pev_flags) bug
 
When are you setting g_bLandedPlayer[ id ] to false when the player is not FL_ONGROUND or FL_INWATER? You need to show more code.

edon1337 07-31-2018 05:52

Re: First time landing (pev_flags) bug
 
Quote:

Originally Posted by Bugsy (Post 2607195)
When are you setting g_bLandedPlayer[ id ] to false when the player is not FL_ONGROUND or FL_INWATER? You need to show more code.

That's the only part where g_bLandedPlayer is used. I set g_bLandedPlayer to false in NewRound now, I'll see if that fixed it. Also I think the 2nd statement should be 'else if' instead of 'if'
BTW: Here's an explanation of what I'm trying to accomplish:

Player spawns in max height, he jumps from a plane then he must have a parachute to fall slowly, once he lands, we need to get rid of the parachute.


All times are GMT -4. The time now is 12:28.

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