RDiamondz Posted May 2, 2021 Share Posted May 2, 2021 So i've made a simple crates skript but the problems is sometimes when i right click with the key it didnt give me any rewards and sometimes it gave me 2 rewards on 1 key, can anyone help me to see what's the problem in this code, it'll help me so much. Thx on right click: if event-block is a lime stained glass: if player is holding a tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate": remove 1 tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate" from player's inventory cancel event chance of 50%: give player 8 golden apple send "{@p} &bYou just got &38 Golden Apples &bfrom the crate" chance of 13%: give player 1 of blaze rod of mending named "&cFire Wand" with lore "&cUse &c&lRIGHT CLICK &r&cto shoot a fireball" send "{@p} &bYou just got &31 Fire Wand &bfrom the crate" chance of 16%: give player 1 of sunflower of mending named "&6Token" with lore "&8You can use this to buy &aCustom Items" send "{@p} &bYou just got &31 Token &bfrom the crate" chance of 5%: give player 1 enchanted golden apple send "{@p} &bYou just got &31 Enchanted Golden Apple &bfrom the crate" chance of 14%: give player 2 of tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate" send "{@p} &bYou just got &31 Uncommon Key &bfrom the crate" chance of 1%: give player 1 of tripwire hook named "&9{@ekey}" with lore "&8Use this to open &9Epic Crate" send "{@p} &bYou just got &31 Epic Key &bfrom the crate" else: push the player backwards with speed 2 send "{@p} &bUse {@ukey} to open this crate" Link to comment Share on other sites More sharing options...
AgentGamerPro Posted May 2, 2021 Share Posted May 2, 2021 (edited) 11 minutes ago, RDiamondz said: So i've made a simple crates skript but the problems is sometimes when i right click with the key it didnt give me any rewards and sometimes it gave me 2 rewards on 1 key, can anyone help me to see what's the problem in this code, it'll help me so much. Thx on right click: if event-block is a lime stained glass: if player is holding a tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate": remove 1 tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate" from player's inventory cancel event chance of 50%: give player 8 golden apple send "{@p} &bYou just got &38 Golden Apples &bfrom the crate" chance of 13%: give player 1 of blaze rod of mending named "&cFire Wand" with lore "&cUse &c&lRIGHT CLICK &r&cto shoot a fireball" send "{@p} &bYou just got &31 Fire Wand &bfrom the crate" chance of 16%: give player 1 of sunflower of mending named "&6Token" with lore "&8You can use this to buy &aCustom Items" send "{@p} &bYou just got &31 Token &bfrom the crate" chance of 5%: give player 1 enchanted golden apple send "{@p} &bYou just got &31 Enchanted Golden Apple &bfrom the crate" chance of 14%: give player 2 of tripwire hook named "&a{@ukey}" with lore "&8Use this to open &aUncommon Crate" send "{@p} &bYou just got &31 Uncommon Key &bfrom the crate" chance of 1%: give player 1 of tripwire hook named "&9{@ekey}" with lore "&8Use this to open &9Epic Crate" send "{@p} &bYou just got &31 Epic Key &bfrom the crate" else: push the player backwards with speed 2 send "{@p} &bUse {@ukey} to open this crate" This might sound a bit confusing but... The chance event doesnt work like you think. Theres a chance for every single reward so you're going to get some rewards, or if you're unlucky, none. Use: set {_variable1} to a random element out of {variable2::*} add all your rewards to variable2. heres an example: add "2 of tripwire hook named ""&a{@ukey}"" with lore ""&8Use this to open &aUncommon Crate"" to {variable2::*} Edited May 2, 2021 by AgentGamerPro Lifestealed | Minecraft Servers [VIP] 12/26/20 - 10/27/2021[PRO] 12/27/21 - Present Link to comment Share on other sites More sharing options...
RDiamondz Posted May 2, 2021 Author Share Posted May 2, 2021 16 minutes ago, AgentGamerPro said: This might sound a bit confusing but... The chance event doesnt work like you think. Theres a chance for every single reward so you're going to get some rewards, or if you're unlucky, none. Use: set {_variable1} to a random element out of {variable2::*} add all your rewards to variable2. heres an example: add "2 of tripwire hook named ""&a{@ukey}"" with lore ""&8Use this to open &aUncommon Crate"" to {variable2::*} So the only way is to do it randomly and not with chances? Cus i saw here it say "random element" Link to comment Share on other sites More sharing options...
AgentGamerPro Posted May 2, 2021 Share Posted May 2, 2021 1 hour ago, RDiamondz said: So the only way is to do it randomly and not with chances? Cus i saw here it say "random element" As far as i know yes Lifestealed | Minecraft Servers [VIP] 12/26/20 - 10/27/2021[PRO] 12/27/21 - Present Link to comment Share on other sites More sharing options...
_Tarna_ Posted May 2, 2021 Share Posted May 2, 2021 2 minutes ago, AgentGamerPro said: As far as i know yes 1 hour ago, RDiamondz said: So the only way is to do it randomly and not with chances? Cus i saw here it say "random element" You can use random numbers to use chance instead too. set {_r} to random integer between 1 and 100 if {_r} is between 1 and 10: # this is a chance of 10% else if {_r} is between 11 and 50: # chance of 40% else if {_r} is between 51 and 100: # chance of 50% You can also increase or decrease the range of the random number it generates if you want too. Discord - Tarna256#8675 In-game name - _Tarna_ Follow @Tarna_256 on Twitter --------------------------------------------------------- [VIP] - 7/27/2020 Support - 7/8/20 | 11/3/20 Helper - 11/3/20 - 2/21/21 Moderator - 2/21/21 - 5/17/21 - 5/17/21 - now Moderator - 12/20/22 - now --------------------------------------------------------- Link to comment Share on other sites More sharing options...
RDiamondz Posted May 2, 2021 Author Share Posted May 2, 2021 1 hour ago, AgentGamerPro said: This might sound a bit confusing but... The chance event doesnt work like you think. Theres a chance for every single reward so you're going to get some rewards, or if you're unlucky, none. Use: set {_variable1} to a random element out of {variable2::*} add all your rewards to variable2. heres an example: add "2 of tripwire hook named ""&a{@ukey}"" with lore ""&8Use this to open &aUncommon Crate"" to {variable2::*} So the only way is to do it randomly and not with chances? Cus i saw here it say "random element" Okay, thx for the help, i'll try this Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now