Can't detect KEY_UP and KEY_DOWN
#1

Hello, I'm trying to detect these two(and more) keys, everything is alright with KEY_LEFT and KEY_RIGHt, but with UP and DOWN it's just weird.

I added some prints, and it prints when I press RMB, it prints when I press space, but not when i press arrows up/down...

My code
pawn Код:
if((newkeys & KEY_UP) && !(oldkeys & KEY_UP))
    {
        GetPlayerObjectPos(pid,Object,coo[0],coo[1],coo[2]);
        SetPlayerObjectPos(pid,Object,coo[0]+10.0,coo[1],coo[2]);
        printf("KEY UP");
    }
    else if((newkeys & KEY_DOWN) && !(oldkeys & KEY_DOWN))
    {
        GetPlayerObjectPos(pid,Object,coo[0],coo[1],coo[2]);
        SetPlayerObjectPos(pid,Object,coo[0]-10.0,coo[1],coo[2]);
        printf("KEY_DOWN");
    }
I did not redefine my keyboard. It's default
Reply
#2

Researching and - above all - actually reading the information will solve questions most of the time. https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Quote:

Directional keys do not trigger OnPlayerKeyStateChange (up/down/left/right).

Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Researching and - above all - actually reading the information will solve questions most of the time. https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
But left/right did trigger it :/

Do you have any ideas what could i use instead?
Reply
#4

I know that you can use GetPlayerKeys to determine whether keys are being pressed, but I don't see a very efficient way of its use.

https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
I know that you can use GetPlayerKeys to determine whether keys are being pressed, but I don't see a very efficient way of its use.

https://sampwiki.blast.hk/wiki/GetPlayerKeys
I failed detecting KEY_UP and KEY_DOWN with that aswell, although i did it EXACTLY the way it in the example :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)