using switch
#1

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?
Reply
#2

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

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.
Reply
#4

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)