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

Nutrition35

Member
Feb 11, 2020
11
0
1
19
  1. Script Version: 2.5.3
  2. Script Author: Nutrition35
  3. Minecraft Version: 1.16.5
  4. Full Code:
Code:
on right click on enchantment table:
    cancel event
    if player's held item is sword:
        wait 1 tick
        set {Enchitem::%player%} to player's held item
        remove {Enchitem::%player%} from player's inventory
        open virtual chest inventory with size 3 named "&eSword Enchanter" to player   
        fillGUI(player)
        wait 1 tick
        format gui slot 11 of player with {Enchitem::%player%}
        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"
    else:
        message "&cYou must hold either a &c&lSword&c, &c&lPickaxe&c, &cor &c&lArmor &cto do this!"
        play sound "block.note_block.pling" with volume 100 and pitch -2 to event-player
on inventory click:
    if name of event-inventory contains "&eSword Enchanter":
        cancel event
        if index of event-slot is 4:
            cancel event
            open virtual chest inventory with size 3 named "&f&lDaze Books" to player 
            fillGUI(player)
            wait 1 tick
            format gui slot 10 of player with {Enchitem::%player%}
            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!"
            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!"
            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!"
            format gui slot 18 of player with red stained glass pane named "&c&lBACK"
    if name of event-inventory contains "&f&lDaze Books":
        cancel event
        if index of event-slot is 12:
            if {tokens::%player%} is greater than or equal to 500:
                if lore of {Enchitem::%player%} contains "&fDaze I":
                    cancel event
                    message "&cYou already have &fDaze I &con your sword!" to event-player
                    play sound "block.note_block.pling" with volume 100 and pitch -2 to event-player
                else:
                    subtract 500 from {tokens::%player%}
                    play sound "block.note_block.pling" with volume 100 and pitch 6 to event-player
                    set lore of {Enchitem::%player%} to "&fDaze I"
        if index of event-slot is 18:
            open virtual chest inventory with size 3 named "&eSword Enchanter" to player   
            fillGUI(player)
            wait 1 tick
            format gui slot 11 of player with {Enchitem::%player%}
            format gui slot 4 of player with book named "&f&l| Daze |" with lore "" and "&7Chance to &fstun &7your &cvictim"
on inventory close:
    if name of event-inventory contains "&eSword Enchanter":
        add {Enchitem::%player%} to player's inventory
    if name of event-inventory contains "&f&lDaze Books":
        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.
 
Status
Not open for further replies.