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



using switch - kazai - 30.10.2009

can someone help me with this code?

Код:
		zang = floatround(zang);
		switch(zang)
		{
			case 0: SendClientMessage(playerid,0xFFFFFFFF,"test1");
			case 1 .. 89: SendClientMessage(playerid,0xFFFFFFFF,"test2");

			case 90: SendClientMessage(playerid,0xFFFFFFFF,"test3");

			case 91 .. 179: SendClientMessage(playerid,0xFFFFFFFF,"test4");

			case 180: SendClientMessage(playerid,0xFFFFFFFF,"test5");

			case 181 .. 269: SendClientMessage(playerid,0xFFFFFFFF,"test6");

			case 270: SendClientMessage(playerid,0xFFFFFFFF,"test7");

			case 271 .. 359: SendClientMessage(playerid,0xFFFFFFFF,"test8");

		}
i haven't provided all of it for obvious reasons, but the main problem is is that it doesnt detect the .. case's, so test2, test4, test6 and test8 dont come up. it is using a rounded zang which i get from GetPlayerFacingAngle, so i dont know why it doesnt work :\

can anyone explain why it doesnt work for test2, test4, test6 and test8? and provide a working example?


Re: using switch - Sergei - 30.10.2009

You can't do '555 ... 666' and expect that it will include all numbers between those.


Re: using switch - kazai - 30.10.2009

then what do i use? i know it is possible to do every single number between 0 and 360 but that is pointless and i dont need to do that anyway due to my code.


Re: using switch - Google63 - 30.10.2009

Quote:
Originally Posted by $ЂЯĢ
You can't do '555 ... 666' and expect that it will include all numbers between those.
It will, because in compile-time there isn't any possible way to know what value will contain variable "zang"(as it may change), if you do "pawncc -a file.pwn" you will see that all cases are listed...