OnPlayerKeyStateChange reacts to Enter multiple times - 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)
+--- Thread: OnPlayerKeyStateChange reacts to Enter multiple times (
/showthread.php?tid=608463)
OnPlayerKeyStateChange reacts to Enter multiple times -
ax1 - 01.06.2016
Why is OnPlayerKeyStateChanged called a few times when I press Enter even though I use
if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
{
Re: OnPlayerKeyStateChange reacts to Enter multiple times -
Sjn - 01.06.2016
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.
Re: OnPlayerKeyStateChange reacts to Enter multiple times -
justjamie - 01.06.2016
Eyo.
Add
at the end of it.
Np
Re: OnPlayerKeyStateChange reacts to Enter multiple times -
NaS - 01.06.2016
Quote:
Originally Posted by justjamie
Eyo.
Add 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.
Re: OnPlayerKeyStateChange reacts to Enter multiple times -
SickAttack - 01.06.2016
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.
Re: OnPlayerKeyStateChange reacts to Enter multiple times -
Stinged - 01.06.2016
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.