random skript

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

zTak

Active Member
Mar 3, 2018
84
6
8
21
Code:
command /Zufall [<text>]:
    trigger:
        if player is op:
            broadcast "&8> &7Ein &ezufälliger Spieler &7wird nun ausgewählt..."
            wait 1 second
            loop all players:
                play "LEVEL_UP" to loop-player
                add loop-player to {_list::*}
                set {_random} to a random element out of {_list::*}
                send "&8> &7Der Spieler &e&l%{_random}%&7 wurde ausgewählt!" to loop-player
                send loop-player title "&8> &e&l%{_random}%" with subtitle "&7wurde ausgewählt&8." for 3 seconds
                clear {_list::*}
                clear {_random}

This is my code for a skript which chooses a random player, but if i use it, every player get his own name on the messages
 
Hey I know you are German. I write this in English for anybody:
It is very important, that "set {_random} to a random element out of {_list::*}" is out of "loop all players:".
So this is the code:

Code:
command /Zufall [<text>]:
    trigger:
        if player is op:
            broadcast "&8> &7Ein &ezufälliger Spieler &7wird nun ausgewählt..."
            wait 1 second
            loop all players:
                play "LEVEL_UP" to loop-player
                add loop-player to {_list::*}
            set {_random} to a random element out of {_list::*}
            loop all players:
                send "&8> &7Der Spieler &e&l%{_random}%&7 wurde ausgewählt!" to loop-player
                send loop-player title "&8> &e&l%{_random}%" with subtitle "&7wurde ausgewählt&8." for 3 seconds
            clear {_list::*}
            clear {_random}
 
Status
Not open for further replies.