function itemtype doesn't return an item

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

MiiTsY

Active Member
May 27, 2022
50
1
8
Hello so here's a code that worked a few years ago (2022 I think? so for quite old skript version) but which does not work anymore since I updated Skript and a few addons and I cannot find the uptodate syntax/way to do it. These were functions that were supposed to return an item named and with lore (and attributes, which is why I used NBT) with a command.

Code:
function FleshoftheoldKing() :: itemtype:
    set {_i} to rotten flesh named "&2Flesh of the old King" with lore "&7Smells really bad ..." and "&7maybe an use for it ..?"
    set {_n} to nbt compound of {_i}
    return nbt item of {_n}


Code:
command /givecustom [<text>]:
    permission: staff.admin
    trigger:
        if arg-1 is set:
            if arg-1 is "FleshoftheoldKing":
                give player FleshoftheoldKing()

Result = no errors, just nothing

here's my skript and addons versions:
1744324622297.png
1744324642210.png


Please help :emoji_grinning:
 
Last edited:
try this
Code:
function FleshoftheoldKing() :: item:
    set {_i} to rotten flesh named "&2Flesh of the old King" with lore "&7Smells really bad ..." and "&7maybe an use for it ..?"
    return {_i}

command /givecustom [<text>]:
    permission: staff.admin
    trigger:
        if arg-1 is set:
            if arg-1 is "FleshoftheoldKing":
                give player FleshoftheoldKing()
 
I know this works, but what about attributes ?

How would you make this work ?

Code:
function HeavyBoots() :: itemtype:
    set {_i} to iron boots named "&5Heavy Boots" with lore "&7Gear Rating: &e75" and "&7Defence: &4100" and "&7Health: &41" and " " and "&4Requires &2Level: &220" and "&5Chestplate made by a famous Dwarf." and "&5Said to be so resistant that even dragons wouldn't melt it... " and "&5But it's too heavy." with all flags hidden
    set {_n} to nbt compound of {_i}
    set {_a::*} to tag "tag;AttributeModifiers" of {_n}
    add nbt compound of "{AttributeName:""generic.max_health"",Amount:1,Operation:0,Slot:chest,UUID:[I;-1201124,10148,125632,-20296],Name:""generic.max_health""}" to {_a::*}
    add nbt compound of "{AttributeName:""generic.armor"",Amount:0,Operation:0,Slot:chest,UUID:[I;-1201124,10148,125632,-20296],Name:""generic.armor""}" to {_a::*}
    add nbt compound of "{}" to {_a::*}
    set tag "tag;AttributeModifiers" of {_n} to {_a::*}
    return nbt item from {_n}
 
why not just add the attribute to the player when they equip the armor?
set player's max health attribute to 20
 
Does that not require more server ressource since u'd have to update each time a player equip, unequip, swap tools and logs in? Also would add checks to every gear that exist no? (if helmet's name is "", etc etc) which would make a mess of a code
 
no it would not make a mess of your code, it may take a SLIGHT bit more power but probably not noticeable, and logging in would do nothing because it changes the attribute, and it will only check the slot tag name or item you want
 
  • Like
Reactions: MiiTsY
Aight thx for the help tho! I'll leave it open for now in case someone knows the uptodate syntaxe with nbts.