Jump to content
  • 0

Voting Poll NPC ( BUG )


awesomazingxed

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Hello everyone, i just found a bug in this script.

Everytime I create or add a vote poll it keeps saying "vote exceeded"

Thank you so much.

//===== eAthena Script =======================================
//= Vote NPC
//===== By ===================================================
//= llchrisll
//===== Version ==============================================
//= 1.0 - Script Made
//= 1.1 - Added missing check for Vote Limit
//===== Compatible With ======================================
//= Every eAthena Version
//===== Description ==========================================
//= This script can create/delete/reset votes.
//  Config has been made as dynamically as possible.
//	Delay, Max Answers, Max Votes at once, Max letters per Vote,
//	Max letters per Answers can be set too.
//	See 'OnInit'.
//===== Comments =============================================
//= Request (http://rathena.org/board/topic/57438-request-vote-npc/'>http://rathena.org/board/topic/57438-request-vote-npc/)
//	by PapaZola (http://rathena.org/board/user/682-papazola/'>http://rathena.org/board/user/682-papazola/)
//	in the rAthena Board (http://rathena.org/board)
//============================================================
turbo_room,104,121,4	script	Vote Poll NPC	858,{

mes .n$;
mes "Hello, "+strcharinfo(0)+".";
if(getgmlevel() < .gm) {
	DoVote:
	if(getarraysize($vote_q$) < 1) {
		mes "I'm sorry, there is no vote yet.";
		close;
	}
	if(gettimetick(2) < #vote_del) {
		mes "You can't vote again, please wait the delay is over.";
		close;
		
	} else if(.vote_limit == 1 && #vote_l == 1) {
		mes "I'm sorry, but you voted already.";
		close;
	}
	mes "Please select which vote you want to participate in:";
	mes "^FF0000Note: Vote Delay " + ( (.vote_delay/60 >= 60)?.vote_delay/3600+" hours.":.vote_delay/60+" minutes");
	mes ( (.vote_limit == 1)?"You can only vote once per vote.^000000":"You can vote more than once after the delay has passed.^000000");
	set @v_menu$,"";
	for ( set .@l,0; .@l < getarraysize($vote_q$); set .@l,.@l + 1)
		set @v_menu$,@v_menu$ + "- "+$vote_q$[.@l] + ( ($vote_q$[.@l+1] != "")?":":"");
		
	next;
	set .@v,select(@v_menu$) - 1;
	
	mes .n$;
	set @a_menu$,"";
	for ( set .@a,1; .@a < getd("$vote_q"+.@v+"_at"); set .@a,.@a + 1) 
		set @a_menu$,@a_menu$ + "- "+getd("$vote_q"+.@v+"_a"+.@a+"$") + ( (getd("$vote_q"+.@v+"_a"+(.@a+1)+"$") != "")?":":"");
	
	mes $vote_q$[.@v];
	next;
	set .@a,select(@a_menu$);
	mes .n$;
	mes "Thank you for participating in this vote.";
	mes "I appreciate it.";
	setd("$vote_q"+.@d+"_v"+.@a),getd("$vote_q"+.@d+"_v"+.@a) + 1;
	if(.vote_limit == 0) 
		set #vote_del,gettimetick(2) + .vote_delay;
	else
		set #vote_l,1;
	close;
	
} else {
	mes "How may I help you today?";
	mes " ";
	if(getarraysize($vote_q$) < 1) mes "Currently there are no Votes running.";
	else {
		mes "Currently there are the following Votes running:";
		mes "====================";
		for ( set .@q,0; .@q < getarraysize($vote_q$); set .@q,.@q + 1) {
			mes (.@q + 1) + ". "+$vote_q$[.@q];
			mes ( ($vote_q$[.@q+1] != "")?"---------------------":"====================");
		}
	}
	next;
	switch(select("- View Vote Results:- Add Vote:- Delete Vote:- Reset Vote:- Delete All Votes:- Vote:- Nevermind")) {
	
		case 1:
		mes .n$;
		mes "Here are the current Vote Results!";
		next;
		mes "====================";
		for(set .@d,0; .@d < getarraysize($vote_q$); set .@d,.@d + 1) {
			mes $vote_q$[.@d]+":";
			set .@a,1;
			while( .@a < getd("$vote_q"+.@d+"_at")) {
				mes getd("$vote_q"+.@d+"_a"+.@a+"$")+": "+getd("$vote_q"+.@d+"_v"+.@a);
				set .@a,.@a + 1;
			}
			mes ( ($vote_q$[.@d+1] != "")?"---------------------":"====================");
		}
		close;
	
		case 2:
		mes .n$;
		if(getarraysize($vote_q$) == .votes) {
			mes "I'm sorry, but the maxium of votes you can create has been reached.";
			mes "Please delete one first before creating a new one.";
			close;
		}
		mes "Please state the question for the Vote please.";
		mes "Maximum is "+.vote_q_max+" letters.";
		next;
		if(input(.@v_name$,1,.vote_q_max) != 0) {
			mes .n$;
			mes "The question you have put is too long.";
			mes "Please choose a shorter one.";
			close;
		}

		set @a,1;
		while( @a <= .vote_a) {
			mes .n$;
			mes "Possible Answer #"+@a+"/"+.vote_a+":";
			mes "Maximum "+.vote_a_max+" letters.";
			next;
			if(input(getd(".@v_a"+@a+"$"),1,.vote_a_max) != 0) {
				mes .n$;
				mes "Error: Maximum "+.vote_a_max+" letters.";
				next;
				continue;
			}
			if(getd(".@v_a"+@a+"$") != "") {
				setd("$vote_q"+getarraysize($vote_q$)+"_a"+@a+"$"),getd(".@v_a"+@a+"$");
				set @a,@a + 1;
			}
		}
		setd("$vote_q"+getarraysize($vote_q$)+"_at"),@a; // Total Answers of the vote
		setarray $vote_q$[getarraysize($vote_q$)],.@v_name$;
		mes .n$;
		mes "New Vote, "+.@v_name$+", has been created.";
		close;
		
		case 3:
		mes .n$;
		mes "Please select which vote you want to delete:";
		set @v_menu$,"";
		for ( set .@l,0; .@l < getarraysize($vote_q$); set .@l,.@l + 1)
			set @v_menu$,@v_menu$ + "- "+$vote_q$[.@l] + ( ($vote_q$[.@l+1] != "")?":":"");
			
		next;
		set .@v,select(@v_menu$) - 1;
		
		mes .n$;
		mes "Chosen Vote: \""+$vote_q$[.@v]+"\"";
		mes "Correct?";
		if(select("- Yes:- No") - 1) close;
		next;
		mes .n$;
		mes "I will now delete this vote.";
		close2;
		set .@a,1;
		while( .@a != getd("$vote_q"+.@v+"_at")) {
			setd("$vote_q"+.@v+"_a"+.@a+"$"),"";
			setd("$vote_q"+.@v+"_v"+.@a),0;
			set .@a,.@a + 1;
		}
		setd("$vote_q"+.@v+"_at"),0;
		deletearray $vote_q$[.@v],1;
		end;
		
		case 4:
		mes .n$;
		mes "Please select which vote you want to reset:";
		set @v_menu$,"";
		for ( set .@l,0; .@l < getarraysize($vote_q$); set .@l,.@l + 1)
			set @v_menu$,@v_menu$ + "- "+$vote_q$[.@l] + ( ($vote_q$[.@l+1] != "")?":":"");
			
		next;
		set .@v,select(@v_menu$) - 1;
		
		mes .n$;
		mes "Chosen Vote: \""+$vote_q$[.@v]+"\"";
		mes "Correct?";
		if(select("- Yes:- No") - 1) close;
		next;
		mes .n$;
		mes "I will now reset this vote.";
		close2;
		set .@a,1;
		while( .@a != getd("$vote_q"+.@v+"_at")) {
			setd("$vote_q"+.@v+"_v"+.@a),0;
			set .@a,.@a + 1;
		}
		end;
		
		case 5:
		mes .n$;
		mes "Do you really delete every vote?";
		if(select("- Yes:- No") - 1) close;
		for(set .@d,0; .@d < getarraysize($vote_q$); set .@d,.@d + 1) {
			set .@a,1;
			while( .@a != getd("$vote_q"+.@d+"_at")) {
				setd("$vote_q"+.@d+"_a"+.@a+"$"),"";
				setd("$vote_q"+.@d+"_v"+.@a),0;
				set .@a,.@a + 1;
			}
			setd("$vote_q"+.@d+"_at"),0;
		}
		deletearray $vote_q$[0],128;
		close;
		
		case 6:
		mes .n$;
		goto DoVote;
		
		case 7:
		close;
	}
}

OnInit:
waitingroom "Voting Poll",0;
end;
}
set .n$,"["+strnpcinfo(1)+"]";
set .votes,10; // Max Votes at the same time, Maximum 128!!!
set .vote_q_max,100; // Maxium letters for the question
set .vote_a,2; // Max Answers possible
set .vote_a_max,100; // Maxium letters for the answers
set .vote_delay,86400; // Delay in seconds, default 1 day (86400 Seconds)
set .vote_limit,1; // Each player can only once per Vote: 1 = On / 0 = Off
set .gm,60; // GM Access Level
end;
}

Edited by awesomazingxed
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

I found a fix.


turbo_room,104,121,4	script	Vote Poll NPC	858,{
set @np$,"[ ^7401DFSandra^000000 ]";
if ( getgmlevel() == 99 ) {
if ( $survey_running ) {
switch ( select ( "- Survey Result","- Delete Survey" ) ) {

        case 1:
			mes "- ^8A0808"+$survey_title$+"^000000 -";
			mes $survey_question$;
			mes "";
			for ( set @a,0; @a < getarraysize($survey_option$); set @a,@a+1 ) {
			mes "^0404B4"+$survey_option$[@a]+"^000000 - ^8A0808"+$survey_option_votes[@a]+"^000000 Vote/s";
			}
			close;
         case 2:
                mes @np$;
                mes "Are you sure that you want to delete the survey: ";
                mes "";
                mes "- ^8A0808"+$survey_title$+"^000000 -";
                next;
                if ( select ( "No.","Yes, pretty sure." ) == 1 ) { close; }
                set $survey_running,0;
				set $survey_title$,"^8A0808NOT SET^000000"; 
				set $survey_question$,"";
				set @question_set$,"^8A0808NOT SET^000000";
				for ( set @b,0; @b <= getarraysize($survey_option$)+2; set @b,@b+1 ) {
				set $survey_option$[@b],"";
				set $survey_option_votes[@b],0;
				}
                mes @np$;
                mes "The survey has been deleted successfully.";
                close;
                }
                
		} // Ending bracket to Survey running
		if ( select ( "- Exit","- Create Survey" ) == 1 ) { close; }
		set $survey_title$,"^8A0808NOT SET^000000"; 
		set $survey_question$,"";
		set @question_set$,"^8A0808NOT SET^000000";
		for ( set @b,0; @b <= getarraysize($survey_option$); set @b,@b+1 ) {
		set $survey_option$[@b],"";}
		while ( 1 ) {
			set @subtract,2;
			if ( getarraysize($survey_option$) > 1 ) && ($survey_title$ != "NOT SET") && ( $survey_question$ != "NOT SET") { 
				set @menu_string$,"- Complete";
				set @menu_string$,@menu_string$+":Title [^04B404"+$survey_title$+"^000000]";
				set @subtract,3;
			} else {
				set @menu_string$,"Title [^04B404"+$survey_title$+"^000000]";
				}
			set @menu_string$,@menu_string$+":Question ["+@question_set$+"]";
			for ( set @a,0; @a < getarraysize($survey_option$); set @a,@a+1 ) {
				set @menu_string$,@menu_string$ +":    "+(@a+1)+". ^0404B4"+$survey_option$[@a]+"^000000";
				}
			set @menu_string$,@menu_string$ +":^0AE143+^000000 Add Option";
			mes @np$;
			mes "Do your Survey settings.";
			next;
			set @selected, select ( @menu_string$)-@subtract;
				if ( @selected == -2 ) {
					mes @np$;
					mes "Title:"; 
					mes "^04B404"+$survey_title$+"^000000";
					mes "Question:";
					mes "^04B404"+$survey_question$+"^000000";
					mes "Options:";
					for ( set @b,0; @b <= getarraysize($survey_option$)-1; set @b,@b+1 ) {
					mes (@b+1)+". ^0404B4"+$survey_option$[@b]+"^000000";
					}
				next;
				if ( select ( "No, it is not correct.","Yes, it is correct." ) == 2 ) {
					mes @np$;
					mes "Your Survey started successfully";
					set $vote_id,$vote_id+1;
					set $survey_running,1;
					getmapxy(@map$,@x,@y,1);
					announce "Please see the Survey NPC in "+@map$+" and give us your Vote.",bc_all;
					close;
					}
				}

			if ( @selected == 0) { 
			mes @np$;
			mes "Type in the survey leading question.";
			mes "";
			mes "Current:";
			if ( $survey_question$ == "" ) {
			mes "^8A0808NOT SET^000000";
				} else {
					mes "^04B404"+$survey_question$+"^000000"; }
					next;
					input $survey_question$;
					set @question_set$,"^0AE143SET^000000";
					}

			if ( @selected == -1) { 
				mes @np$;
				mes "Type in the survey title.";
				mes "";
				mes "Current:";
				mes "^04B404"+$survey_title$+"^000000";
				next;
				input $survey_title$;
				}

			if ( @selected == getarraysize($survey_option$)+1) { 
			mes @np$;
			mes "Type in a new option.";
			next;
			input $survey_option$[@selected-1];
			set @selected,@selected+1;
			}

		if ( @selected >= 1 ) && ( @selected < getarraysize($survey_option$)+1) {

		set @selected2, select ( "- Back","- Change","- Delete" );

          if ( @selected2 == 2 ) {
			mes @np$;
			mes "Type in the new option:";
			mes "";
			mes "Current:";
			mes "^0404B4"+$survey_option$[@selected-1]+"^000000";
			next;
			input $survey_option$[@selected-1];
		}
          if ( @selected2 == 3) {

			for ( set @a,@selected-1; @a < getarraysize($survey_option$)-1; set @a,@a+1 ) {
			set $survey_option$[@a],$survey_option$[@a+1];
		}
            set $survey_option$[@a],"";
		}
	}
}
OnInit:
waitingroom "Voting Poll",0;
end;
// GM Settings End
} else {
// Player view
	if ( !$survey_running ) { mes @np$; mes "There is no survey currently running."; close; }
	if ( !getd("##survey_id_"+$vote_id) ) {
		mes @np$;
		mes "Please choose an Option for the following Survey:";
		next;
		while (1) {
		mes "- ^8A0808"+$survey_title$+"^000000 -";
		mes "";
		mes $survey_question$;
		set @menu_string$,"";
		for ( set @a,0; @a < getarraysize($survey_option$); set @a,@a+1 ) {
		set @menu_string$,@menu_string$ +":"+(@a+1)+". ^0404B4"+$survey_option$[@a]+"^000000";
		}
	next;
	set @select, select ( @menu_string$ )-2;
	mes @np$;
	mes "Are you positive with your choice?";
	mes "";
	mes "- ^0404B4"+$survey_option$[@select]+"^000000 -";
	next;
	if ( select ( "Nope","Yeah" ) == 2 ) { 
		set getd("##survey_id_"+($vote_id-1)),0;
		set getd("##survey_id_"+$vote_id),1;
		set $survey_option_votes[@select],$survey_option_votes[@select]+1;
		mes @np$;
		mes "Thank you for your Vote.";
		next;
		break;
		}
	}
}
	if ( getd("##survey_id_"+$vote_id) ) {
		mes "- ^8A0808"+$survey_title$+"^000000 -";
		mes $survey_question$;
		mes "";
		for ( set @a,0; @a < getarraysize($survey_option$); set @a,@a+1 ) {
		mes "^0404B4"+$survey_option$[@a]+"^000000 - ^8A0808"+$survey_option_votes[@a]+"^000000 Vote/s";
		}
		close;
		}
	}
}// Ending bracket
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Anyone?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   21
  • Joined:  01/31/12
  • Last Seen:  

Posts in the support sections may be bumped with MORE INFORMATION no less than 24 hours after the last post.Any other bumping is not allowed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...