making teams for minigame

  • 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 community!

    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!

prettycoolTBH

New Member
Dec 20, 2024
8
1
3
so im making a minigames server(and im pretty new to skript) and i want to make 2 seperate teams that are even from a list like {maingame::*} (if a even amount of players are online) but i dont know how to do this so can anyone help??? thank you!
 
You can set a variable to the amount of players online. with that variable you can devide it by 2. Here is an easy way to understand it. You can use this as reference to use in your skript

Code:
command /teams:
  trigger:
    set {players} to number of all players
    set {team1} and {team2} to {players} / 2

if you want to round up when an uneven amount of players is online you can do this. the round({...}) rounds an integer up to the closest whole number. then we remove 0.5 from a team and add 0.5 from a team. so if total players would be 5, we devide by 2 wich gives us 2.5 in both variables. we add 0.5 and remove 0.5. we get 2 players on one variable and 3 players on the other. also for this one you can take reference and use it in your skript.

Code:
command /teams:
  trigger:
    set {players} to number of all players
    set {team1} and {team2} to {players} / 2
    set {team1} to round({team1})
    set {team2} to round({team2})
    add 0.5 to {team1}
    remove 0.5 from {team2}