How to: Make a VoteKick System

Ryuu

I am back with Chocolate (:
Reaction score
64
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.
  1. You want to kick him. You HATE him.
  2. 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.

variablesst8.png


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

Code:
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.

Code:
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.
Code:
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.

Code:
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.
Code:
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) [i]//change this to your desired number of hits needed to acknowledge a kick[/i]

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.

Code:
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.
Code:
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.

Code:
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:
 

Attachments

  • VoteKick System Tutorial 1.6.w3x
    24.1 KB · Views: 507

InfectedWithDrew

I used to go here a lot.
Reaction score
95
Votekicking is the fairest form of kicking possible. Instead of the host being the judge, the players are. This prevents a bias, mostly. +rep.
 

gref

New Member
Reaction score
33
It would be good if there was a demonstration map uploaded so we can see it in use.

I in particular would rather use your map to test it/copy it if I was wanting this in my map, than to write out the triggers myself.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
That would be a dreadful problem :(

I have 2 computers, one has ability to play good games (shouldn't use GOOD GAMES, in fact every game can be played well without lagg)

The other one is mainly for internet surfing.

Well by saying these I think you can roughly understand what I'm saying. My good computer (the one that can play games) is :( spoiled :( and so I have lost my demo map.

If anyone is kind enough to help me with it (I can download the map and attach it to the first post, but I can't test it though), I would gladly rep. ;)
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Hmm... Kicking players when they attack players? Thats a good idea, but i cant do it now... Im at school lol
 

gref

New Member
Reaction score
33
Actually... He meant the opposite.

He meant kicking the players that were attacked :p
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Oh... But i dont get it. Why kick the players who are attacked?

EDIT: Lol, I just reread his post, then I knew the reason.. ganging up on him. Won't it be better if the host + few other guys attacked instead? It would be fair, won't it?

Major Update

Ok sorry for double posting but just wanna inform you guys that I had updated the second post with Part 2.

I did some major changes to Part 1 as well, take a look at it.

EDIT:

Another Major Update

I updated the tutorial YET AGAIN, and now the version is V1.4. The reason why I updated it again is because I found an error again.

I can't believe I found the same error twice.
 
P

pathetic nub

Guest
i cat find sum tings:Set playersONLINE = (All players matching ((((Matching player) controller) Equal to User) or (((Matching player) slot status) Equal to Is playing))) n Set player = (Owner of (Triggering Unit)) i onli foun set variable no set player cn sum1 help mi i nid a kik in my mapp
 

vypur85

Hibernate
Reaction score
803
Set playersONLINE = (All players matching ((((Matching player) controller) Equal to User) or (((Matching player) slot status) Equal to Is playing)))
Actions - Player Group


Set player = (Owner of (Triggering Unit))
Actions - Set Variable --> Create New Variable (Variable Name = 'player'; Variable Type = Player)

I think you should fix your spellings. Try not to use too many short forms. Very hard to understand. (Seems like Singlish or Manglish = =, not sure where you're from)
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Meh, he's from Singapore, same as me ;)

Well he said his keyboard has spoilt (he's lying for sure) and he is only 8 years old lol, for him to be learning the world editor is a very very good achievement.

Anyway once again I updated the tutorial.

> Actions - Player Group

Heh?
 

vypur85

Hibernate
Reaction score
803
> Actions - Player Group

Heh?

Whoops... Should be:
Actions - Set Variable --> Create New Variable (Variable Name = 'playerONLINE'; Variable Type = Player Group)


Paiseh... :p

Offtopic: Boy boy... Study hard hard... Don't play too much games... (He must be your cousin or something :p)
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Nah, he is my schoolmate.. some guy I bumped into while reading a book =.= its a long story lol.
 

Crusher

You can change this now in User CP.
Reaction score
121
Kick

Well its sure votekick is the best,but whats wrong with only host decides kicking well he can ask others to vote by typing 123 in chat box :)
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Think about this:

Host: Ok I'm going to kick teal anyone wanna vote
Blue: Okay I agree (host counts 1)
Teal: Disagree!! (host counts 2, got confused abit)
Purple: agree (counts 3)

and so on.. he'll either get confused, all agree or disagree, or, he'll lost count and end up not concentrating on the game and losing the game.

Anything can really happen in a kick. ;)
 
P

pathetic nub

Guest
lol

thx for de help works now but hw 2 activate vote?
exampe if i host hw 2 start de kick/
 

Ryuu

I am back with Chocolate (:
Reaction score
64
The host will type -kick (number of player), and to vote you type -1 to agree or -2 to disagree.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top