SA-MP Forums Archive
Pressing and releasing UD and LR - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pressing and releasing UD and LR (/showthread.php?tid=262928)



Pressing and releasing UD and LR - Zh3r0 - 19.06.2011

How do I check when I release for example the 'W' key (forward or any of the buttons that orientates you?

I tried the GetPlayerKeys example, but can't seem to make it work, also tried the KEY_UP/DOWN/LEFT/RIGHT definitons. Didn't work, I tried them with PRESSED and RELEASED macro, same thing, doesn't detect them. Any ideas?


My code.
pawn Код:
if(PRESSED(KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT)) Pressed
else if(RELEASED(KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT)) Released
If I use another key, like KEY_ACTION or KEY_CROUCH, it works.


Re: Pressing and releasing UD and LR - PrawkC - 19.06.2011

Are you using the OnPlayerKeState callback? because as it says on the wiki

"OnPlayerKeyStateChange will be called each time a key state is changed. It will never be called for up, down, left and right."


Re: Pressing and releasing UD and LR - Calgon - 20.06.2011

Keys: Up, down, left and right do not call OnPlayerKeyStateChange.

You can move the code over to OnPlayerUpdate or a timer to detect when the key combinations are pressed.


Re: Pressing and releasing UD and LR - Zh3r0 - 20.06.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Keys: Up, down, left and right do not call OnPlayerKeyStateChange.

You can move the code over to OnPlayerUpdate or a timer to detect when the key combinations are pressed.
I know that way, but I can only make it being pressed but not released...