Help with multiple key detection - 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 with multiple key detection (
/showthread.php?tid=571872)
Help with multiple key detection -
IKnowWhatIAmDoing - 23.04.2015
I am trying to do it so that if you press Y and H at the same time it will trigger some code to work.
if (PRESSED( KEY_YES | KEY_CTRL_BACK))
It doesn't work.
Re: Help with multiple key detection -
JaydenJason - 23.04.2015
What's your code for "PRESSED"?
Re: Help with multiple key detection -
IKnowWhatIAmDoing - 23.04.2015
Quote:
Originally Posted by JaydenJason
What's your code for "PRESSED"?
|
#if !defined PRESSED
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#endif
Re: Help with multiple key detection -
JaydenJason - 23.04.2015
Code:
if(PRESSED(KEY_YES) && PRESSED(KEY_CTRL_BACK))
{
// code ere
}
Re: Help with multiple key detection -
IKnowWhatIAmDoing - 23.04.2015
pawn Code:
if (PRESSED( KEY_YES | KEY_CTRL_BACK))
{
printf("called");
}
There's currently no code, I am reserving the key combinations for further use, the code to execute is not ready yet. However, for testing sake, I got the code above at the moment.
Quote:
Originally Posted by JaydenJason
Code:
if(PRESSED(KEY_YES) && PRESSED(KEY_CTRL_BACK))
{
// code ere
}
|
This doesn't work.
Re: Help with multiple key detection -
PowerPC603 - 23.04.2015
Your code may be ok, but some keyboards don't accept multiple keypresses with characters (the alphabet characters).
Pressing Y + H are 2 character keys at once and may not work.
Pressing multiple special keys (CTRL, ALT, SHIFT) along with a character key is allowed on most keyboards (if not all), but not multiple character keys.
Some of your players may not be able to execute your code because their keyboard doesn't support it.
Yours might not accept it either and your code will not trigger.
Re: Help with multiple key detection -
IKnowWhatIAmDoing - 23.04.2015
Quote:
Originally Posted by PowerPC603
Your code may be ok, but some keyboards don't accept multiple keypresses with characters (the alphabet characters).
Pressing Y + H are 2 character keys at once and may not work.
Pressing multiple special keys (CTRL, ALT, SHIFT) along with a character key is allowed on most keyboards (if not all), but not multiple character keys.
Some of your players may not be able to execute your code because their keyboard doesn't support it.
Yours might not accept it either and your code will not trigger.
|
You are right, thanks a lot!