function should return a value? But i use return..
#3

Ah so what do i have to do in my case to fix this problem?

I never worked with bool before

And btw. which way is better?
I wrote 3 blocks for the same problem


Код:
stock TeamsAlive(bool:value)
{
	new i=0,count=0;
	while(i<TEAMSIZE)
	{
		if(GetTeamCount(i) > 0)
		{
			count++;
		}
		i++;	
	}
	if(bool:value == false)
	switch(count)
	{
		case 1:
		{
			switch(TeamsAlive(true))
			{
				case FIRST_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
					}	
				}
				case SECOND_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
					}	
				}
				#if defined TEAMSIZE
				#if TEAMSIZE >= 3
				case THIRD_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE >= 4
				case FOURTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE >= 5
				case FIFTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE == 6
				case SIXTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
			}
		}
	}
	if(bool:value == true && count == 1)//Returns the ID of the remaining team
	return i;
	
}
isEnd() function to call TeamsAlive

Код:
stock TeamsAlive(bool:value)
{
	new i=0,count=0;
	while(i<TEAMSIZE)
	{
		if(GetTeamCount(i) > 0)
		{
			count++;
		}
		i++;	
	}
	if(bool:value == false)//Returns the amount of remaining teams
	return count;
	if(bool:value == true && count == 1)//Returns the ID of the remaining team
	return i;
	
}


stock isEnd()
{
	switch(TeamsAlive(false))
	{
	case 0:
		{
			SendClientMessageToAll(COLOR_WHITE,"SERVER: All teams have been wiped. No one has won the game!");
		}
	case 1:
		{
			switch(TeamsAlive(true))
			{
			case FIRST_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
					}	
				}
			case SECOND_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
					}	
				}
				#if defined TEAMSIZE
				#if TEAMSIZE >= 3
			case THIRD_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE >= 4
			case FOURTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE >= 5
			case FIFTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
				#if defined TEAMSIZE
				#if TEAMSIZE == 6
			case SIXTH_TEAM:
				{
					for(new i;i<MAX_PLAYERS;i++)
					{
						SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
					}	
				}
				#endif
				#endif
			}
			printf("Total game time: %d",totaltime);
			SendRconCommand("gmx");
		}
	default:
		{
			
		}
		
	}
	
}
Or massive if statements
Код:
#if defined TEAMSIZE
	#if TEAMSIZE == 2
	if(GetTeamCount(FIRST_TEAM) > 0 && GetTeamCount(SECOND_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) > 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	#endif
	#endif
	
	#if defined TEAMSIZE
	#if TEAMSIZE == 3
	if(GetTeamCount(FIRST_TEAM) > 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
		}	
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) > 0 && GetTeamCount(THIRD_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) > 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	#endif
	#endif
	#if defined TEAMSIZE
	#if TEAMSIZE == 4
	if(GetTeamCount(FIRST_TEAM) > 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");		
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) > 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) > 0 && GetTeamCount(FOURTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) > 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	#endif
	#endif
	
	#if defined TEAMSIZE
	#if TEAMSIZE == 5
	if(GetTeamCount(FIRST_TEAM) > 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM)== 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) > 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM)== 0)
	{	
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) > 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM)== 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) > 0 && GetTeamCount(FIFTH_TEAM)== 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM) > 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	#endif
	#endif
	
	#if defined TEAMSIZE
	#if TEAMSIZE == 6
	if(GetTeamCount(FIRST_TEAM) > 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM) == 0 && GetTeamCount(SIXTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) > 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM)== 0 && GetTeamCount(SIXTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) > 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM)== 0 && GetTeamCount(SIXTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) > 0 && GetTeamCount(FIFTH_TEAM)== 0 && GetTeamCount(SIXTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM) > 0 && GetTeamCount(SIXTH_TEAM) == 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);	
		}
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	if(GetTeamCount(FIRST_TEAM) == 0 && GetTeamCount(SECOND_TEAM) == 0 && GetTeamCount(THIRD_TEAM) == 0 && GetTeamCount(FOURTH_TEAM) == 0 && GetTeamCount(FIFTH_TEAM) == 0 && GetTeamCount(SIXTH_TEAM) > 0)
	{
		for(new i;i<MAX_PLAYERS;i++)
		{
			SendClientMessageEx(i,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
		}	
		printf("Total game time: %d",totaltime);
		SendRconCommand("gmx");
	}
	#endif
	#endif
Reply


Messages In This Thread
function should return a value? But i use return.. - by faxxe - 21.03.2017, 15:34
Re: function should return a value? But i use return.. - by SyS - 21.03.2017, 15:41
Re: function should return a value? But i use return.. - by faxxe - 21.03.2017, 15:57
Re: function should return a value? But i use return.. - by SyS - 21.03.2017, 17:00
Re: function should return a value? But i use return.. - by OneDay - 21.03.2017, 22:08

Forum Jump:


Users browsing this thread: 1 Guest(s)