SA-MP Forums Archive
[BUG] bit logical product - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [BUG] bit logical product (/showthread.php?tid=101426)



[BUG] bit logical product - raven.yz - 10.10.2009

I have problem with the keys in the 0.3 (do not know whether the bug is in 0.2), you see the operator & does not work with positive numbers, example:

Код:
	GetPlayerKeys(playerid, Arrays[tmpInt][0], Arrays[tmpInt][1], Arrays[tmpInt][2]);

	if(Arrays[tmpInt][1] & KEY_UP)
	{
		print("UP");
		return 1;
	}

	if(Arrays[tmpInt][1] & KEY_DOWN)
	{
		print("DOWN");
		return 1;
	}

	if(Arrays[tmpInt][2] & KEY_LEFT)
	{
		print("LEFT");
		return 1;
	}

	if(Arrays[tmpInt][2] & KEY_RIGHT)
	{
		print("RIGHT");
		return 1;
	}
if I press UP key, console shows UP (good)
if I press DOWN key, console show UP too (bad)
if I press LEFT key, console show LEFT (good)
if I press RIGHT key, console show LEFT too (bad)

Код:
#define KEY_UP					(-128)
#define KEY_DOWN				(128)
#define KEY_LEFT				(-128)
#define KEY_RIGHT				(128)
if I change & to ==, it works good


Re: [BUG] bit logical product - raven.yz - 10.10.2009

but I've wanted with &, cause with ==, not works if player pressed another keys too

and bugs should be fixed


Re: [BUG] bit logical product - NeRoSiS - 10.10.2009

Try using &&