- Joined
- May 29, 2023
- Messages
- 41
The auto starting system is required for making fully automatic round based games such as the Spleef, Tnt tag, dodgebow idk
amountToStart = put the number of required players to start
timeToStart = put the number for the countdown until the game starts
theItem = put here the item that the player must click to join
When a player clicks the join item if the game has not already started
+1 to the playersJoined if this is more than the required amount of players to start
and if the countdown has not yet started, Start the countdown
When a player that joined the game left the world -1 to the playersJoined
if the countdown has begun but there are less players than required stop the countdown
Create the "Start" Function which will be responsible of starting the game e.g. teleport the players into the arena, give the players weapons,
also set the playersJoined == 0 and gameHasStarted == 1
When the game ends set the gameHasStarted == 0
amountToStart = put the number of required players to start
timeToStart = put the number for the countdown until the game starts
theItem = put here the item that the player must click to join
Code:
Player Right Click Event
{
If Player Item Equals (theItem)
{
If Variable (gameHasStarted != 1)
{
If Variable (%player%hasJoined != 1)
{
Set Variable %player%hasJoined == 1
Set Variable playersJoined += 1
Player Action Remove Item (theItem)
If Variable (countdownHasStarted != 1)
{
If Variable playersJoined ≥ amountToStart
{
Set Variable countdownHasStarted == 1
Set Variable countdownTime == timeToStart
Start Loop ("Countdown")
}
}
}
}
else
{
Player Action Send Message ("The Game Has Started!")
}
}
}
When a player clicks the join item if the game has not already started
+1 to the playersJoined if this is more than the required amount of players to start
and if the countdown has not yet started, Start the countdown
Code:
Player Event Quit
{
If Variable (%player%hasJoined = 1)
{
Set Variable %player%hasJoined == 0
Set Variable playersJoined -= 1
If Variable (countdownHasStarted == 1)
{
If Variable playersJoined < amountToStart
{
Stop Loop (Countdown)
Set Variable countdownHasStarted == 0
Player Action Send Message %all% ("Not Enough Players to Start!")
}
}
}
}
When a player that joined the game left the world -1 to the playersJoined
if the countdown has begun but there are less players than required stop the countdown
Code:
Loop Countdown
{
Player Action Send Title (countdownTime)
If Variable countdownTime ≤ 0
{
Stop Loop (Countdown)
Set Variable countdownHasStarted == 0
Call Function (Start)
}
Set Variable countdownTime -= 1
}
Create the "Start" Function which will be responsible of starting the game e.g. teleport the players into the arena, give the players weapons,
also set the playersJoined == 0 and gameHasStarted == 1
When the game ends set the gameHasStarted == 0
Last edited: