Help outputting name of given 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!

Status
Not open for further replies.

CKR367

Member
Feb 1, 2017
64
2
0
I am creating a /give command, and I am trying to make skript message the player with the name of the item that was given, but it keeps saying "<none>" Here is my code:
code_language.skript:
command /invgive [<text>] [<text>] [<text>] [<text>]:
    executable by: players
    trigger:
 
I LEFT THIS PART OF THE CODE OUT

            if argument 2 is set:
                if argument 3 is set:
                    if argument 1 is "all":
                        set {_i} to argument 2 parsed as item
                        set {_a} to "%argument 3%" parsed as a number
                        if {_i} is an item:
                            if {_a} is a number:
                                message "&cInventory &8» &7You gave &c%{_a}% %name of {_i}% &7to &cALL&7."
                                message "&cInventory &8» &7You received &c%{_a}% [B]%name of {_i}% [/B] &7from &c%player%&7." to all players
                                loop {_a} times:
                                    give {_i} to all players

You can see in the line of code "&7You gave &c%{_a}% %name of {_i}% &7to &cALL&7." it has "name of {_i}" which is parsed as an item. I want it, for instance, if I give a player a diamond sword, I want it to display "Diamond Sword", which is the name of that item.
 
, like diamond_sword, not Diamond Sword, which is what I am trying to achieve
The problem is that you can't get the name of the item unless you've put a custom name to it, try using something like {_i}'s type or just replace the underline with an space.
 
The problem is that you can't get the name of the item unless you've put a custom name to it, try using something like {_i}'s type or just replace the underline with an space.
%(_i)'s type% just set it to '<none>' :emoji_frowning:

There is no way for skript to read a item's name without it being custom? I would use the tactic of removing the _'s but that means even if someone uses "DiamondSword", it won't be 2 words.
 
Last edited by a moderator:
%(_i)'s type% just set it to '<none>' :emoji_frowning:

There is no way for skript to read a item's name without it being custom? I would use the tactic of removing the _'s but that means even if someone uses "DiamondSword", it won't be 2 words. Is there a way to set a variable to the last given item or last spawned item?

You mean something like that?
code_language.skript:
set {_item} to player's held item
You can use this method too:
code_language.skript:
command /invgive [<player>]:
    trigger:
        if argument-1 is set:
            set {_item} to player's held item
            set {_amount} to amount of {_item} in player's inventory
            add player's held item to the arg-1's inventory
            message "&7You received &a%{_amount}% &b%{_item}% &7by &3%player's name%&7." to the arg-1
            message "&7You gived &a%{_amount}% &b%{_item}% &7to &3%arg-1's name%&7." to the player
            stop
        else:
            message "&cYou need to write the player's name."
            stop
 
You mean something like that?
code_language.skript:
set {_item} to player's held item
You can use this method too:
code_language.skript:
command /invgive [<player>]:
    trigger:
        if argument-1 is set:
            set {_item} to player's held item
            set {_amount} to amount of {_item} in player's inventory
            add player's held item to the arg-1's inventory
            message "&7You received &a%{_amount}% &b%{_item}% &7by &3%player's name%&7." to the arg-1
            message "&7You gived &a%{_amount}% &b%{_item}% &7to &3%arg-1's name%&7." to the player
            stop
        else:
            message "&cYou need to write the player's name."
            stop
That wouldn't work because when you give a player an item, it does not mean that they are holding it.
 
That wouldn't work because when you give a player an item, it does not mean that they are holding it.

They don't need to hold the item , just the one that need to give it.
 
Another way is edit your aliases and remove all the optional underlines from the aliases, you'll not be able to use the underlines in the item names anymore though.
 
I am creating a /give command, and I am trying to make skript message the player with the name of the item that was given, but it keeps saying "<none>" Here is my code:
code_language.skript:
command /invgive [<text>] [<text>] [<text>] [<text>]:
    executable by: players
    trigger:
 
I LEFT THIS PART OF THE CODE OUT

            if argument 2 is set:
                if argument 3 is set:
                    if argument 1 is "all":
                        set {_i} to argument 2 parsed as item
                        set {_a} to "%argument 3%" parsed as a number
                        if {_i} is an item:
                            if {_a} is a number:
                                message "&cInventory &8» &7You gave &c%{_a}% %name of {_i}% &7to &cALL&7."
                                message "&cInventory &8» &7You received &c%{_a}% [B]%name of {_i}% [/B] &7from &c%player%&7." to all players
                                loop {_a} times:
                                    give {_i} to all players

You can see in the line of code "&7You gave &c%{_a}% %name of {_i}% &7to &cALL&7." it has "name of {_i}" which is parsed as an item. I want it, for instance, if I give a player a diamond sword, I want it to display "Diamond Sword", which is the name of that item.
CKR367 how did you type the skript in the thread
 
Another way is edit your aliases and remove all the optional underlines from the aliases, you'll not be able to use the underlines in the item names anymore though.
Yeah that's the issue.
 
Status
Not open for further replies.