I need someone who can fix my skript. I'm not experienced enough.

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

Maki

Member
Jul 26, 2024
4
0
1
Code:
on death:
    if victim is in region "elytra-pvp":
        set {-drops::%victim's uuid%::*} to drops
        drop 1 of chest named "&d%victim%'s &eDeath Package" with lore "&8[&7Right-Click&8] &7to claim!"
        clear drops
    
on right click:
    name of event-item contains "Death Package":
        cancel event
        set {_d} to name of event-item
        replace all "&d" and "&e" and "'s Death Package" in {_d} with ""
        set {_f} to {_d} parsed as offline player
        if player can hold {-drops::%{_f}'s uuid%::*}:
            give player {-drops::%{_f}'s uuid%::*}
            delete {-drops::%{_f}'s uuid%::*}
            remove event-item from player's inventory
            play sound "ITEM_ARMOR_EQUIP_NETHERITE" with pitch 0 to players in radius 10 of player
            play sound "ENTITY_PUFFER_FISH_BLOW_UP" with pitch 1 to players in radius 10 of player
        else if player can't hold {-drops::%{_f}'s uuid%::*}:
            send action bar "&cYou don't have enough space in invenotry" to player
            play sound "BLOCK_ANVIL_PLACE" with pitch 1 to player


on left click:
    name of event-item contains "Death Package":
        open virtual chest inventory with size 5 named "Test" to player
 
So when you kill a player it drops a chest item that you can right-click to claim loot.
This works but it is buggy, for example, if I kill a player twice it will stop working.

On left-click it should open a preview GUI, have no idea how to do this at all
 
You can edit this around a bit but it works and has a expire date of 24h you can edit the time if you want but here it is:







on death:
victim is a player
cancel drops

set {_chest} to getInventoryChest(victim)
drop 1 of {_chest} at victim

on right click with chest:
if (int tag "custom;isSavedInventory" of nbt of held item) is set:
cancel event
set {_oldnow} to int tag "custom;expireChest" of nbt of player's tool
if difference between now and (unix date of {_oldnow}) > 24 hours:
send "yes" to player
send action bar "&cThis Death Stash is expired you can't claim it!" to player
remove 1 of player's tool from player
else:
send "no" to player
giveInventoryChest(player, (player's held item))
remove 1 of player's held item from player

set {_name} to name of player's tool
send action bar "&aYou've claimed a death stash!" to player
play sound "ui.toast.in" to player
on left click with chest:
if (int tag "custom;isSavedInventory" of nbt of held item) is set:
cancel event

set {_i::*} to compound list tag "custom;savedItems" of nbt of player's tool
loop {_i::*}:
add nbt item from loop-value to {_i2::*}
set {_name} to name of player's tool
set {_GUI} to chest inventory with 4 rows named "%{_name}%"
add {_i2::*} to {_GUI}
open {_GUI} to event-player
on inventory click:
if uncolored name of event-inventory contains "Death Stash":
cancel event
local function giveInventoryChest(player: player, chest: itemtype):
set {_i::*} to compound list tag "custom;savedItems" of nbt of {_chest}
loop {_i::*}:
set {_i} to nbt item from loop-value
give or drop {_i} to {_player}

local function getInventoryChest(player: player) :: itemtype:
set {_item} to chest named "&a%{_player}%'s Death Stash" with lore "&7Right-Click to claim" and "&7Left-Click to preview" and " " and "&cNote: This chest will expiry after 24hour if you didn't claimed it!"
set int tag "custom;isSavedInventory" of nbt of {_item} to 1
set {_nownbt} to unix timestamp of now
set int tag "custom;expireChest" of nbt of {_item} to {_nownbt}
loop inventory of {_player}:
set {_s} to index of loop-slot
set {_i} to full nbt of loop-slot

set int tag "Slot" of {_i} to {_s}
add {_i} to {_i::*}
set compound list tag "custom;savedItems" of nbt of {_item} to {_i::*}
return {_item}
 
  • Like
Reactions: Maki
You can edit this around a bit but it works and has a expire date of 24h you can edit the time if you want but here it is:







on death:
victim is a player
cancel drops

set {_chest} to getInventoryChest(victim)
drop 1 of {_chest} at victim

on right click with chest:
if (int tag "custom;isSavedInventory" of nbt of held item) is set:
cancel event
set {_oldnow} to int tag "custom;expireChest" of nbt of player's tool
if difference between now and (unix date of {_oldnow}) > 24 hours:
send "yes" to player
send action bar "&cThis Death Stash is expired you can't claim it!" to player
remove 1 of player's tool from player
else:
send "no" to player
giveInventoryChest(player, (player's held item))
remove 1 of player's held item from player

set {_name} to name of player's tool
send action bar "&aYou've claimed a death stash!" to player
play sound "ui.toast.in" to player
on left click with chest:
if (int tag "custom;isSavedInventory" of nbt of held item) is set:
cancel event

set {_i::*} to compound list tag "custom;savedItems" of nbt of player's tool
loop {_i::*}:
add nbt item from loop-value to {_i2::*}
set {_name} to name of player's tool
set {_GUI} to chest inventory with 4 rows named "%{_name}%"
add {_i2::*} to {_GUI}
open {_GUI} to event-player
on inventory click:
if uncolored name of event-inventory contains "Death Stash":
cancel event
local function giveInventoryChest(player: player, chest: itemtype):
set {_i::*} to compound list tag "custom;savedItems" of nbt of {_chest}
loop {_i::*}:
set {_i} to nbt item from loop-value
give or drop {_i} to {_player}

local function getInventoryChest(player: player) :: itemtype:
set {_item} to chest named "&a%{_player}%'s Death Stash" with lore "&7Right-Click to claim" and "&7Left-Click to preview" and " " and "&cNote: This chest will expiry after 24hour if you didn't claimed it!"
set int tag "custom;isSavedInventory" of nbt of {_item} to 1
set {_nownbt} to unix timestamp of now
set int tag "custom;expireChest" of nbt of {_item} to {_nownbt}
loop inventory of {_player}:
set {_s} to index of loop-slot
set {_i} to full nbt of loop-slot

set int tag "Slot" of {_i} to {_s}
add {_i} to {_i::*}
set compound list tag "custom;savedItems" of nbt of {_item} to {_i::*}
return {_item}
Tnx, the only issue is that players drop chest and loot when the logoff in combat