SA-MP Forums Archive
OnPlayerKeyChange - 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: OnPlayerKeyChange (/showthread.php?tid=554734)



OnPlayerKeyChange - n00el - 04.01.2015

Hello. I have an error with OnPlayerKeyCahgen..

When i press KEY_CTRL_BACK its print z-, up, left
WHen i press KEY_NO its print z+, up, left
And when press KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT its not print anything.. Why? Someone please help me... Thanks!

Код:
	if (PRESSED( KEY_CTRL_BACK ))
	{
        printf("z+");
	}
	if (PRESSED( KEY_NO ))
	{
        printf("z-");
	}
 	if (PRESSED( KEY_UP ))
	{
		printf("up");
	if ((newkeys & KEY_DOWN) && !(oldkeys & KEY_DOWN))
	{
        printf("down");
	}
 	if ((newkeys & KEY_LEFT) && !(oldkeys & KEY_LEFT))
	{
        printf("left");
	}
 	if ((newkeys & KEY_RIGHT) && !(oldkeys & KEY_RIGHT))
	{
		printf("right");
	}



AW: OnPlayerKeyChange - Sascha - 04.01.2015

UP DOWN LEFT and RIGHT can only be detected with GetPlayerKeys, not via OnPlayerKeyStateChange

look here for an example:
https://sampwiki.blast.hk/wiki/GetPlayerKeys