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.

Trouble making gui, duplicate items.

Discussion in 'Skript' started by Nutrition35, Apr 7, 2021.

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

    Nutrition35 New Member

    Joined:
    Feb 11, 2020
    Messages:
    9
    Likes Received:
    0
    1. Script Version: 2.5.3
    2. Script Author: Nutrition35
    3. Minecraft Version: 1.16.5
    4. Full Code:
    Code (Text):
    1. on right click on enchantment table:
    2.     cancel event
    3.     if player's held item is sword:
    4.         wait 1 tick
    5.         set {Enchitem::%player%} to player's held item
    6.         remove {Enchitem::%player%} from player's inventory
    7.         open virtual chest inventory with size 3 named "&eSword Enchanter" to player  
    8.         fillGUI(player)
    9.         wait 1 tick
    10.         format gui slot 11 of player with {Enchitem::%player%}
    11.         format gui slot 4 of player with book named "&f&l| Daze |" with lore "" and "&7Chance to &fstun &7your &cvictim &7upon Impact!" and "&7&lRequires Level: &a᚛ 0 ᚜ &7to enchant!" and "" and "&f&lCOMMON"
    12.     else:
    13.         message "&cYou must hold either a &c&lSword&c, &c&lPickaxe&c, &cor &c&lArmor &cto do this!"
    14.         play sound "block.note_block.pling" with volume 100 and pitch -2 to event-player
    15. on inventory click:
    16.     if name of event-inventory contains "&eSword Enchanter":
    17.         cancel event
    18.         if index of event-slot is 4:
    19.             cancel event
    20.             open virtual chest inventory with size 3 named "&f&lDaze Books" to player
    21.             fillGUI(player)
    22.             wait 1 tick
    23.             format gui slot 10 of player with {Enchitem::%player%}
    24.             format gui slot 12 of player with book named "&f&lDaze I" with lore "" and "&b5%% &fchance to make your victim hallucinate on attack!" and "&fHallucination lasts &b5 &fseconds!" and "" and "&fCosts &b500 Tokens!"
    25.             format gui slot 14 of player with book named "&f&lDaze II" with lore "" and "&b10%% &fchance to make your victim hallucinate on attack!" and "&fHallucination lasts &b5 &fseconds!" and "" and  "&fCosts &b1000 Tokens!"
    26.             format gui slot 16 of player with book named "&f&lDaze III" with lore "" and "&b15%% &fchance to make your victim hallucinate on attack!" and "&fHallucination lasts &b5 &fseconds!" and "" and "&fCosts &b1500 Tokens!"
    27.             format gui slot 18 of player with red stained glass pane named "&c&lBACK"
    28.     if name of event-inventory contains "&f&lDaze Books":
    29.         cancel event
    30.         if index of event-slot is 12:
    31.             if {tokens::%player%} is greater than or equal to 500:
    32.                 if lore of {Enchitem::%player%} contains "&fDaze I":
    33.                     cancel event
    34.                     message "&cYou already have &fDaze I &con your sword!" to event-player
    35.                     play sound "block.note_block.pling" with volume 100 and pitch -2 to event-player
    36.                 else:
    37.                     subtract 500 from {tokens::%player%}
    38.                     play sound "block.note_block.pling" with volume 100 and pitch 6 to event-player
    39.                     set lore of {Enchitem::%player%} to "&fDaze I"
    40.         if index of event-slot is 18:
    41.             open virtual chest inventory with size 3 named "&eSword Enchanter" to player  
    42.             fillGUI(player)
    43.             wait 1 tick
    44.             format gui slot 11 of player with {Enchitem::%player%}
    45.             format gui slot 4 of player with book named "&f&l| Daze |" with lore "" and "&7Chance to &fstun &7your &cvictim"
    46. on inventory close:
    47.     if name of event-inventory contains "&eSword Enchanter":
    48.         add {Enchitem::%player%} to player's inventory
    49.     if name of event-inventory contains "&f&lDaze Books":
    50.         add {Enchitem::%player%} to player's inventory
    Problem being that when a person clicks on the book to change inventories to select the level of the book they want, it gives them the sword because it thinks the inventory actually closed. How can I prevent this? how can I make it so that it only gives the sword when they fully exit any GUI, or I assume thats my issue.

    Thank you all.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...