Posts: 737
Threads: 338
Joined: Jan 2013
Hi,
Why this code doesn't work?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( PRESSED( KEY_UP ) )
{
SendClientMessage(playerid,-1,"ASDASDASD");
}
return 1;
}
Why when I press ↑ i don't get this message?
Posts: 737
Threads: 338
Joined: Jan 2013
But how to know when player release ↑ ? Yes, when i use onplayerupdate, then i get message, but i need to know, when player press that arrow, or release.
Posts: 11,827
Threads: 33
Joined: Dec 2011
Reputation:
0
I'm not sure if that would work, checking if the ud is not equal to KEY_UP. I've not used them before, but give a try.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
You need to store their previous key state and compare it with the new state to figure out whether they pressed or released the key. Values are -128 for down and left, 128 for up and right and 0 for nothing. However, if the player is using a joypad then the value may be anywhere between these limits.