Problem with keys
#1

PHP код:
    if(IsKeyJustDown(KEY_UP,newkeys,oldkeys) && Viewing[playerid] != && ViewingCar[playerid] != 0)
    { 
and
PHP код:
    if(IsKeyJustDown(KEY_DOWN,newkeys,oldkeys) && Viewing[playerid] != && ViewingCar[playerid] != 0)
    { 
Both of them start operating when I click CAPSLOCK/the right button on my mouse but they won't work when I actually use the keys, I already tried with KEY_LEFT & KEY_RIGHT...
Reply
#2

You need to post more code. What is the IsKeyJustDown() method?
Reply
#3

PHP код:
IsKeyJustDown(keynewkeysoldkeys)
{
    if((
newkeys key) && !(oldkeys key)) return 1;
    return 
0;

It wasn't made by me.
Reply
#4

Oh, looks like you're passing in the keys from OnPlayerKeyStateChange. Those keys are different keys to the direction keys.

The KEY_DOWN, KEY_UP, KEY_LEFT and KEY_RIGHT don't work in OnPlayerKeyStateChange. You're required to use GetPlayerKeys(...). Maybe on a timer or OnPlayerUpdate, whichever suits your needs. If you wanted to detect direction keys, you would be required to do something like this:

pawn Код:
new keys, updown, leftright;

GetPlayerKeys(playerid, keys, updown, leftright);

if (updown > 0)  {
    // key_up
} else if (leftright < 0) {
    // key_down
}

if (leftright > 0) {
    // key_right
} else if (leftright < 0) {
    // key_left
}
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)