1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Random element out of.

Discussion in 'Skript' started by FishRekt, Aug 4, 2017.

Thread Status:
Not open for further replies.
  1. FishRekt

    FishRekt Active Member

    Joined:
    Jan 26, 2017
    Messages:
    87
    Likes Received:
    0
    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

     
  2. Best Answer:
    Post #4 by ShaneBee, Aug 4, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    put a condition in there like
    Code (Skript):
    1. if {is.murderer} is true:
    2.     stop
    When the murderer gets selected set that variable to true so they can't be a detective as well
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thank you for the reply, i did a code like this:
    Code (Skript):
    1.  
    2. command /murder [<text>]:
    3.     trigger:
    4.         if arg-1 is "start":
    5.             if {murder} is not set:
    6.                 delete {murdererplayers}
    7.                 delete {murderer::*}
    8.                 delete {murderer}
    9.                 delete {detective}
    10.                 set {murder} to true
    11.                 loop all players:
    12.                     add loop-player to {murderer::*}
    13.                     add 1 to {murdererplayers}
    14.                 if {murderer} is not set:
    15.                     set {murderer} to a random element out of {murderer::*}
    16.                 if {detective} is not set:
    17.                     set {detective} to a random element out of {murderer::*}
    18.                 wait 2 seconds
    19.                 send all players title "Murder in inizio tra" with subtitle "5" for 1 second
    20.                 wait 1 second
    21.                 send all players title "Murder in inizio tra" with subtitle "4" for 1 second
    22.                 wait 1 second
    23.                 send all players title "Murder in inizio tra" with subtitle "3" for 1 second
    24.                 wait 1 second
    25.                 send all players title "Murder in inizio tra" with subtitle "2" for 1 second
    26.                 wait 1 second
    27.                 send all players title "Murder in inizio tra" with subtitle "1" for 1 second
    28.                 wait 1 second
    29.                 send all players title "Murder in inizio!" with subtitle "" for 1 second
    30.                 delete {murder}
    31.                 loop all players:
    32.                     if loop-player is {murder}:
    33.                         send loop-player title "&c&lSei il Murderer" with subtitle "sei uno stronzo" for 2 seconds
    34.                     else if loop-player is {detective}:
    35.                         send loop-player title "&9&lSei il Detective" with subtitle "devi uccidere lo stronzo" for 2 seconds
    36.                     else if loop-player is not {murder} or {detective}:
    37.                         send loop-player title "&e&lSei un innocente!" with subtitle "" for 2 seconds
    38.                 wait 2 seconds
    39.                 send "&c&lIl Murderer riceverà la sua arma a breve.." to all players
    40.                 give 1 bow named "&aArma" to {detective}
    41.                 wait 3 seconds
    42.                 give 1 iron sword named "&6Coltello" to {murderer}
    43.                 send "&aL'arma è stata data al detective" to all players
    44.             else if {murder} is set:
    45.                 send "Murdering già in inizio!" to executor
    46. on death:
    47.     remove 1 from {murdererplayers}
    48.     if {murderer} is victim:
    49.         send "&a&lIl Murder %{murderer}% è stato ucciso." to all players
    50.         send "" to all players
    51.         send "" to all players
    52.         send "&9&lEroe: %attacker%" to all players
    53.         send "&b&lDetective: %{detective}%" to all players
    54.     else if {detective} is victim:
    55.         send "&b&lIl Detective è stato ucciso" to all players
    56.     if victim is not {murderer}:
    57.         if attacker is not {murderer}:
    58.             kill attacker
    59.     if {murdererplayers} is 1:
    60.         send "&c&lIl Murder ha vinto la partita!" to all players
    61. command /killmurder:
    62.     trigger:
    63.         delete {murder}
    But a player can still get both..
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    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 Like x 1
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Wow thank you, i'll trying to do it now, i'll let you know =)
    --- Double Post Merged, Aug 5, 2017, Original Post Date: Aug 4, 2017 ---
    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.
     
    #5 ShaneBee, Aug 5, 2017
    Last edited by a moderator: Aug 5, 2017
    • Friendly Friendly x 1
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    hahax3 really glad it worked <3
     
    • Friendly Friendly x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...