Jump to content
  • 0

You are the weakest link...good bye


Sovane

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  08/19/12
  • Last Seen:  

Alright so i need a script to add to my event, the event is kinda like DS but after each wave of monsters the players inside must vote to kick someone out. So i need a script that will make a dialog box pop up that tells them they need to vote someone out. They will chose only 1 person. Anyone with more than three votes gets kicked and the voting process will last 30 seconds anyone who does not vote also gets kicked.

 

Hope this isnt too much to ask for Thank you!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  08/19/12
  • Last Seen:  

Ok so ive done some research on how i would make this happen, i haven't gotten far but this is what i got.

 

if i put everyone in a party then use Getpartymember to make the array and put this into a menu the players can choose who they vote for by menu

 

I dont think this will really work tho for a number of reason. They could leave the event and not get kicked from party, idk how to program it to kick the player after they are selected in the menu. and a few other things...

 

Can i get some help, im stuck! lol

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Here's what I have so far: see post #5

prontera,0,0,0	script	weakest_link	-1,{
	
	
	
	end;

OnVote4WeakestLink:
	if (getmapusers(strnpcinfo(4)) > 128) {
		debugmes "too many players on map   T_T";
		end;
	} else if (getmapusers(strnpcinfo(4)) <= 2) {
		announce "There are 2 players left.", bc_blue|bc_map;
		end;
	}
	
	// for all online players
	while (getusers(1) > .@count) {
		set .@count, .@count + query_sql("SELECT account_id FROM `char` WHERE online=1 LIMIT 128 OFFSET "+.@count, .@account_id);
		set .@i, 0;
		while (.@i < getarraysize(.@account_id)) {
			getmapxy .@map$,.@x,.@y, 0,rid2name(.@account_id[.@i]);
			if (.@map$ == strnpcinfo(4)) {
				// save account_id of players on this map
				set .RID[getarraysize(.RID)], .@account_id[.@i];
			}
			set .@i, .@i +1;
		}
		deletearray .@account_id, 128;
		sleep 1; // prevent infinity loop
	}
	
	// for players on this map
	for (set .@i,0; .@i<getarraysize(.RID); set .@i,.@i+1) {
		if (attachrid(.RID[.@i])) {
			set @is_voting, 1;
			doevent strnpcinfo(3)+"::OnVotePopup";
		}
	}
	announce "You have 30 seconds to vote for the Weakest Link.", bc_blue|bc_map;
	
	// wait 30 seconds (give them time to vote)
	sleep 25000;
	announce "You have 5 seconds left to vote for the Weakest Link.", bc_blue|bc_map;
	sleep 5000;
	announce "Voting is over...", bc_blue|bc_map;
	
	// kick any players who did not vote
	for (set .@i,0; .@i<getarraysize(.RID); set .@i,.@i+1) {
		if (attachrid(.RID[.@i])) {
			if (@is_voting) {
				dispbottom "You are disqualified because you took too long to vote.";
				warp "SavePoint",0,0;
			}
		}
	}
	
	// calculate char with most votes
	for (set .@i,0; .@i<getarraysize(.RID); set .@i,.@i+1) {
		if ((.votes[.@i] > .@max_votes) || (.votes[.@i]==.@max_votes && rand(2))) {
			set .@max_votes, .votes[.@i]
			set .@weakest, .RID[.@i];
		}
	}
	// announce (and kick) the weakest link
	announce rid2name(.RID[.@weakest])+" is the Weakest Link!", bc_blue|bc_map;
	if (attachrid(.RID[.@weakest])) {
		mes "You are the weakest link.";
		mes " ";
		mes "Goodbye.";
		sleep2 2000;
		warp "SavePoint",0,0;
	}
	end;
	
OnVotePopup:
	// shuffle the .RID[] array into .@RID[]
	for( set .@i,0; .@i < getarraysize(.RID); set .@i,.@i+1 ) {
		while( set(.@rand,rand(1,getarraysize(.RID))) == getd(".@__tmp_"+.@rand) );
		setd(".@__tmp_"+.@rand,set(.@RID[.@i],.@rand));
	}
	// arrange the menu options in that order
	for( set .@i,0; .@i < getarraysize(.@RID); set .@i,.@i+1 )
		set .@menu$, .@menu$ + .RID[.@RID[.@i]-1] + ":";
	// display menu --> player picks a weakest link
	set .@idx, .@RID[select(.@menu$)-1]-1;
	set .votes[.@idx], .votes[.@idx] +1;
	set @is_voting, 0;
	close;
}

Trigger the OnVote4WeakestLink label each round of your event.

* I didn't know how to vote when it's down to 2 players (since they would probably always vote for each other, then it'd be a tie) so I made the script just stop if 2 players are left.

Edited by Brian
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  08/19/12
  • Last Seen:  

Thank you so much! it actually wont go down to two players as there is only 5 rounds and they vote 4 of the 5 and maybe 20 players thank you!

Edited by Sovane
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

I fixed a bunch of errors:

- missing semi-colon

- changed 'doevent' to 'addtimer' so the menu pops up immediately

- changed 'announce' to 'mapannounce', which works with no RID attached

- removed player's own name from list (so they can't vote themself as the weakest link)

- fixed rid2name(.@weakest)

and tested it with 3 chars and it seems to work now. /no1

prontera,155,180,0	script	test	910,{
	
	// end;

OnVote4WeakestLink:
	deletearray .RID;
	deletearray .votes;
	
	
	if (getmapusers(strnpcinfo(4)) > 128) {
		debugmes "too many players on map   T_T";
		end;
	} else if (getmapusers(strnpcinfo(4)) <= 2) {
		mapannounce strnpcinfo(4),"There are 2 players left.", 0,0x00FFFF;
		end;
	}
	
	// for all online players
	while (getusers(1) > .@count) {
		set .@count, .@count + query_sql("SELECT account_id FROM `char` WHERE online=1 LIMIT 128 OFFSET "+.@count, .@account_id);
		set .@i, 0;
		while (.@i < getarraysize(.@account_id)) {
			getmapxy .@map$,.@x,.@y, 0,rid2name(.@account_id[.@i]);
			if (.@map$ == strnpcinfo(4)) {
				// save account_id of players on this map
				set .RID[getarraysize(.RID)], .@account_id[.@i];
			}
			set .@i, .@i +1;
		}
		deletearray .@account_id, 128;
		sleep 1; // prevent infinity loop
	}
	
	// for players on this map
	for (set .@i,0; .@i<getarraysize(.RID); set .@i,.@i+1) {
		if (attachrid(.RID[.@i])) {
			set @is_voting, 1;
			addtimer 0,strnpcinfo(3)+"::OnVotePopup";
		}
	}
	mapannounce strnpcinfo(4),"You have 30 seconds to vote for the Weakest Link.", 0,0x00FFFF;
	
	// wait 30 seconds (give them time to vote)
	sleep 25000;
	mapannounce strnpcinfo(4),"You have 5 seconds left to vote for the Weakest Link.", 0,0x00FFFF;
	sleep 5000;
	mapannounce strnpcinfo(4),"Voting is over...", 0,0x00FFFF;
	
	for (set .@i,0; .@i<getarraysize(.RID); set .@i,.@i+1) {
		// kick players who did not vote
		if (attachrid(.RID[.@i])) {
			if (@is_voting) {
				dispbottom "You are disqualified because you took too long to vote.";
				warp "SavePoint",0,0;
			}
		}
		// calculate RID with most votes                                rand() is for when there are ties
		if ((.votes[.@i] > .@max_votes) || (.votes[.@i]==.@max_votes && rand(2))) {
			set .@max_votes, .votes[.@i];
			set .@weakest, .RID[.@i];
		}
	}
	
	// announce (and kick) the weakest link
	mapannounce strnpcinfo(4),rid2name(.@weakest)+" is the Weakest Link!", 0,0x00FFFF;
	if (attachrid(.@weakest)) {
		dispbottom "You are the weakest link.";
		dispbottom "Goodbye.";
		warp "SavePoint",0,0;
	}
	end;
	
OnVotePopup:
	// shuffle the .RID[] array into .@RID[]
	for( set .@i,0; .@i < getarraysize(.RID); set .@i,.@i+1 ) {
		while( set(.@rand,rand(1,getarraysize(.RID))) == getd(".@__tmp_"+.@rand) );
		setd(".@__tmp_"+.@rand,set(.@RID[.@i],.@rand));
	}
	// arrange the menu options in that order
	for( set .@i,0; .@i < getarraysize(.@RID); set .@i,.@i+1 )
		set .@menu$, .@menu$ +( (.RID[.@RID[.@i]-1]==getcharid(3)) ? "":rid2name(.RID[.@RID[.@i]-1]) )+ ":";
	// display menu --> player picks a weakest link
	set .@idx, .@RID[select(.@menu$)-1]-1;
	set .votes[.@idx], .votes[.@idx] +1;
	set @is_voting, 0;
	close;
}
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...