Solved Random element out of.

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

FishRekt

Active Member
Jan 26, 2017
87
0
0
25
I want to create a murder skript, but i'm in trouble..
I need to do that the skript select a random player in the server, and make it murder or detective..
I already do it, but the thing can make a player both murder and detective.. Please help
 
put a condition in there like
code_language.skript:
if {is.murderer} is true:
    stop
When the murderer gets selected set that variable to true so they can't be a detective as well
 
put a condition in there like
code_language.skript:
if {is.murderer} is true:
    stop
When the murderer gets selected set that variable to true so they can't be a detective as well

Thank you for the reply, i did a code like this:
code_language.skript:
command /murder [<text>]:
    trigger:
        if arg-1 is "start":
            if {murder} is not set:
                delete {murdererplayers}
                delete {murderer::*}
                delete {murderer}
                delete {detective}
                set {murder} to true
                loop all players:
                    add loop-player to {murderer::*}
                    add 1 to {murdererplayers}
                if {murderer} is not set:
                    set {murderer} to a random element out of {murderer::*}
                if {detective} is not set:
                    set {detective} to a random element out of {murderer::*}
                wait 2 seconds
                send all players title "Murder in inizio tra" with subtitle "5" for 1 second
                wait 1 second
                send all players title "Murder in inizio tra" with subtitle "4" for 1 second
                wait 1 second
                send all players title "Murder in inizio tra" with subtitle "3" for 1 second
                wait 1 second
                send all players title "Murder in inizio tra" with subtitle "2" for 1 second
                wait 1 second
                send all players title "Murder in inizio tra" with subtitle "1" for 1 second
                wait 1 second
                send all players title "Murder in inizio!" with subtitle "" for 1 second
                delete {murder}
                loop all players:
                    if loop-player is {murder}:
                        send loop-player title "&c&lSei il Murderer" with subtitle "sei uno stronzo" for 2 seconds
                    else if loop-player is {detective}:
                        send loop-player title "&9&lSei il Detective" with subtitle "devi uccidere lo stronzo" for 2 seconds
                    else if loop-player is not {murder} or {detective}:
                        send loop-player title "&e&lSei un innocente!" with subtitle "" for 2 seconds
                wait 2 seconds
                send "&c&lIl Murderer riceverà la sua arma a breve.." to all players
                give 1 bow named "&aArma" to {detective}
                wait 3 seconds
                give 1 iron sword named "&6Coltello" to {murderer}
                send "&aL'arma è stata data al detective" to all players
            else if {murder} is set:
                send "Murdering già in inizio!" to executor
on death:
    remove 1 from {murdererplayers}
    if {murderer} is victim:
        send "&a&lIl Murder %{murderer}% è stato ucciso." to all players
        send "" to all players
        send "" to all players
        send "&9&lEroe: %attacker%" to all players
        send "&b&lDetective: %{detective}%" to all players
    else if {detective} is victim:
        send "&b&lIl Detective è stato ucciso" to all players
    if victim is not {murderer}:
        if attacker is not {murderer}:
            kill attacker
    if {murdererplayers} is 1:
        send "&c&lIl Murder ha vinto la partita!" to all players
command /killmurder:
    trigger:
        delete {murder}

But a player can still get both..
 
You could also try adding them to their own list so they're no longer in the selection. once the murder is selected in the code, remove them from the main list and into their own so they can no longer be a random element to be selected for detective
 
  • Like
Reactions: FishRekt
You could also try adding them to their own list so they're no longer in the selection. once the murder is selected in the code, remove them from the main list and into their own so they can no longer be a random element to be selected for detective
Wow thank you, i'll trying to do it now, i'll let you know =)
[doublepost=1501937901,1501881884][/doublepost]Ehm.. This doesn't seem to work.. I did this:

Nothing, i fixed it by changing a variable that wasn't wrote correctly, thank you, you're the best.
 
Last edited by a moderator:
Status
Not open for further replies.