Jump to content

Could someone help me fix a skript?


Juskittin_

Recommended Posts

I was making a server with loot-crate like chests where you right click one it drops a random item from a list of items and the chest disappears and respawns in the same spot after a short time, I've got the disappearing and respawning down, but i need help with the random item dropping, i tried doing it on my own but either it drops 2 different items or give you nothing. I will provide my skript and i was hoping someone could help me fix it. Thank you.

 

Edited by Juskittin_
Removed an un-wanted image
Link to comment
Share on other sites

6 hours ago, Juskittin_ said:

I was making a server with loot-crate like chests where you right click one it drops a random item from a list of items and the chest disappears and respawns in the same spot after a short time, I've got the disappearing and respawning down, but i need help with the random item dropping, i tried doing it on my own but either it drops 2 different items or give you nothing. I will provide my skript and i was hoping someone could help me fix it. Thank you.

 

Well for people trying to help you, it would be nice if you actually provided your code.

Edited by ApexSplat

Discord: Dead#6905

Love anime!


Anime Gifs

Link to comment
Share on other sites

12 hours ago, ApexSplat said:

Well for people trying to help you, it would be nice if you actually provided your code.

Yeah sorry about that, yknow how minehuts free servers are down for about a week? Yeah my code is in the folders and i do not remember it by heart i will try to type it out here though.

on right-click:

    if event-block is chest:

chance 25%:

        drop 1 diamond

chance 25%:

        drop 1 dirt

chance 25%:

        drop 1 stone

chance 25%:

        drop 1 gold_ingot

     

 

Link to comment
Share on other sites

Well the problem here is if you are really lucky, you can get all 4 items. You can set a local var to a random integer between 1 and 4 as that is the same as 25% chance for each and if it is 1 they get diamond, 2 they get dirt etc

Discord: Dead#6905

Love anime!


Anime Gifs

Link to comment
Share on other sites

8 hours ago, ApexSplat said:

Well the problem here is if you are really lucky, you can get all 4 items. You can set a local var to a random integer between 1 and 4 as that is the same as 25% chance for each and if it is 1 they get diamond, 2 they get dirt etc

Could you provide an example of code like that? I am really new to code and I don't really know what a "local var" is. Sorry if I'm bothering you.

Link to comment
Share on other sites

set {_i} ro random integer between 1 and 4
if {_i} is 1:
	drop 1 diamond
else if {_i} is 2:
	drop 1 dirt
else if {_i} is 3:
	drop 1 stone
else if {_i} is 4:
	drop 1 gold ingot

 

Edited by ApexSplat

Discord: Dead#6905

Love anime!


Anime Gifs

Link to comment
Share on other sites

On 4/25/2023 at 8:01 AM, ApexSplat said:
set {_i} ro random integer between 1 and 4
if {_i} is 1:
	drop 1 diamond
else if {_i} is 2:
	drop 1 dirt
else if {_i} is 3:
	drop 1 stone
else if {_i} is 4:
	drop 1 gold ingot

 

Sadly, this code did not work, i will try to experiment with it but, is there anything in the code that i need to change?

Link to comment
Share on other sites

9 hours ago, ApexSplat said:

you spelt to wrong

 

 

Oh, I fixed that but when i tried to do it it did not work at first it gave you something every time you right-click something and now ive tried to fix it it it dosent give you anything. Here's the exact code. 

image.png

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...