Solved Check if arena is full

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

SaltyPotata

Member
May 26, 2020
17
0
0
25
Code:
command /event [<text>] [<text>]:
    trigger:
        if arg 1 isn't set:
            send "&7/event help"
        if arg 1 is "help":
            player has permission "event.admin":
                send "&8&m---------- &cHELP &8&m----------"
                send "&7/event join"
                send "&7/event leave"
                send "&7soon more"
            else:
                send "&8&m---------- &cHELP &8&m----------"
                send "&7/event join"
                send "&7/event leave"
        if arg 1 is "join":
            if arg 2 isn't set:
                send "&cWrong syntax!"
            else:
                if {ingame.%player%} is true:
                    send "&cYou already in game!"
                else:
                    clear player's inventory
                    teleport player to {spawn.%arg 2%}
                    set {ingame.%player%} to true
                    set {arena.%player%} to arg 2
                    send "&7You joined the game!"
                    wait 1 tick
                    give player stick of knockback 1 named "&fThis is just a normal stick!"                     
        if arg 1 is "leave":
            if arg 2 isn't set:
                send "&cWrong syntax!"
            else:
                if {ingame.%player%} is true:
                    send "&7You left the game!"
                    clear player's inventory
                    delete {arena.%player%}
                    teleport player to {lobby.%arg 2%}
                    set {ingame.%player%} to false

How do I create a player limit on an area. Max of 2 players. If someone joins max of 1 player and if someone leaves then max 2 players again?
 
Add line 26:
Code:
add player to {arenaplayers.%{arena.%player%}%::*}
And add line 34:
Code:
remove player from {arenaplayers.%{arena.%player%}%::*}
Then you can check number of players:
Code:
if size of {arenaplayers.%arg-2%::*} >= 2:
    send "&cThe arena is full!"
    stop
 
  • Like
Reactions: SaltyPotata
Status
Not open for further replies.