Solved Item id?

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

TimeStellar

Member
Mar 4, 2024
19
0
1
24
i want to make a item level system but i wanna use varibles but how would i make a variable for a specific item like an id or smth like that.

Code:
command /admin <text>:
    permission: op
    trigger:
        if arg-1 is "give":
            give diamond sword named "&aLeveled Sword" with lore "" and "Lvl {itemlevel} ({xp}/{maxxp})"
 
i want to make a item level system but i wanna use varibles but how would i make a variable for a specific item like an id or smth like that.

Code:
command /admin <text>:
    permission: op
    trigger:
        if arg-1 is "give":
            give diamond sword named "&aLeveled Sword" with lore "" and "Lvl {itemlevel} ({xp}/{maxxp})"
Best way would to be to use list variables attached to the player's uuid and use a function when it comes to adding/removing XP or levels.
 
yeah but that would make all of the items same level and xp i wanna keep it like to the item not player
 
yeah but that would make all of the items same level and xp i wanna keep it like to the item not player
I think you might be mistaken? If you are to use a variable like {example} to store the item's XP and level data and one player levels it up to let's say level 10 and they gain 10 XP for the item. Now every player's item will be level 10 and have 10 XP. You can still keep it to the item using a different variable by using a variable like {example2::%player's uuid%}, only difference is it won't be synched to EVERY player's level & xp for their item.
 
ok yeah does list variable work for that?
It certainly does. When you want individual values for players, list variables are the way to go. I use em pretty frequently. Also a kinda cool thing you can do with list variables is that you can sort em. Meaning you could set up a leaderboard of which player has the highest level or amount of a specified list variable.
 
well can you help me a little cuz i dont realy use it often can you give me a example on how it would work on my skript?
 
well can you help me a little cuz i dont realy use it often can you give me a example on how it would work on my skript?
command /admin <text>:
permission: op
trigger:
if arg-1 is "give":
give diamond sword named "&aLeveled Sword" with lore "" and "Level 1 (0/100)" to player

on right click:
if name of player's tool is "&aLeveled Sword":
set {_lore::*} to lore of player's tool
loop {_lore::*}:
if loop-value contains "Level":
set {_uuid} to uuid of player
set {_nbt} to nbt of player's tool
set {_item} to item with nbt {_nbt}

set {_level::*} to uncolored loop-value split at " "
set {_level} to {_level::2} parsed as number

set {_xp_data::*} to uncolored {_level::4} split at "/"
set {_xp} to {_xp_data::1} parsed as number
set {_max_xp} to {_xp_data::2} parsed as number

add 10 to {_xp}
if {_xp} >= {_max_xp}:
set {_xp} to 0
add 1 to {_level}

set {_new_lore} to "Level %{_level}% (%{_xp}%/%{_max_xp}%)"
set lore of player's tool to "{@new_lore}"
send "You leveled up your item to level %{_level}%!" to player
 
  • Like
Reactions: Luke_Sky_Walker
ok thank you the code has some bugs like first the new lore variable is wrong its needs to be %{_new_lore}% and the xp system doesnt work at all but thank you for the help
 
ok thank you the code has some bugs like first the new lore variable is wrong its needs to be %{_new_lore}% and the xp system doesnt work at all but thank you for the help
my bad and no problem, I am a new skripter myself