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.

Chance of NUMBER%: Always chose only 1

Discussion in 'Skript' started by LoneElf, Aug 8, 2017.

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

    LoneElf Active Member

    Joined:
    Apr 30, 2017
    Messages:
    165
    Likes Received:
    2
    So, this can apply for an auto broadcaster, which is why I am relating to it, so what I need is that every 5 minutes, chance of 50%: broadcast "Hello!", or a chance of 50%: broadcats "Bye!". So, the thing is, in those examples, it will 50% broadcast just Hello, 50% broadcast just Bye, or 50% broadcast both. How would I make it so it broadcasts only 1 of them, chosen by a chance of 50%? Thanks :emoji_slight_smile:
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    with "chance of" it's rolling both chances, therefore there's a chance both or none can be played. A better way to do it would be like
    Code (Skript):
    1. set {_chance} to a random integer between 1 and 100
    2. if {_chance} is between 1 and 50:
    3.     broadcast "hello"
    4. if {_chance} is between 51 and 100:
    5.     broadcast "bye"
     
    • Like Like x 1
    • Useful Useful x 1
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    3 outcomes can't each have a chance of 50%... do you mean 33% chance for each?

    I personally like doing it the way Wynnevir showed because if you use multiple chance of % expressions in a row then the chances in the expressions after the first one get screwed up since you have to consider the probability that the previous chance expressions aren't successful
     
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...