Item lives

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

2Unexpected

Member
Nov 4, 2022
19
1
3
23
Category:
Skript Request

Suggested name:
Item lives

Spigot/Skript Version:
Should support Skript_2.2-dev36 (Because it's used on a 1.8.8 PVP based server)

What I want:
A command to add lives to items, If an item has 2 lives, If you die it loses a life but it wont be removed from your inventory, If you die a second time you will lose the item, I want to add a command to add lives with lore that says the amount of lives left on an item.

Ideas for commands:
If I'm holding a diamond sword (The skript should work with custom/non vanilla items too), by running /itemlivesadd 5, The item will receive 5 lives and a lore to see the lives left.

Ideas for permissions:
op

When I'd like it by: As soon as possible

Example picture:

Screenshot 2024-07-10 210953.png
 
Last edited:
Made by crafty code ai

on rightclick:
if player's tool is diamond sword:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} is 0:
set {_lives} to 5
else:
set {_lives} to {_lives} + 5
set lore of player's tool to "Lives left: %{_lives}%"

command /itemlivesadd <number>:
permission: itemlives.add
trigger:
if player's tool is not air:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} is 0:
set {_lives} to arg-1
else:
set {_lives} to {_lives} + arg-1
set lore of player's tool to "Lives left: %{_lives}%"
send "You have added %{arg-1}% lives to your item!"
else:
send "You must be holding an item to use this command."

on death:
if player's tool is not air:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} > 1:
set lore of player's tool to "Lives left: %{_lives - 1}%"
send "You lost 1 life! Lives left: %{_lives - 1}%"
else:
clear player's tool
send "You have lost your item!"
 
Made by crafty code ai

on rightclick:
if player's tool is diamond sword:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} is 0:
set {_lives} to 5
else:
set {_lives} to {_lives} + 5
set lore of player's tool to "Lives left: %{_lives}%"

command /itemlivesadd <number>:
permission: itemlives.add
trigger:
if player's tool is not air:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} is 0:
set {_lives} to arg-1
else:
set {_lives} to {_lives} + arg-1
set lore of player's tool to "Lives left: %{_lives}%"
send "You have added %{arg-1}% lives to your item!"
else:
send "You must be holding an item to use this command."

on death:
if player's tool is not air:
set {_lives} to 0
loop all lore of player's tool:
if loop-value contains "Lives left: ":
set {_lives} to integer of (loop-value - "Lives left: ")
if {_lives} > 1:
set lore of player's tool to "Lives left: %{_lives - 1}%"
send "You lost 1 life! Lives left: %{_lives - 1}%"
else:
clear player's tool
send "You have lost your item!"
The skript has to check all the player's items for the ones having lives instead of the item they are holding, This skript just checks and tells if u lost a live on the item you were holding and does literally nothing else, It doesn't even give you back the item. Also one of my important plugins removes all items from a player's inventory on death so it has to be placed in the exact same inventory/armor slot of the player again after death as well.