OnPlayerKeyStateChange
#1

Hello I have a question how could I combine 2 keys to do an action like /wave or something for example C + LALT
I know that C=KEY_CROUCHED and LALT=KEY_WALK but I want to know how to combine the 2 to do 1 thing
Reply
#2

Hello!

Try this I found it here:
https://sampwiki.blast.hk/wiki/Keys

PHP код:
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
    
if(
PRESSED(KEY_CROUCH KEY_WALK)) 
Mencent
Reply
#3

#define*PRESSED(%0)*\*
****(((newkeys*&*(%0))*==*(%0))*&&*((oldkeys*&*(%0 ))*!=*(%0)))*
if(PRESSED(KEY_CROUCH | KEY_WALK))
{
//animation here
}
By the way i just wanted to explain for him this code up there so i made that other code
Reply
#4

Quote:
Originally Posted by R0
Посмотреть сообщение
easy,there you go:
pawn Код:
#define HOLDING(%0) \
        ((newkeys & (%0)) == (%0))

#define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))

new PressedC[MAX_PLAYERS];
new PressedAlt[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (HOLDING(KEY_CROUCH))
    {
            PressedC[playerid] = 1;
            if(PressedAlt[playerid] == 1)
            {
                LoopingAnim(playerid,"ON_LOOKERS","wave_loop",4.0,1,0,0,0,0);
            }
    }
        if(RELEASED(KEY_CROUCH))
        {
            PressedC[playerid] = 0;
        }
        if(HOLDING(KEY_WALK))
        {
            PressedAlt[playerid] = 1;
            if(PressedC[playerid] == 1)
            {
                LoopingAnim(playerid,"ON_LOOKERS","wave_loop",4.0,1,0,0,0,0);
            }
        }
        if(RELEASED(KEY_WALK))
        {
            PressedAlt[playerid] = 0;
        }
    return 1;
}
Why would you go through this amount of trouble?

Just do what Mencent said, that's how everybody should be doing it because it's correct.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)