How to: Make a VoteKick System

Tutorial By Ryuu

VoteKick System V1.7
A tutorial by PureGUI


Welcome to the Votekick System tutorial! There are 2 parts within this tutorial. Part 1 is a fair votekicking system, while the 2nd part is the fairest you can get.

Part 1 - Fair

Players may be offending you too far off, and you have two things you need to question about in your mind.

• You want to kick him. You HATE him.
• Some people disagree with your kick. They might HATE you.


In order to prevent that from happening, this very simple Pure GUI VoteKick System will explain the basics to the advanced from variable setting to kicking the player.

What we need to go into now is to set variables, because life is 100% better with variables.

We need a player group to 'tell' the trigger that the player is online and is playing, because you don't want to have a computer player kicked. We also need 2 integer variables for the number of votes, that would be the core of our voting kick system. Another thing we need is a unit group variable, to remove all the units if the player is kicked. More variables are also needed.

(Image)

In the trigger, set those that are needed to be set now, otherwise set it later in the triggers.

Variables Events Map initialization Conditions Actions Set playersONLINE = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))

Now all is left is how the host (For this tutorial Player 1 (Red) will be the assumed host) will kick the desired player, and how the desired player will be kicked. When player 1 types -kick 3, it will kick player 3 (teal).

All the below trigger will do in the game is to display the message:
Jack is voted to be kicked. Typing -1 will agree and -2 will disagree.

We don't want the message to be sent to the kicked player, because we don't want him to know that he is about to be kicked.

Since the player has been voted to be kicked, we want the players to vote, except, of course, the kicked player.

Note: Add the trigger 'Player Vote' before making the following trigger.

Host Kicking Events Player - Player 1 (Red) types a chat message containing -kick as A substring Conditions Actions For each (Integer A) from 1 to (Number of players in playersONLINE), do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Equal to (String((Player number of (Player((Integer A)))))) Then - Actions Trigger - Turn On Kick Player <gen> Set player = (Player((Integer A))) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (player is in playersONLINE) Equal to True Then - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player number of player) Not equal to playerCheck[Player number of player] Then - Actions Trigger - Turn on Player Vote <gen> Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: ((|cffffcc00 + (Name of player)) + (|r + is voted to be kicked. Typing |c00ff0303-1|r will agree and |c00ff0303-2|r will disagree.)) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions Else - Actions Else - Actions Game - Display to Player group - Player 1 (Red) the text: (This player is already kicked before; you cannot kick him/her again!) Set playerCheck[Player number of player] = (Player number of player) Else - Actions

After the host starts the vote for the player, we need to enable the player to kick it. To do so, we need to use substrings, because players vote using -1 (agree) and -2 (disagree).

Next, check if the second character in the string is equal to 1 or 2, then do the agree or disagree actions.

Note: This trigger is INTIALLY OFF.
Player Vote Events Player - Player 2 (Blue) types a chat message containing - as A substring Player - Player 3 (Teal) types a chat message containing - as A substring Player - Player 4 (Purple) types a chat message containing - as A substring Player - Player 5 (Yellow) types a chat message containing - as A substring Player - Player 6 (Orange) types a chat message containing - as A substring Player - Player 7 (Green) types a chat message containing - as A substring Player - Player 8 (Pink) types a chat message containing - as A substring Player - Player 9 (Gray) types a chat message containing - as A substring Player - Player 10 (Light Blue) types a chat message containing - as A substring Conditions (Triggering player) Not equal to player Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Substring((Entered chat string), 2, 2)) Equal to 1 Then - Actions Set agreeInt = (agreeInt + 1) Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: ((|cffffcc00 + (Name of (Triggering player))) + |r agreed to the vote.) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Substring((Entered chat string), 2, 2)) Equal to 2 Then - Actions Set disagreeInt = (disagreeInt + 1) Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: ((|cffffcc00 + (Name of (Triggering player))) + |r disagreed to the vote.) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions Else - Actions

The next and the last trigger is need is to kick the player. Before doing that, we have to check if the 'agree' integer is more than the 'disagree' integer. If it is, kick the player, but if it is not, the player is allowed to stay.

Use the following trigger for that:

Note: This trigger is INITiALLY OFF.

Kick Player Events Time - Every 30.00 seconds of game-time Conditions Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions agreeInt Greater than disagreeInt Then - Actions Set unitGrp = (Units owned by player) Game - Defeat player with the message: You have been kicke... Game - Display to (All players) the text: ((|cffffcc00 + (Name of player)) + |r has been kicked!) Player Group - Remove player from playersONLINE Unit Group - Pick every unit in unitGrp and do (Actions) Loop - Actions Unit - Remove (Picked unit) from the game Custom script: call DestroyGroup( udg_unitGrp ) Else - Actions Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: (The vote for + (|cffffcc00 + ((Name of player) + |r has failed!))) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions

Well that basically covers all of our Voting System. The player will be kicked if the vote is successful, and if you type the kick and vote strings under 'ally' so that the kicked player will never know that he is the one to be kicked.

Other options include only showing the kick and vote messages into the ally.
To do that, set 'playersONLINE' into arrays 1 and 2; make them allies and enemies of players.
But then for the 'max no. of players' (in this tutorial it's 10), you have to set it to the number of players in the force.

Well that's it for Part 1!

Part 2 - Very Fair

An extended and fairer version of our previous Pure GUI VoteKick System Part 1.

In Part 2, I'll be guiding along the usage of the host attacking a player whom he wants to kick, and make sure he hits the player X times before the kick is acknowledged. This is to make sure that the host has the power to kick and he is STRONG enough to kick, so that the kick can be initiated fairly.

Now in order to do what I have just mentioned, as usual, we need variables. Like I already said in Part 1, variables are life-savers. Just setting variables makes your life a whole lot easier.

We need the same list of variables, plus three additional integer variables for recording the number of hits and the loop. We also need two dialog variables, one for the frame and one for the buttons:

playersONLINE - Player Group Variable
agreeInt - Integer Variable
disagreeInt - Integer Variable
playerNumber - Integer Variable
playerLoop - Integer Variable
numberOfhits - Integer Variable
maxNumber - Integer Variable
unitGrp - Unit Group Variable
player - Player Variable
dialogFrame - Dialog Variable
dialogButtons - Dialog Array Variable

Similar to the previous part, we need a trigger setting the variables.
Variables Events Map initialization Conditions Actions Set playersONLINE = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))) Set maxNumber = (Random integer number between 1 to 10) //change this to your desired number of hits needed to acknowledge a kick

The following triggers will be very different from Part 1, because the events are different too.

We will be having five different stages in this part. They are also known as initiating the kick, attacking the enemy, acknowledging the kick, initiating the vote, and lastly, kicking the player.

Well first off we'll be initiating the kick, but only the host (for this tutorial Player 1 (Red) will be used as the host.

The following trigger will be very easy, because all we'll be doing is turning on a trigger and displaying a string.

Initiating the Kick Events Player - Player 1 (Red) types a chat message containing -kick as An exact match Conditions Actions Game - Display to (Player Group - Player 1 (Red)) the text: Before acknowledging the vote, you need to attack the player + String(maxNumber) + times before you can kick him. Trigger - Turn on Stage 2 & 3 <gen>

Since the host has now initiated the kick, it is up to him to attack the enemy. We'll be needing several more variables for the following trigger, bear that in mind.

The following trigger will be covering stages 2 and 3, which is on attacking the enemy and acknowledging the kick.

Note: This trigger is INTIALLY OFF.
Stage 2 & 3 Events Unit - A unit Is attacked Conditions (Owner of (Attacking Unit)) Equals to Player 1 (Red) Actions Set player = (Owner of (Triggering Unit)) Set numberOfhits = (numberOfhits + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions numberOfhits Equals to maxNumber Then - Actions For each (Integer A) from 1 to (Number of players in playersONLINE), do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (player is in playersONLINE) Equal to True Then - Actions Trigger - Turn on Initiating the Vote <gen> Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: ((|cffffcc00 + (Name of player)) + (|r + is voted to be kicked.)) Dialog - Clear dialogFrame Dialog - Change the title of dialogFrame to Do you agree to kick + (Name of player) Dialog - Create a dialog button for dialogFrame labelled Disagree Set dialogButtons[1] = (Last created dialog Button) Dialog - Create a dialog button for dialogFrame labelled Agree Set dialogButtons[2] = (Last created dialog Button) Dialog - Show dialogFrame to (Picked player) Game - Pause the game If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions Else - Actions Else - Actions Else - Actions

The next trigger we need will be on initiating the vote and kicking the player. Since in Part 1 I used strings, I decided I go for a change. In this tutorial, dialogs will be used. The game will pause because I decided it would be unfair if those who voted first gets to attack those who are still voting. The game will only unpause until all players have finished voting. It is very simple, because all we need is to compare the agree and disagree integers, if the agree integer is more than the disagree integer, kick the player while destroying all his units, but if it is lesser, the player would be allowed to stay.

Initiating the Vote Events Dialog - A dialog button is clicked for dialogFrame Conditions Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to dialogButton[1] Then - Actions Set disagreeInt = (disagreeInt + 1) Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Clicked dialog button) Equal to dialogButton[2] Then - Actions Set agreeInt = (agreeInt + 1) Else - Actions Set playerLoop = (playerLoop + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerLoop Equals to ((Number of players in playersONLINE) - 1) Then - Actions Game - Unpause the game If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions agreeInt Greater than disagreeInt Then - Actions Set unitGrp = (Units owned by player) Game - Defeat player with the message: You have been kicke... Game - Display to (All players) the text: ((|cffffcc00 + (Name of player)) + |r has been kicked!) Player Group - Remove player from playersONLINE Unit Group - Pick every unit in unitGrp and do (Actions) Loop - Actions Unit - Remove (Picked unit) from the game Custom script: call DestroyGroup( udg_unitGrp ) Else - Actions Player Group - Pick every player in playersONLINE and do (Actions) Loop - Actions Set playerNumber = (playerNumber + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Player number of player) Then - Actions Set playerNumber = (playerNumber + 1) Else - Actions Game - Display to (Player group((Picked player))) the text: (The vote for + (|cffffcc00 + ((Name of player) + |r has failed!))) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions playerNumber Equal to (Number of players in playersONLINE) Then - Actions Set playerNumber = 0 Else - Actions Else - Actions

Frequently Asked Questions

Q: If a player leaves by his/her own, will he/she still be in the 'online and playing' player group?
A: By default, no, but you can make a trigger denoting that. Just make so that when a player leaves, he is removed from the player group.

Q: If the player is kicked, will his/her units be removed? If yes, can I change it to no?
A: Yes, his/her units and buildings etc. will be completely removed. You can change it, by removing the 'Unit - Remove (Picked unit) from the game' and the unit group action in the last trigger.

Hope you enjoy the two parts!
Any comment of feedback is appreciated.

VoteKick System V1.6

I have uploaded the latest demonstration map, VoteKick System Tutorial 1.6.

Please download it here:

Click here to comment on this tutorial.
 
 
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.