if-else or switch? Whats better?
#1

Ahoy friends.

Im trying to do this

Код:
		switch(TEAMSIZE)
		{
		case >=2:
		{
			switch(gPlayerTeamSelection[playerid])
			{
				case 1:
				{
				SetPlayerColor(playerid,COLOR_TEAM_ONE);	
				}
				case 2:
				{
				SetPlayerColor(playerid,COLOR_TEAM_TWO);	
				}
			}
		}
		case >=3:
		{
			switch(gPlayerTeamSelection[playerid])
			{
				case 3:
				{
				SetPlayerColor(playerid,COLOR_TEAM_THREE);	
				}
			}
		}
		case >=4:
		{
			switch(gPlayerTeamSelection[playerid])
			{
				case 3:
				{
				SetPlayerColor(playerid,COLOR_TEAM_FOUR);	
				}
			}
		}
		case >=5:
		{
			switch(gPlayerTeamSelection[playerid])
			{
				case 3:
				{
				SetPlayerColor(playerid,COLOR_TEAM_FIVE);	
				}
			}
		}
		case >=6:
		{
			switch(gPlayerTeamSelection[playerid])
			{
				case 3:
				{
				SetPlayerColor(playerid,COLOR_TEAM_SIX);	
				}
			}
		}
Can i use >=6 in switch case or do i have to use if-else-if ? Because according to the compiler its an invalid expression

Maybe someone can help to find the best way
Reply
#2

You must use case 6..max_next_value:

example
case 6..10:
Reply
#3

So its better to use if-else if i want to check if something is less or equal?
Or can you give an example?

So i could use case 2..6: ?

Ah now i saw your example.. i will try
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)