[HELP] hold and press a key at the same time - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] hold and press a key at the same time (
/showthread.php?tid=664843)
[HELP] hold and press a key at the same time -
CobraWoW - 12.03.2019
i want so when i hold CTRL (KEY_ACTION) and then press SPACE (KEY_HANDBRAKE) at the same time to call the function
but it only works in a reversed way, it works when i hold SPACE and then Press CTRL
So what i want is, call the function by holding KEY_ACTION (default left CTRL key) and pressing KEY_HANDBRAKE
(default spacebar) at the same time.
here is the code
Код:
if((newkeys & (KEY_ACTION | KEY_HANDBRAKE)) == (KEY_ACTION | KEY_HANDBRAKE) && (oldkeys & (KEY_ACTION | KEY_HANDBRAKE)) != (KEY_ACTION | KEY_HANDBRAKE))
{
// MY FUNCITON WILL BE HERE
}
Re: [HELP] hold and press a key at the same time -
CobraWoW - 12.03.2019
Quote:
Originally Posted by ******
|
I tried that, but its only the reverse
doesn't work with holding ctrl and pressing space
but work with holding space and pressing ctrl
idk what is the meaning of this
Re: [HELP] hold and press a key at the same time -
CobraWoW - 13.03.2019
Quote:
Originally Posted by ******
I think the problem is the confusion of terms between holding and pressing. If you just want to activate when both are pressed, check both are pressed:
Код:
if (PRESSED(KEY_ACTION | KEY_HANDBRAKE))
{
}
|
Still the same result
Tschh..
Re: [HELP] hold and press a key at the same time -
NaS - 13.03.2019
Код:
if((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE) && (newkeys & KEY_ACTION))
This will react only if KEY_HANDBRAKE is pressed but wasn't pressed before and KEY_ACTION is already pressed.
Re: [HELP] hold and press a key at the same time -
CobraWoW - 13.03.2019
Quote:
Originally Posted by NaS
Код:
if((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE) && (newkeys & KEY_ACTION))
This will react only if KEY_HANDBRAKE is pressed but wasn't pressed before and KEY_ACTION is already pressed.
|
I fixed it, the problem was that
another "if(KeyPressed(KEY_HANDBRAKE))" was placed before "if(KeyHeld(KEY_ACTION) && KeyPressed(KEY_HANDBRAKE))"
Thanks ****** & THANKS Nas!