Solved Custom Tags wont work

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

Status
Not open for further replies.

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hello, im having a little trouble on getting some tags to work. I have a command that i can use to add or remove tags from a player. It works. I can add a tag, and use the /tags command to bring up the menu that shows all the tags. It will be listed in there, with the correct name that i give it. But im working on a Christmas event, and you can buy tags from a GUI. But im using a on inventory click event. I cant use a command to add the tags to the player. I have to use something like: add colored "&aJolly" to {tags::%player%::*}. But when i click the slot in the gui to add the tag, it says the tag is <none>. But like i said. If i add a tag with the command, it shows up correct. Im not sure what im doing wrong, and how to correct it. If someone knows what wrong, please let me know asap.

Thanks!
~Matt

Command to add/remove a tag:

Code:
command /tags [<text>] [<text>] [<offlineplayer>]:
    trigger:
        if arg-1 is "remove":
            if player has permission "tags.admin":
                remove arg-2 from {tags::%arg-3%::*}
                send "&aYou removed the tag %arg-2%&a from %arg-3%&a's tags!"
                set {tag::on::%arg-3%} to "&8[&aNone&8]"
        if arg-1 is "add":
            if player has permission "tags.admin":
                add arg-2 to {tags::%arg-3%::*}
                set {HCOL::%arg-3%::%arg 2%} to colored arg-2
                send "&aYou added the tag %colored arg-2%&a to %arg-3%&a's tags!"
        if arg-1 isn't set:
            tags(player)

Open tags menu:

Code:
function tags(P: player):
    open chest inventory with 6 rows named "&d&ltags" to {_P}
    if {tag::on::%{_P}%} isn't set:
        set {tag::on::%{_P}%} to "&8[&aNone&8]"
    set {_var} to 44
    loop 9 times:
        add 1 to {_var}
        set slot {_var} of {_P}'s current inventory to black stained glass pane named ""
    set slot 40 of {_P}'s current inventory to barrier named "&c&lClose Menu"
    set slot 38 of {_P}'s current inventory to tnt named "&cRemove tag!"
    if size of {tags::%{_P}%::*} is bigger than 0:
        set {_tags} to 0
        loop {tags::%{_P}%::*}:
            set {tags} to loop-value
            set slot {_tags} of {_P}'s current inventory to name tag named "&8[%{HCOL::%{_P}%::%{tags}%}%&8]"
            add 1 to {_tags}
    while name of {_P}'s current inventory contains "&d&ltags":
        set slot 36 of {_P}'s current inventory to diamond named "&bCurrent tag: %{tag::on::%{_P}%}%"
        wait 1 seconds

Code to get a tag from the GUI that wont work:

Code:
on inventory click:
    if name of player's current inventory contains "    &b❆&b&lChristmas Event&b❆":
        cancel event
        if index of event-slot is 13:
            buytags(player)
function buytags(P: player):
    open chest inventory with 4 rows named "           &b❆&bBuy Tags&b❆" to {_P}
    set slot 0, 2, 4, 6, 8, 18, 26, 28, 30, 32 and 34 of {_P}'s current inventory to green stained glass pane named "&a"
    set slot 1, 3, 5, 7, 9, 17, 27, 29, 31, 33 and 35 of {_P}'s current inventory to blue stained glass pane named "&a"
    set slot 31 of {_P}'s current inventory to barrier named "&c&lMain Page"
    set slot 10 of {_P}'s current inventory to name tag named "&aJolly" with lore "&8- &bCost: &ax100 Event Tokens"
    set slot 11 of {_P}'s current inventory to name tag named "&8[&7Coal&8] &aTag" with lore "&8- &bCost: &ax150 Event Tokens"
    set slot 12 of {_P}'s current inventory to name tag named "&8[&2Elf&8] &aTag" with lore "&8- &bCost: &ax200 Event Tokens"
    set slot 13 of {_P}'s current inventory to name tag named "&8[&bMrs.Clause&8] &aTag" with lore "&8- &bCost: &ax250 Event Tokens"
    set slot 14 of {_P}'s current inventory to name tag named "&8[&bSanta&8] &aTag" with lore "&8- &bCost: &ax250 Event Tokens"
    set slot 15 of {_P}'s current inventory to name tag named "&8[&fSnowman&8] &aTag" with lore "&8- &bCost: &ax50 Event Tokens"
    set slot 16 of {_P}'s current inventory to name tag named "&8[&c2020&8] &aTag" with lore "&8- &bCost: &ax2020 Event Tokens"
    set slot 19 of {_P}'s current inventory to name tag named "&8[&cNaughty&8] &aTag" with lore "&8- &bCost: &ax5000 Event Tokens"
    set slot 20 of {_P}'s current inventory to name tag named "&8[&bNice&8] &aTag" with lore "&8- &bCost: &ax5000 Event Tokens"
on inventory click:
    if name of player's current inventory contains "&bBuy Tags":
        cancel event
        if index of event-slot is 31:
            christmas(player)
        if index of event-slot is 10:
            if {christmas::money::%player's uuid%} >= 100:
                remove 100 from {christmas::money::%player's uuid%}
                send "&aYou bought the &8[&aJolly&8] &atag!"
                add colored {HCOL::%player%::%colored name of event-slot%} to {tags::%player%::*}
            else:
                close player's inventory
                send "&cYou dont have enough event tokens!"
 
  • Like
Reactions: FrostPVP™️
I'm not really 100% sure what the problem is, but i can recommend some stuff to you based on what ive seen.
1. its better to use %player's uuid% due to this being persistent over name changes, which just makes sure if a player changes their name they wont lose their tags.
2. Instead of checking for the name of a players inventory, use metadata tags, for example,
Code:
#making the inventory example
set metadata tag "buyTags" of player to chest inventory with 3 rows named "&bBuy Tags"
set slot 0 of metadata tag "buyTags" of player to stone named "test"
open (metadata tag "buyTags" of player) to player
#example of checking the inventory clicking
on inventory click:
    if player's current inventory != (metadata tag "buyTags" of player):
        stop
    cancel event
    if index of event-slot = 0:
        send "you have clicked our test stone!"
 
Status
Not open for further replies.