OnPlayerKeyStateChange reacts to Enter multiple times
#1

Why is OnPlayerKeyStateChanged called a few times when I press Enter even though I use

if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
{
Reply
#2

I've faced this bug as well. However when you press F instead of Enter, it seems to work fine. Haven't found any clue for this yet, but I think there's a way around.
Reply
#3

Eyo.
Add
pawn Код:
break;
at the end of it.
Np
Reply
#4

Quote:
Originally Posted by justjamie
Посмотреть сообщение
Eyo.
Add
pawn Код:
break;
at the end of it.
Np
Dude, before posting those pointless replies please read the topic.
"break" doesnt do anything here, it's not a loop.

It's a known bug by the way.
Reply
#5

pawn Код:
// ** INCLUDES

#include <a_samp>

// ** DEFINES

// *** KEY SIMULATIONS

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

// ** MAIN

main()
{
    print("Loaded \"on_player_key_state_change_enter.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    {
        SendClientMessage(playerid, -1, "You have pressed \"ENTER\"!");
    }
    return 1;
}
Called once.
Reply
#6

Even though I usually use what SickAttack posted (a PRESSED macro), I tried it with your code:
Код:
if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
And it was only calling once per click.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)