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.

Detecting a gui slot

Discussion in 'Skript' started by Yodexx, Jun 13, 2020.

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

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    By the way, I did check forums but it didn't really help me...
    So what I'm trying to do is make a gui that detects if a certain item is in the empty slot and will put a "spell" on it, but for some reason it keeps popping up this error! (at the bottom)
    This is my code:

    Code (Text):
    1. command /mpsf:
    2.     permission: minepvp.spellforge
    3.     permission message: &cYou are not in the right lobby/game to do this!
    4.     trigger:
    5.         wait 1 tick
    6.         open chest with 3 rows named "&c&lSpell Forge" to player
    7.         wait 1 tick      
    8.  
    9.         format slot 0 of player with gray stained glass pane named "&a" to close
    10.         format slot 1 of player with gray stained glass pane named "&a" to close
    11.         format slot 2 of player with gray stained glass pane named "&a" to close
    12.         format slot 3 of player with gray stained glass pane named "&a" to close
    13.         format slot 4 of player with gray stained glass pane named "&a" to close
    14.         format slot 5 of player with gray stained glass pane named "&a" to close
    15.         format slot 6 of player with gray stained glass pane named "&a" to close
    16.         format slot 7 of player with gray stained glass pane named "&a" to close
    17.         format slot 8 of player with gray stained glass pane named "&a" to close
    18.         format slot 9 of player with gray stained glass pane named "&a" to close
    19.         format slot 10 of player with gray stained glass pane named "&a" to close
    20.         format slot 11 of player with gray stained glass pane named "&a" to close
    21.         format slot 12 of player with gray stained glass pane named "&a" to close
    22.         format slot 14 of player with gray stained glass pane named "&a" to close
    23.         format slot 15 of player with gray stained glass pane named "&a" to close
    24.         format slot 16 of player with gray stained glass pane named "&a" to close
    25.         format slot 17 of player with gray stained glass pane named "&a" to close
    26.         format slot 18 of player with gray stained glass pane named "&a" to close
    27.         format slot 19 of player with gray stained glass pane named "&a" to close
    28.         format slot 20 of player with gray stained glass pane named "&a" to close
    29.         format slot 21 of player with gray stained glass pane named "&a" to close
    30.         format slot 23 of player with gray stained glass pane named "&a" to close
    31.         format slot 22 of player with redstone block named "&3&lCombine" to close
    32.         format slot 24 of player with gray stained glass pane named "&a" to close
    33.         format slot 25 of player with gray stained glass pane named "&a" to close
    34.         format slot 26 of player with gray stained glass pane named "&a" to close
    35.         on inventory click:
    36.             if inventory name of player's current inventory is "&c&lSpell Forge":
    37.                 if clicked slot is 13:
    38.                     set {_spellforgeitem} to player's cursor
    39.                     if lore of {_spellforgeitem} is "&fsup":
    40.                         send "%{_spellforgeitem}%"
    41.                         if name of {_spellforgeitem} is "&fTorch":
    42.                             send "%{_spellforgeitem}%"
    43.  
    And when I reload the script it sends out this error:

    Code (Text):
    1. Line 35: Can't understand this condition: 'on inventory click' (script.sk, line 35: on inventory click:')
    How can I fix this?
     
  2. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    Correcty way
    Code (Text):
    1. command /mpsf:
    2.     permission: minepvp.spellforge
    3.     permission message: &cYou are not in the right lobby/game to do this!
    4.     trigger:
    5.         wait 1 tick
    6.         open chest with 3 rows named "&c&lSpell Forge" to player
    7.         wait 1 tick    
    8.  
    9.         format slot 0 of player with gray stained glass pane named "&a" to close
    10.         format slot 1 of player with gray stained glass pane named "&a" to close
    11.         format slot 2 of player with gray stained glass pane named "&a" to close
    12.         format slot 3 of player with gray stained glass pane named "&a" to close
    13.         format slot 4 of player with gray stained glass pane named "&a" to close
    14.         format slot 5 of player with gray stained glass pane named "&a" to close
    15.         format slot 6 of player with gray stained glass pane named "&a" to close
    16.         format slot 7 of player with gray stained glass pane named "&a" to close
    17.         format slot 8 of player with gray stained glass pane named "&a" to close
    18.         format slot 9 of player with gray stained glass pane named "&a" to close
    19.         format slot 10 of player with gray stained glass pane named "&a" to close
    20.         format slot 11 of player with gray stained glass pane named "&a" to close
    21.         format slot 12 of player with gray stained glass pane named "&a" to close
    22.         format slot 14 of player with gray stained glass pane named "&a" to close
    23.         format slot 15 of player with gray stained glass pane named "&a" to close
    24.         format slot 16 of player with gray stained glass pane named "&a" to close
    25.         format slot 17 of player with gray stained glass pane named "&a" to close
    26.         format slot 18 of player with gray stained glass pane named "&a" to close
    27.         format slot 19 of player with gray stained glass pane named "&a" to close
    28.         format slot 20 of player with gray stained glass pane named "&a" to close
    29.         format slot 21 of player with gray stained glass pane named "&a" to close
    30.         format slot 23 of player with gray stained glass pane named "&a" to close
    31.         format slot 22 of player with redstone block named "&3&lCombine" to close
    32.         format slot 24 of player with gray stained glass pane named "&a" to close
    33.         format slot 25 of player with gray stained glass pane named "&a" to close
    34.         format slot 26 of player with gray stained glass pane named "&a" to close
    35. on inventory click:
    36.     if inventory name of player's current inventory is "&c&lSpell Forge":
    37.         if clicked slot is 13:
    38.             set {_spellforgeitem} to player's cursor
    39.             if lore of {_spellforgeitem} is "&fsup":
    40.                 send "%{_spellforgeitem}%"
    41.                 if name of {_spellforgeitem} is "&fTorch":
    42.                     send "%{_spellforgeitem}%"
     
    • Informative Informative x 1
  3. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    That did solve the error part (which thank you!), but for some reason the inventory click ain't working...
     
  4. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    you're using ''format slot'' from skquery that doesnt works correctly, also you're using ''to close'' at the end so inventory clicks actions doesnt works, change it to ''to be unstealable'' or a better way is using vanilla format slot

    Code (Text):
    1. set slot <int> of <target>'s current inventory to [amount] <item> [named %text%] [with lore %texts%]
    Code (Text):
    1. set slot 23 of player's current inventory to gray stained glass pane named "&a"
    2. set slot 22 of player's current inventory to redstone block named "&3&lCombine"
    3. set slot 24 of player's current inventory to gray stained glass pane named "&a"
     
    • Useful Useful x 1
  5. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    but how do I make it so that when an item is clicked it runs a command? is it the same as format slot just with set slot? (e.g set slot <id> of player's current inventory to gray stained glass pane named "&a" to close then run [execute player command "COMMAND HERE"])
     
  6. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    no, vanilla gui works with inventory clicks
    Code (Text):
    1.  
    2. on inventory click:
    3.    if inventory name....
    4.       cancel event # if u wanna make the item unstealable
    5.       #do stuff
    I recommend u to use Vanilla guis cuz its way better (confirmed) than SkQuery. You dont even need to use ''wait...'' in vanilla guis
     
    • Informative Informative x 1
  7. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    well I mean well you hit like the redstone block (which would trigger a command, but that's still very helpful, thx)
    --- Double Post Merged, Jun 13, 2020, Original Post Date: Jun 13, 2020 ---
    Wait okay so would this work?

    Code (Text):
    1. command /mpsf:
    2.     permission: minepvp.spellforge
    3.     permission message: &cYou are not in the right lobby/game to do this!
    4.     trigger:
    5.         wait 1 tick
    6.         open chest with 3 rows named "&c&lSpell Forge" to player
    7.         wait 1 tick      
    8.  
    9.         set slot 0 of player's current inventory to gray stained glass pane named "&a"
    10.         set slot 1 of player's current inventory to gray stained glass pane named "&a"
    11.         set slot 2 of player's current inventory to gray stained glass pane named "&a"
    12.         set slot 3 of player's current inventory to gray stained glass pane named "&a"
    13.         set slot 4 of player's current inventory to gray stained glass pane named "&a"
    14.         set slot 5 of player's current inventory to gray stained glass pane named "&a"
    15.         set slot 6 of player's current inventory to gray stained glass pane named "&a"
    16.         set slot 7 of player's current inventory to gray stained glass pane named "&a"
    17.         set slot 8 of player's current inventory to gray stained glass pane named "&a"
    18.         set slot 9 of player's current inventory to gray stained glass pane named "&a"
    19.         set slot 10 of player's current inventory to gray stained glass pane named "&a"
    20.         set slot 11 of player's current inventory to gray stained glass pane named "&a"
    21.         set slot 12 of player's current inventory to gray stained glass pane named "&a"
    22.         set slot 13 of player's current inventory to gray stained glass pane named "&a"
    23.         set slot 14 of player's current inventory to gray stained glass pane named "&a"
    24.         set slot 15 of player's current inventory to gray stained glass pane named "&a"
    25.         set slot 16 of player's current inventory to gray stained glass pane named "&a"
    26.         set slot 17 of player's current inventory to gray stained glass pane named "&a"
    27.         set slot 18 of player's current inventory to gray stained glass pane named "&a"
    28.         set slot 19 of player's current inventory to gray stained glass pane named "&a"
    29.         set slot 20 of player's current inventory to gray stained glass pane named "&a"
    30.         set slot 21 of player's current inventory to gray stained glass pane named "&a"
    31.         set slot 22 of player's current inventory to redstone block named "&3&lCombine"
    32.         set slot 23 of player's current inventory to gray stained glass pane named "&a"
    33.         set slot 24 of player's current inventory to gray stained glass pane named "&a"
    34.         set slot 25 of player's current inventory to gray stained glass pane named "&a"
    35. on inventory click:
    36.     if inventory name of player's current inventory is "&c&lSpell Forge":
    37.         cancel event
    38.         if clicked slot is 13:
    39.             set {_spellforgeitem} to player's cursor
    40.             if lore of {_spellforgeitem} is "&fsup":
    41.                 send "%{_spellforgeitem}%"
    42.                 if name of {_spellforgeitem} is "&fTorch":
    43.                     send "%{_spellforgeitem}%"
    Cause I feel like it wouldn't... :emoji_frowning:
     
  8. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    ye but dont use ''if lore...'' because detecting lore always results in error, doesnt works correctly, just use:
    Code (Text):
    1. if name of is/contains, if clicked item/slot, if etc is/contains
     
  9. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    so delete the "if lore"? or just replace with something?
     
  10. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    don't use ''lore'' to detecting items, just the name of clicked item
    dont use player's cursor, too, i think doesnt work propertly

    i changed these values and it works

    Code (Text):
    1. set {_spellforgeitem} to clicked item # (instead of player's cursor)
    2.  
    3. if {_spellforgeitem} = "&fTorch": #instead of ''name of bla bla''
    4.     send "%{_spellforgeitem}%"
     
  11. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    So this is what I've got: (for inventory click)
    Code (Text):
    1. on inventory click:
    2.     if inventory name of player's current inventory is "&c&lSpell Forge":
    3.         cancel event
    4.         if clicked slot is 13:
    5.             set {_spellforgeitem} to clicked item # (instead of player's cursor)
    6.             if {_spellforgeitem} = "&fTorch"
    7.             send "%{_spellforgeitem}%"
    but this came up:
    Code (Text):
    1. Line 40: Can't compare 'if {_spellforgeitem}' with a text (script.sk, line 40: if {_spellforgeitem} = "&fTorch"')
     
  12. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    Wrong usage, u forget '':'' and tab (4 spaces)

    Code (Text):
    1. if {_spellforgeitem} = "&fTorch":
    2.     send "%{_spellforgeitem}%"
     
  13. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    so is this script suppost to message out the item name? because if so, its not working... :I
    --- Double Post Merged, Jun 13, 2020, Original Post Date: Jun 13, 2020 ---
    if you'd like to check my code here it is:
    Code (Text):
    1. command /mpsf:
    2.     permission: minepvp.spellforge
    3.     permission message: &cYou are not in the right lobby/game to do this!
    4.     trigger:
    5.         wait 1 tick
    6.         open chest with 3 rows named "&c&lSpell Forge" to player
    7.         wait 1 tick      
    8.  
    9.         set slot 0 of player's current inventory to gray stained glass pane named "&a"
    10.         set slot 1 of player's current inventory to gray stained glass pane named "&a"
    11.         set slot 2 of player's current inventory to gray stained glass pane named "&a"
    12.         set slot 3 of player's current inventory to gray stained glass pane named "&a"
    13.         set slot 4 of player's current inventory to gray stained glass pane named "&a"
    14.         set slot 5 of player's current inventory to gray stained glass pane named "&a"
    15.         set slot 6 of player's current inventory to gray stained glass pane named "&a"
    16.         set slot 7 of player's current inventory to gray stained glass pane named "&a"
    17.         set slot 8 of player's current inventory to gray stained glass pane named "&a"
    18.         set slot 9 of player's current inventory to gray stained glass pane named "&a"
    19.         set slot 10 of player's current inventory to gray stained glass pane named "&a"
    20.         set slot 11 of player's current inventory to gray stained glass pane named "&a"
    21.         set slot 12 of player's current inventory to gray stained glass pane named "&a"
    22.         set slot 14 of player's current inventory to gray stained glass pane named "&a"
    23.         set slot 15 of player's current inventory to gray stained glass pane named "&a"
    24.         set slot 16 of player's current inventory to gray stained glass pane named "&a"
    25.         set slot 17 of player's current inventory to gray stained glass pane named "&a"
    26.         set slot 18 of player's current inventory to gray stained glass pane named "&a"
    27.         set slot 19 of player's current inventory to gray stained glass pane named "&a"
    28.         set slot 20 of player's current inventory to gray stained glass pane named "&a"
    29.         set slot 21 of player's current inventory to gray stained glass pane named "&a"
    30.         set slot 22 of player's current inventory to redstone block named "&3&lCombine"
    31.         set slot 23 of player's current inventory to gray stained glass pane named "&a"
    32.         set slot 24 of player's current inventory to gray stained glass pane named "&a"
    33.         set slot 25 of player's current inventory to gray stained glass pane named "&a"
    34.         set slot 26 of player's current inventory to gray stained glass pane named "&a"
    35. on inventory click:
    36.     if inventory name of player's current inventory is "&c&lSpell Forge":
    37.         cancel event
    38.         if clicked slot is 13:
    39.             set {_spellforgeitem} to clicked item # (instead of player's cursor)
    40.             if {_spellforgeitem} = "&fTorch":
    41.                 send "%{_spellforgeitem}%"
     
  14. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    I did an error, i fixed
    example https://gyazo.com/6de2c1aa64c8c1c7590ab5424a617ac7
    Code (Text):
    1. command /x:
    2.     trigger:
    3.         wait 1 tick
    4.         open chest with 2 row named "&c&lSpell forge" to player
    5.         set slot 13 of player's current inventory to torch named "&fTorch"
    6.  
    7. on inventory click:
    8.     if inventory name of player's current inventory is "&c&lSpell Forge":
    9.         cancel event
    10.         if clicked slot is 13:
    11.             set {_spellforgeitem} to name of clicked item
    12.             if {_spellforgeitem} = "&fTorch":
    13.                 send "%{_spellforgeitem}%"
     
  15. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    are u using any other plugins besides Skellet and SkQuery?
     
  16. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    no, im not
     
  17. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    for some reason nothing is working... :I
     
  18. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    wtf, skript version? skquery version? server version? but, is there any error on load or something else?
     
  19. Yodexx

    Yodexx Member

    Joined:
    Jun 13, 2020
    Messages:
    19
    Likes Received:
    0
    Well theres not error on load, the server version is 1.8-1.5 (I'm using 1.15), and I think the latest skript version
    --- Double Post Merged, Jun 13, 2020, Original Post Date: Jun 13, 2020 ---
    It just won't do what its suppost to do... (e.g that video you showed me, I had the exact code and it did nothing... :I)
    --- Double Post Merged, Jun 13, 2020 ---
    I even ran the skript you made... :I still didn't work :emoji_frowning:
     
  20. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    try using skquery-lime by limeglass, its rlly weird tbh
     
Thread Status:
Not open for further replies.

Share This Page

Loading...