# Chance of NUMBER%: Always chose only 1

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

Not open for further replies.
1. ### LoneElf Active Member

Joined:
Apr 30, 2017
Messages:
165
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

#1
2. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
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:
4. if {_chance} is between 51 and 100:

#2
• Like x 1
• Useful x 1
3. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
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

#3
• Like x 1
Not open for further replies.