Solved (help) create 3 random drops from player inventory and blacklist

  • 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.
Mar 29, 2020
28
0
1
28
Hello friends, I want to create a plugin for my server with scripts, but I am a beginner. I should not do to create a plugin that players on death drop only 3 random items from their inventory. I would also like to have a blacklist of objects that can never be dropped. thanks I hope you can help me!
 
Code:
on script load:
    set {blacklist::*} to diamond, cactus, and chest
   
on death of a player:
    keep the inventory
    set {_itemsToDrop::*} to all items of victim's inventory where [{blacklist::*} doesn't contain input]
    loop min((size of {_itemsToDrop::*}) and 3) times:
        set {_item} to a random item out of {_itemsToDrop::*}
        remove {_item} from victim's inventory
        remove {_item} from {_itemsToDrop::*}
        drop {_item} at victim's location
this should be what are you trying to make. Edit {blacklist*} elements to match your choice.
 
Last edited:
Code:
on script load:
    set {blacklist::*} to diamond, cactus, and chest
  
on death of a player:
    keep the inventory
    set {_itemsToDrop::*} to all items of victim's inventory where [{blacklist::*} doesn't contain input]
    loop min((size of {_itemsToDrop::*}) and 3) times:
        set {_item} to a random item out of {_itemsToDrop::*}
        remove {_item} from victim's inventory
        remove {_item} from {_itemsToDrop::*}
        drop {_item} at victim's location
this should be what are you trying to make. Edit {blacklist*} elements to match your choice.
genius! That is something that I could never do with my little knowledge. I'll try it later, I really appreciate your help :emoji_slight_smile:
[doublepost=1585672102,1585636221][/doublepost]
Code:
on script load:
    set {blacklist::*} to diamond, cactus, and chest
  
on death of a player:
    keep the inventory
    set {_itemsToDrop::*} to all items of victim's inventory where [{blacklist::*} doesn't contain input]
    loop min((size of {_itemsToDrop::*}) and 3) times:
        set {_item} to a random item out of {_itemsToDrop::*}
        remove {_item} from victim's inventory
        remove {_item} from {_itemsToDrop::*}
        drop {_item} at victim's location
this should be what are you trying to make. Edit {blacklist*} elements to match your choice.

I already tried it and it worked! but at the beginning it did not drop the articles but it did delete them, because first it eliminated them and later it detected them but they were no longer in the inventory. so change the order and it works! Many thanks!


So I stay, it works 100%


Code:
on death of a player:
    keep the inventory
    set {_itemsToDrop::*} to all items of victim's inventory where [{blacklist::*} doesn't contain input]
    loop min((size of {_itemsToDrop::*}) and 2) times:
        set {_item} to a random item out of {_itemsToDrop::*}
        set {_item} to a random item out of {_itemsToDrop::*}
        wait 1 ticks       
        drop {_item} at victim's location       
        remove {_item} from {_itemsToDrop::*}
        wait 1 ticks       
        remove {_item} from victim's inventory
 
Status
Not open for further replies.