2 or 3 keys pressed in the same time | Please help -
AdrianG - 17.03.2016
Hello, I don't know how to determine if, for instance, a play press W and in the same time he pressed also Q or E.. How can I get it..
I have a script like:
if (newkeys == KEY_LOOK_RIGHT) do smth
but this is called when is JUST E pressed without any key.. how can I activate this if even if is another key pressed.
In conclusion I want to know if a key is pressed even another one is also pressed. Thx. I hope you understand me
Re: 2 or 3 keys pressed in the same time | Please help -
ZToPMaN - 17.03.2016
Hmm "&&" = and , so you can use this tick.
if (newkeys == KEY_LOOK_RIGHT && "add new one here")
Re: 2 or 3 keys pressed in the same time | Please help -
Redirect Left - 17.03.2016
The wiki page (which you should start checking before posting) has all the information you need on detecting keys reliably.
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: 2 or 3 keys pressed in the same time | Please help -
Mauzen - 17.03.2016
Quote:
Originally Posted by ZToPMaN
Hmm "&&" = and , so you can use this tick.
if (newkeys == KEY_LOOK_RIGHT && "add new one here")
|
An integer cant be equal to two different values at a time, so that if-code wont ever exeucte.
Re: 2 or 3 keys pressed in the same time | Please help -
ATGOggy - 17.03.2016
You cannot detect two keys at the same time.
But, I think you can detect the keys if the player holds the first key and presses the next key.
Re: 2 or 3 keys pressed in the same time | Please help -
Mauzen - 17.03.2016
Quote:
Originally Posted by ATGOggy
You cannot detect two keys at the same time.
But, I think you can detect the keys if the player holds the first key and presses the next key.
|
Sure you can, just check what Redirect Left posted.
Re: 2 or 3 keys pressed in the same time | Please help -
AdrianG - 17.03.2016
So, i checked the
https://sampwiki.blast.hk/wiki/OnPlayerK..._multiple_keys but I want to know just if Q is pressed doesn't matter which one is also pressed. So I have to check for each combination like if ((newkeys & KEY_LOOK_LEFT) && (newkeys & KEY_CROUCH)) ??
Or if ((newkeys & KEY_LOOK_LEFT) && (newkeys >=-128 ) ), where (newkeys >=-128 ) is for another key (doesnt matter which is)
because -128 is the lowest key value i guess
Am I right or ?
Re: 2 or 3 keys pressed in the same time | Please help -
ATGOggy - 17.03.2016
Quote:
Originally Posted by AdrianG
So, i checked the https://sampwiki.blast.hk/wiki/OnPlayerK..._multiple_keys but I want to know just if Q is pressed doesn't matter which one is also pressed. So I have to check for each combination like if ((newkeys & KEY_LOOK_LEFT) && (newkeys & KEY_CROUCH)) ??
Or if ((newkeys & KEY_LOOK_LEFT) && (newkeys >=1)), where (newkeys >=1) is for another key (doesnt matter which is)
|
First one will work only if the player presses one key after the another.
Re: 2 or 3 keys pressed in the same time | Please help -
Crayder - 17.03.2016
Quote:
Originally Posted by AdrianG
So, i checked the https://sampwiki.blast.hk/wiki/OnPlayerK..._multiple_keys but I want to know just if Q is pressed doesn't matter which one is also pressed. So I have to check for each combination like if ((newkeys & KEY_LOOK_LEFT) && (newkeys & KEY_CROUCH)) ??
Or if ((newkeys & KEY_LOOK_LEFT) && (newkeys >=-128 ) ), where (newkeys >=-128 ) is for another key (doesnt matter which is)
because -128 is the lowest key value i guess
Am I right or ?
|
So you want to know if Q and ANY OTHER KEY are pressed at the same time?
pawn Код:
if((newkeys & KEY_LOOK_LEFT) && (newkeys & !KEY_LOOK_LEFT))
@ATGOggy: Quit being that guy that replies to random Scripting Help threads without any clue whether you're right or not. In this case you obviously don't know the answer so get out. No rep for you here.
Re: 2 or 3 keys pressed in the same time | Please help -
ATGOggy - 17.03.2016
Use this:
PHP код:
if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE) && (newkeys & KEY_CROUCH) && !(oldkeys & KEY_CROUCH))
Try it