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_PreThink( id )
{
if( ! is_user_alive( id ) )
return PLUGIN_CONTINUE;
if( g_bIsPlayerInParachute[ id ] )
{
new Float:fVelocity[ 3 ];
pev( id, pev_velocity, fVelocity );
if( ! g_bLandedPlayer[ id ] && ( ( pev( id, pev_flags ) & FL_ONGROUND ) || ( pev( id, pev_flags ) & FL_INWATER ) ) ) // player has landed on ground/ in water
{
g_bIsPlayerInParachute[ id ] = false; // not in parachute anymore
set_pev( id, pev_sequence, detach );
set_pev( id, pev_movetype, MOVETYPE_WALK );
client_cmd( id, "spk sound/%s", g_iSounds[ Landing_Sound ] ); // emit landing sound
g_bLandedPlayer[ id ] = true;
}
if( fVelocity[ 2 ] < 0.0 ) // still in air
{
fVelocity[ 2 ] = g_fCachedParachuteVelocity;
set_pev( id, pev_velocity, fVelocity );
}
}
return PLUGIN_CONTINUE;
}
__________________