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

First time landing (pev_flags) bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 17:54   First time landing (pev_flags) bug
Reply With Quote #1

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;

__________________
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2018 , 22:20   Re: First time landing (pev_flags) bug
Reply With Quote #2

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.
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-31-2018 , 05:52   Re: First time landing (pev_flags) bug
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
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.
__________________

Last edited by edon1337; 07-31-2018 at 05:57.
edon1337 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 10:21.


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