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

Status
Not open for further replies.

Astral

Member
May 31, 2020
2
0
0
23
Hello i'm wondering how to make that when u right click a cd for example stal u get a random item except for bedrock. Can anyone help me?
 
Do you mean something like this?
Code:
on right click on polished granite:
    loop all items:
        add loop-item to {_loop::*}
    remove bedrock from {_loop::*}
    give player a random item out of {_loop::*}
Do not mind the polished granite, used just for testing :emoji_grinning:
[doublepost=1590942936,1590942658][/doublepost]Okay... there may be a problem, it takes a bit of time to loop all items. You can do this:
Code:
on load:
    loop all items:
        add loop-item to {allitems::*}
    remove bedrock from {allitems::*}
on right click on polished granite:
    give player a random item out of {allitems::*}
 
Do you mean something like this?
Code:
on right click on polished granite:
    loop all items:
        add loop-item to {_loop::*}
    remove bedrock from {_loop::*}
    give player a random item out of {_loop::*}
Do not mind the polished granite, used just for testing :emoji_grinning:
[doublepost=1590942936,1590942658][/doublepost]Okay... there may be a problem, it takes a bit of time to loop all items. You can do this:
Code:
on load:
    loop all items:
        add loop-item to {allitems::*}
    remove bedrock from {allitems::*}
on right click on polished granite:
    give player a random item out of {allitems::*}

After reloading your skript 2 times, you now have a list with 2x all items.

This code works instantly after reload and I would recommend using it instead.
Code:
on rightclick on stone:
    set {_items::*} to all items
    remove bedrock from {_items::*}
    give player a random item out of {_items::*}
 
  • Like
Reactions: Nikd0
After reloading your skript 2 times, you now have a list with 2x all items.

This code works instantly after reload and I would recommend using it instead.
Code:
on rightclick on stone:
    set {_items::*} to all items
    remove bedrock from {_items::*}
    give player a random item out of {_items::*}
Yes, but when I tested it, it took about 1 second to loop all items and give it to player. If he doesn't mind, you can sure use it.
In my last code I forgot to add
Code:
if {allitems::*} is not set:
    loop all items:
        #...
 
  • Like
Reactions: Astral
Yes, but when I tested it, it took about 1 second to loop all items and give it to player. If he doesn't mind, you can sure use it.
In my last code I forgot to add
Code:
if {allitems::*} is not set:
    loop all items:
        #...
Hey man thanks for helping me do this, I surely dont mind about the 1 second
[doublepost=1591021919,1591021791][/doublepost]
In my code I don't loop all items. It's instant and reliable.
Thank you aswell
 
Status
Not open for further replies.