21.03.2017, 15:57
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
isEnd() function to call TeamsAlive
Or massive if statements
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; }
Код:
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: { } } }
Код:
#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