Raised This Month: $51 Target: $400
 12% 

{ Else } Does not get executed when others are false.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AwesomeMan
Member
Join Date: Jun 2013
Old 06-18-2013 , 14:33   { Else } Does not get executed when others are false.
Reply With Quote #1

Hey, I am working on a plugin but then I came across error I spent hours trying to fix it. No luck.
Code:
public voteend()
{
	g_Voteinuse = 0
	new players[32], pnum, tempid;
	
	get_players( players, pnum );
	
	for ( new i; i < pnum; i++ )
	{
		tempid = players[i];
	
		show_menu( tempid, 0, "^n", 1);
	}
	if ((g_voteone > g_votetwo) &&
		(g_voteone > g_votethree) &&
		(g_voteone > g_votefour) &&
		(g_voteone > g_votefive) &&
		(g_voteone > g_votesix) &&
		(g_voteone > g_voteseven)) {
			client_print(0, print_chat, "Option 1, %s, has won the vote %s with %d votes.", g_aarg1, g_question, g_voteone);
		}else if ((g_votetwo > g_voteseven) &&
		(g_votetwo > g_voteone) &&
		(g_votetwo > g_votethree) &&
		(g_votetwo > g_votefour) &&
		(g_votetwo > g_votefive) &&
		(g_votetwo > g_votesix)) {
			client_print(0, print_chat, "Option 2, %s, has won the vote %s with %d votes.", g_aarg2, g_question, g_votetwo);
		}else if ((g_votethree > g_voteone) &&
		(g_votethree > g_votetwo) &&
		(g_votethree > g_votefour) &&
		(g_votethree > g_votefive) &&
		(g_votethree > g_votesix) &&
		(g_votethree > g_voteseven)) {
			client_print(0, print_chat, "Option 3, %s, has won the vote %s with %d votes.", g_aarg3, g_question, g_votethree);
		}else if ((g_votefour > g_voteone) &&
		(g_votefour > g_votetwo) &&
		(g_votefour > g_votethree) &&
		(g_votefour > g_votesix) &&
		(g_votefour > g_votefive) &&
		(g_votefour > g_voteseven)) {
			client_print(0, print_chat, "Option 4, %s, has won the vote %s with %d votes.", g_aarg4, g_question, g_votefour);
		}else if ((g_votefive > g_voteone) &&
		(g_votefive > g_votetwo) &&
		(g_votefive > g_votethree) &&
		(g_votefive > g_votefour) &&
		(g_votefive > g_votesix) &&
		(g_votefive > g_voteseven)) {
			client_print(0, print_chat, "Option 5, %s, has won the vote %s with %d votes.", g_aarg5, g_question, g_votefive);
		}else if ((g_votesix > g_voteone) &&
		(g_votesix > g_votetwo) &&
		(g_votesix > g_votethree) &&
		(g_votesix > g_votefour) &&
		(g_votesix > g_votefive) &&
		(g_votesix > g_voteseven)) {
			client_print(0, print_chat, "Option 6, %s, has won the vote %s with %d votes.", g_aarg6, g_question, g_votesix);
		}else if ((g_voteseven > g_voteone) &&
		(g_voteseven > g_votetwo) &&
		(g_voteseven > g_votethree) &&
		(g_voteseven > g_votefour) &&
		(g_voteseven > g_votefive) &&
		(g_voteseven > g_votesix)) {
			client_print(0, print_chat, "Option 7, %s, has won the vote %s with %d votes.", g_aarg7, g_question, g_voteseven);
		}else {
			client_print(0, print_chat, "%s - Two or more votes won, Displaying all votes:");
			client_print(0, print_chat, "Option 1: %s has received %d votes. %s", g_aarg1, g_voteone, g_Arg1);
			client_print(0, print_chat, "Option 2: %s has received %d votes. %s", g_aarg2, g_votetwo, g_Arg2);
			client_print(0, print_chat, "Option 3: %s has received %d votes. %s", g_aarg3, g_votethree, g_Arg3);
			client_print(0, print_chat, "Option 4: %s has received %d votes. %s", g_aarg4, g_votefour, g_Arg4);
			client_print(0, print_chat, "Option 5: %s has received %d votes. %s", g_aarg5, g_votefive, g_Arg5);
			client_print(0, print_chat, "Option 6: %s has received %d votes. %s", g_aarg6, g_votesix, g_Arg6);
			client_print(0, print_chat, "Option 7: %s has received %d votes. %s", g_aarg7, g_voteseven, g_Arg7);
			return PLUGIN_HANDLED;
		}
	return PLUGIN_HANDLED;
}
When all "else if" are false, the else does not get executed. Nothing just happens. Any help?
AwesomeMan is offline
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 06-18-2013 , 17:32   Re: { Else } Does not get executed when others are false.
Reply With Quote #2

Select the highest vote variable and then Use a switch.

Last edited by XINLEI; 06-18-2013 at 17:34.
XINLEI is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-18-2013 , 23:52   Re: { Else } Does not get executed when others are false.
Reply With Quote #3

Do as XINLEI said. Also, you can see how this is done in mapchooser.sma (Hint: It's a very simple for loop).
__________________

Last edited by fysiks; 06-18-2013 at 23:52.
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode