Death Package

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

    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!

Radoco

Member
Jun 14, 2024
11
0
1
Im trying to make a death package: when you kill a player it drops a chest {unplaceable} and if you right-click with the chest in the right-hand you get transfered the victim's item into the attacker's inventory
 
This is not viable without storing custom NBT data in the chest item because a player can have more than 27 slots.

1) create the chest item `set {_item} to 1 chest named "whatever"`
2) loop victim's inventory when they die
3) `add full nbt of loop-value to {_items::*}` https://skripthub.net/docs/?id=10689
4) after the loop, `set compound list tag "minecraft:custom_data;DeathItems" of nbt of {_item} to {_items::*}

This will store the items inside the chest, now for the claiming part.

1) Inside the right click (or place) event, check `if nbt of player's tool has tag "minecraft:custom_data;DeathItems"`
if this passes that means its an item generated by our code.
2) get the list of items (as an nbt compound) `set {_items::*} to compound list tag "minecraft:custom_data;DeathItems" of nbt of player's tool`
3) give the items, `drop (item from nbts {_items::*}) at player`
the reason we use `drop` over `give` is because the items might disappear if the player doesn't have enough inventory space.

Try doing it yourself and if it doesn't work send your attempt!
 
This is not viable without storing custom NBT data in the chest item because a player can have more than 27 slots.

1) create the chest item `set {_item} to 1 chest named "whatever"`
2) loop victim's inventory when they die
3) `add full nbt of loop-value to {_items::*}` https://skripthub.net/docs/?id=10689
4) after the loop, `set compound list tag "minecraft:custom_data;DeathItems" of nbt of {_item} to {_items::*}

This will store the items inside the chest, now for the claiming part.

1) Inside the right click (or place) event, check `if nbt of player's tool has tag "minecraft:custom_data;DeathItems"`
if this passes that means its an item generated by our code.
2) get the list of items (as an nbt compound) `set {_items::*} to compound list tag "minecraft:custom_data;DeathItems" of nbt of player's tool`
3) give the items, `drop (item from nbts {_items::*}) at player`
the reason we use `drop` over `give` is because the items might disappear if the player doesn't have enough inventory space.

Try doing it yourself and if it doesn't work send your attempt!
Yo i tried it gives me error, if i made a major mistake dont yell at me i am new to skript

Attempt
on death:
set {inv_} to chest named "&4&lDeath Package"
loop victim's inventory:
add full nbt of loop-value to {_inv::*}
set compound list tag "minecraft:custom_data;DeathItems" of nbt of {inv_} to {_inv::*}
-
on right-click:
if nbt of player's tool has tag "minecraft:custom_data;DeathItems":
set {_inv::*} to compound list tag "minecraft:custom_data;DeathItems" of nbt of player's tool
drop (item from nbts {_items::*}) at player
 

Attachments

  • Captură de ecran 2024-09-08 112140.png
    Captură de ecran 2024-09-08 112140.png
    20 KB · Views: 210