Solved Guys how can i make cast lots ?

  • 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.

esat179

Member
Jul 3, 2022
3
0
1
21
Guys how can i make cast lots ? For example we have 10 players on server, I want to allocate into teams of 5. When i use /random command, it must return 5 random player. (Example player names : a b c d e f g h j k , used /random -> a j k d c)

I made a basic example in java but i want to convert it to skript, who can help me ? Thanks a lot.

public static void main(String[] args) {
List<String> arraylist = new ArrayList<>();
arraylist.add("1.");
arraylist.add("2.");
arraylist.add("3.");
arraylist.add("4.");
arraylist.add("5.");
arraylist.add("6.");
ArrayList<String> gecici = new ArrayList<>();
while(gecici.size()<3) {
Random rastgele = new Random();
int rndm = rastgele.nextInt(6);
if(gecici.contains(arraylist.get(rndm))){
continue;
}
gecici.add(arraylist.get(rndm));
}
System.out.println(gecici);
}
 
code_language.skript:
command /random:
  trigger:
    set {_players::*} to shuffled players
    loop (size of players) / 2 times:
      add {_players::%loop-number%} to {_result::*}
    send {_result::*}
This code basically returns half of the online players, randomly. I assume that's what you want here
 
code_language.skript:
command /random:
  trigger:
    set {_players::*} to shuffled players
    loop (size of players) / 2 times:
      add {_players::%loop-number%} to {_result::*}
    send {_result::*}
This code basically returns half of the online players, randomly. I assume that's what you want here

Thank you so much :emoji_slight_smile:
 
Status
Not open for further replies.