[HELP] What am i doing wrong (GetPlayerKeys)
#5

The keys are a set of bits. Multiple keys/buttons can be pressed at the same time. So rather than using == or - you should use bitwise &.

pawn Код:
if(keys == KEY_JUMP) { ..
That detects if only the jump key is pressed and no other keys. For example, that condition would be false if the player pressed both KEY_SPRINT and KEY_JUMP at the same time.

pawn Код:
if(keys & KEY_JUMP) { ..
That detects if the KEY_JUMP key is pressed in combination with any other key.

pawn Код:
IsKeyJustDown(key, newkeys, oldkeys)
{
    if((newkeys & key) && !(oldkeys & key)) return 1;
    return 0;
}
Reply


Messages In This Thread
[HELP] What am i doing wrong (GetPlayerKeys) - by Dirty_bum - 25.09.2009, 02:24
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Toribio - 25.09.2009, 02:46
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Dirty_bum - 25.09.2009, 03:09
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Stepashka - 25.09.2009, 07:29
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Kalcor - 25.09.2009, 07:45
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Stepashka - 25.09.2009, 08:03
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Kalcor - 25.09.2009, 08:53
Re: [HELP] What am i doing wrong (GetPlayerKeys) - by Stepashka - 25.09.2009, 09:25

Forum Jump:


Users browsing this thread: 1 Guest(s)