Detect player crouching
#5

Quote:
Originally Posted by Zh3r0
View Post
Then do a variable check. Set true when crouching and set false when standing up from crouching.
Tried that. Worked for 1-3 times, but got easily messed up to be other way around.
ATM I got it working with timer (again )

In 500ms the player has time to stand up / crouch, and the GetPlayerSpecialAction returns the value I need.
So:
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    #define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
   
    #define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

    #define HOLDING(%0) \
    ((newkeys & (%0)) == (%0))

    if( PRESSED(KEY_CROUCH) ) // CROUCH
    {
        CheckCrouch(playerid);
    }
    return 1;
}
Delay:CheckCrouch[500, i](playerid)
{
    if( GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK )
    {
        //stuff
    }
}
And actually in this case I don't mind the slight delay.
Reply


Messages In This Thread
Detect player crouching - by TheXIII - 23.11.2010, 11:33
Re: Detect player crouching - by Mike_Peterson - 23.11.2010, 11:42
Re: Detect player crouching - by TheXIII - 23.11.2010, 11:45
Re: Detect player crouching - by Zh3r0 - 23.11.2010, 11:56
Re: Detect player crouching - by TheXIII - 23.11.2010, 12:13
Re: Detect player crouching - by Babul - 23.11.2010, 12:20
Re: Detect player crouching - by armyoftwo - 23.11.2010, 12:58

Forum Jump:


Users browsing this thread: 4 Guest(s)