Random choose name from variable

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

Status
Not open for further replies.

iStopcontact

Member
Feb 18, 2017
115
2
18
Hello guys!

In my skript i have added a code that when a player joines the server, it gets added to a variable
code_language.skript:
add player to {murderlist::*}

But now i want to select a random name out of that variable.

For example:
There are 3 players in the server: Player1, Player2 and Player3

Now i want to chose 1 of them with a command.

All 3 of them are in the variable {murderlist::*}

So how can i make the skript randomly choose one
 
But how can i choose that in format to chose one random name out of that list and add that player to a other variable @Snow-Pyon
[doublepost=1492981099,1492981044][/doublepost]or yhea how can i type that in skript* @Snow-Pyon
 
code_language.skript:
set {_var} to random element out of {murderlist::*}
 
is it also possible to have the random chosen name in the variable {testvar:%choosenname%}
 
Alright lets see if i get it:

We have two names: xUndefined and iStopcontact

You want a random one, lets say xUndefined

And you want to create a variable called {testvar::xUndefined} that contains xUndefined?

code_language.skript:
set {_var} to random element out of {murderlist::*}
set {testvar::%{_var}%} to {_var}
 
Yess thanks! @xUndefined
[doublepost=1493026255,1493024251][/doublepost]But now i have one more question, i have 2 variables for example: {var1} and {var2}

How can i make sure that for those 2 variables not the same person gets chosen
 
But now i have one more question, i have 2 variables for example: {var1} and {var2}

How can i make sure that for those 2 variables not the same person gets chosen
Using while.

code_language.skript:
set {_var} to random element out of {murderlist::*}
set {testvar::%{_var}%} to {_var}
set {_var2} to random element out of {murderlist::*}
while {_var2} is {_var}:
    set {_var2} to random element out of {murderlist::*}
set {testvar::%{_var2}%} to {_var2}
stop

You should build a failsafe in case you only have 1 player in {murderlist::*}, because if that's the case it will repeat indefinitely. Something like if size of {murderlist::*} is 1
 
Status
Not open for further replies.