Optimized RNG Chances

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

Luke_Sky_Walker

Well-Known Member
Jul 11, 2023
250
27
28
USA
sites.google.com
If you were to arrange an RNG type item system with multiple values and chances like so (This is just a rough example by the way):

Code:
function exam(n: text, p: player)
   chance of 5%:
      give {_p} 1 of gold ingot named "%{_n}%"
      stop
   chance of 1%:
      give {_p} 1 of diamond named "%{_n}%"
      stop

command test:
   trigger:
      chance of 1.5%:
         set {_p} to player
         set {_name} to "&bExample"
         examp({_name}, {_p})

Would there by a way to make this kind of code more effective (Ideally to be a lot shorter and with the ability to have a lot more % chances without using up a lot of lines)?
 
Last edited: