Jump to content

Help me with crates skript plss


RDiamondz

Recommended Posts

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

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 by AgentGamerPro

 

 

image.png.bc433d6489d70ad831075fe76809b993.png
 

Lifestealed | Minecraft Servers
 

OG [VIP] 12/26/20 - 10/27/2021
OG [PRO] 12/27/21 - 11/18/2022
OG [LEGEND] 11/18/2022 - 3/14/2023
[DEFAULT] 3/14/2023 - Present

 

Link to comment
Share on other sites

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

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

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community 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

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...