1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Custom Tags wont work

Discussion in 'Skript' started by Mattllama987, Dec 1, 2020.

Thread Status:
Not open for further replies.
  1. Mattllama987

    Mattllama987 Active Member

    Joined:
    Aug 5, 2018
    Messages:
    225
    Likes Received:
    7
    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 (Text):
    1. command /tags [<text>] [<text>] [<offlineplayer>]:
    2.     trigger:
    3.         if arg-1 is "remove":
    4.             if player has permission "tags.admin":
    5.                 remove arg-2 from {tags::%arg-3%::*}
    6.                 send "&aYou removed the tag %arg-2%&a from %arg-3%&a's tags!"
    7.                 set {tag::on::%arg-3%} to "&8[&aNone&8]"
    8.         if arg-1 is "add":
    9.             if player has permission "tags.admin":
    10.                 add arg-2 to {tags::%arg-3%::*}
    11.                 set {HCOL::%arg-3%::%arg 2%} to colored arg-2
    12.                 send "&aYou added the tag %colored arg-2%&a to %arg-3%&a's tags!"
    13.         if arg-1 isn't set:
    14.             tags(player)
    Open tags menu:

    Code (Text):
    1. function tags(P: player):
    2.     open chest inventory with 6 rows named "&d&ltags" to {_P}
    3.     if {tag::on::%{_P}%} isn't set:
    4.         set {tag::on::%{_P}%} to "&8[&aNone&8]"
    5.     set {_var} to 44
    6.     loop 9 times:
    7.         add 1 to {_var}
    8.         set slot {_var} of {_P}'s current inventory to black stained glass pane named ""
    9.     set slot 40 of {_P}'s current inventory to barrier named "&c&lClose Menu"
    10.     set slot 38 of {_P}'s current inventory to tnt named "&cRemove tag!"
    11.     if size of {tags::%{_P}%::*} is bigger than 0:
    12.         set {_tags} to 0
    13.         loop {tags::%{_P}%::*}:
    14.             set {tags} to loop-value
    15.             set slot {_tags} of {_P}'s current inventory to name tag named "&8[%{HCOL::%{_P}%::%{tags}%}%&8]"
    16.             add 1 to {_tags}
    17.     while name of {_P}'s current inventory contains "&d&ltags":
    18.         set slot 36 of {_P}'s current inventory to diamond named "&bCurrent tag: %{tag::on::%{_P}%}%"
    19.         wait 1 seconds
    Code to get a tag from the GUI that wont work:

    Code (Text):
    1. on inventory click:
    2.     if name of player's current inventory contains "    &b❆&b&lChristmas Event&b❆":
    3.         cancel event
    4.         if index of event-slot is 13:
    5.             buytags(player)
    6. function buytags(P: player):
    7.     open chest inventory with 4 rows named "           &b❆&bBuy Tags&b❆" to {_P}
    8.     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"
    9.     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"
    10.     set slot 31 of {_P}'s current inventory to barrier named "&c&lMain Page"
    11.     set slot 10 of {_P}'s current inventory to name tag named "&aJolly" with lore "&8- &bCost: &ax100 Event Tokens"
    12.     set slot 11 of {_P}'s current inventory to name tag named "&8[&7Coal&8] &aTag" with lore "&8- &bCost: &ax150 Event Tokens"
    13.     set slot 12 of {_P}'s current inventory to name tag named "&8[&2Elf&8] &aTag" with lore "&8- &bCost: &ax200 Event Tokens"
    14.     set slot 13 of {_P}'s current inventory to name tag named "&8[&bMrs.Clause&8] &aTag" with lore "&8- &bCost: &ax250 Event Tokens"
    15.     set slot 14 of {_P}'s current inventory to name tag named "&8[&bSanta&8] &aTag" with lore "&8- &bCost: &ax250 Event Tokens"
    16.     set slot 15 of {_P}'s current inventory to name tag named "&8[&fSnowman&8] &aTag" with lore "&8- &bCost: &ax50 Event Tokens"
    17.     set slot 16 of {_P}'s current inventory to name tag named "&8[&c2020&8] &aTag" with lore "&8- &bCost: &ax2020 Event Tokens"
    18.     set slot 19 of {_P}'s current inventory to name tag named "&8[&cNaughty&8] &aTag" with lore "&8- &bCost: &ax5000 Event Tokens"
    19.     set slot 20 of {_P}'s current inventory to name tag named "&8[&bNice&8] &aTag" with lore "&8- &bCost: &ax5000 Event Tokens"
    20. on inventory click:
    21.     if name of player's current inventory contains "&bBuy Tags":
    22.         cancel event
    23.         if index of event-slot is 31:
    24.             christmas(player)
    25.         if index of event-slot is 10:
    26.             if {christmas::money::%player's uuid%} >= 100:
    27.                 remove 100 from {christmas::money::%player's uuid%}
    28.                 send "&aYou bought the &8[&aJolly&8] &atag!"
    29.                 add colored {HCOL::%player%::%colored name of event-slot%} to {tags::%player%::*}
    30.             else:
    31.                 close player's inventory
    32.                 send "&cYou dont have enough event tokens!"
     
    • Like Like x 1
  2. Ankoki

    Moderator Supporter Addon Developer

    Joined:
    Nov 5, 2020
    Messages:
    55
    Likes Received:
    12
    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 (Text):
    1. #making the inventory example
    2. set metadata tag "buyTags" of player to chest inventory with 3 rows named "&bBuy Tags"
    3. set slot 0 of metadata tag "buyTags" of player to stone named "test"
    4. open (metadata tag "buyTags" of player) to player
    5. #example of checking the inventory clicking
    6. on inventory click:
    7.     if player's current inventory != (metadata tag "buyTags" of player):
    8.         stop
    9.     cancel event
    10.     if index of event-slot = 0:
    11.         send "you have clicked our test stone!"
     
Thread Status:
Not open for further replies.

Share This Page

Loading...