HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make a kickvote system?

07-22-2003, 05:03 AM#1
Plasma[Blade]
Well, in my RPG map, I'm trying to make it so if over half of the players type "kick [player name]", then that player will be kicked. How would I go about doing this?

If it matters, there can be up to 4 human players playing.
07-22-2003, 12:52 PM#2
Dead-Inside
Okay, we make it the easy way.
Make a string array in your variables menu.

At game start, you store all names in the string, like this:
Set StringArray[1] = Player name of Player 1 (Red)
Set StringArray[2] = Player name of Player 2 (Blue)
Ect, until you have all.

Now, your kick trigger:
E: Player 1 (Red) types "kick " as a sub-string (Include the space)
A: If (Entered sub-string(6,16) equal to StringArray[1] then do Defeat Player 1 (Red) else do nothing
If (Entered sub-string(6,16) equal to StringArray[2] then do Defeat Player 2 (Blue) else do nothing
Now continue on doing so.
You might want to do "Multiple actions", where one defeats the kicked player, and the other sends a message that he was kicked by Red.

Regards
Dead-Inside
07-22-2003, 05:15 PM#3
Mr. Thermistor
variables:
int var1=0
int var2[4]
bool player4kick[4]
bool player3kick[4]
bool player2kick[4]
bool player1kick[4]

trigger 1 // counts the number of active players
{
set var1=0

for each integer a from 1 to 4 do (if player(integer a) slot status equal to is playing then do (set var1 = var1 + 1))
}

trigger 2 // vote
{
/* this trigger adds 1 to the variable var2[] when a player votes. When this number reaches half of the number active players, that player is kicked */

event: player 1 /* make one trigger for each player*/ types "kick teal"
player 2 types "kick teal"
player 3 types "kick teal"
...

condition: // check to see if this player has voted or not
player3vote[player number of (triggering player)] == false

action:
set player3vote[player number of (triggering player)] = true

set var2[3] = var2[3] + 1

if var2[3] greater than or equal to var1 / 2 then do (defeat player 3 teal) /* var 1 is equal to the number of players currently in the game; var2[3] because teal is player 3 */
}


This should work with any number of players.

*When splitting odd integers in half, the system uses the smaller half as the result.