Chances not working

Discussion in 'Skript' started by B1a7e, Feb 12, 2020.

  1. My skript is a crate skript and it when opening it might give nothing, a reward, or 2+ rewards anyway to stop

    Code (Text):
    on rightclick on chest:
        if "%location of event-block%" is "x: -398.5, y: 98.5, z: 171.5":
            cancel event
            name of player's tool is "&cPvP &7Key":
                set {_firestick} to stick named "&4&lFire &c&lStick"
                enchant {_firestick} with fire aspect 1
                chance of 50%:
                    add 3 to {exp::%player%}
                    send "&8[&c&lKEYS&8] &7You have won &a3 &lXP"
                chance of 10%:
                    give player 1 of {_firestick}
                    broadcast "&8[&c&lKEYS&8] &b%player% &7has won a &4&lFire &c&lStick"
                chance of 30%:
                    give player 4 ender pearls
                    send "&8[&c&lKEYS&8] &7You have won &54 &lEnderpearls"
                chance of 10%:
                    give player 3 arrows
                    send "&8[&c&lKEYS&8] &7You have won &r3 &lArrows"
     
  2. And what isn't working?... everything?
     
  3. chance of is unreliable, because it may never trigger any

    I recommend random integer
    set {_random} to a random integer betweeen 1 and ...something you want

    then do:
    Code (Text):

    switch {_random}:
      case 1:#the {_random} being 1
        #do something
      case 2:
        #do something else
      case default:
        #if nothing triggered, when you set random integer maximum/minimum lower/higher than the cases you have written.
    if you want some things to have higher chances, then use if and else if with multiple integers based on how common you want it to be