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 Click Event Failing in Some Cases

Discussion in 'Skript' started by A248, Jul 16, 2017.

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

    A248 Member

    Joined:
    Jan 31, 2017
    Messages:
    43
    Likes Received:
    3
    Skript and all addons: Skript v2.2-dev23. SkQuery v3.21.4, skRayFall v1.9.7, TuSKe v1.6.7, SharpSK v1.6.0, RandomSK v2.7.1, SkStuff v1.6.2.

    MC Version: 1.8.8.

    Code (Skript):
    1. on leftclick holding mushroom stew:
    2.     if player has permission "arim.soup":
    3.         set {_prot} to spawnProt(player)
    4.         if {_prot} is false:
    5.             sendOwner("&5%name of player% &3–– &anormal soup leftclick.")
    6.             soup(player)
    7.     else:
    8.         set player's action bar to "&cSoups disabled in this world"
    9.  
    10. on rightclick holding mushroom stew:
    11.     if player has permission "arim.soup":
    12.         set {_prot} to spawnProt(player)
    13.         if {_prot} is false:
    14.             sendOwner("&5%name of player% &3–– &anormal soup rightclick.")
    15.             soup(player)
    16.     else:
    17.         set player's action bar to "&cSoups disabled in this world"
    18.  
    19. function soup(p: player):
    20.     clear tool of {_p}
    21.     heal {_p} by 1 hearts
    22.     remove regeneration from {_p}
    23.     apply potion of regeneration of tier 3 to {_p} for 3 seconds
    24.     play orb pickup at {_p} with pitch 1
    Note: The sendOwner function is irrelevant. It works fine. It is simply helpful to debug stuff, which is why I have used it to try to debug this script.

    Errors on reload: None
    Console Errors: None

    Troubleshooting:
    Have tried the docs.
    Have searched the forums. Perhaps I am using the wrong search words?
    I have also tried using "on leftclick on any block:" or "on leftclick on a block:" to replace the leftclick event.


    Full Description of Error:
    If I leftclick (holding soup) normally, looking at the air, everything works fine. Similarly, if I rightclick (holding soup) normally while looking at a block within range, everything still works fine. Soup works in those cases.

    However, when I right click (holding soup) in the air, the soup applies regeneration, healing, sends the sendOwner notification, and plays the sound, though it does not remove the soup.
    Also, when I left click (holding soup) on a block within range, nothing happens. The event does not fire, I believe.
    Note: I tested this in adventure mode. I will need the script to work while players are in adventure mode.

    Code (Skript):
    1. #Entire function works when left clicking in the air OR righ tclicking a block
    2. function soup(p: player): #Entire function does not work when left clicking a block
    3.     clear tool of {_p} #Does not work while right click the air
    4.     heal {_p} by 1 hearts
    5.     remove regeneration from {_p}
    6.     apply potion of regeneration of tier 3 to {_p} for 3 seconds
    7.     play orb pickup at {_p} with pitch 1
    When clicking with soup:
    • Normal leftclick in air: Works fine.
    • Normal rightclick in air: Soup is not removed ('clear tool of {_p}' does not work)
    • Normal leftclick on block: Nothing happens. Event is not fired.
    • Normal rightclick on block: Works fine.
    EDIT: Earlier, I had said that rightclicks in the air worked, while rightclicks on a block failed to clear the item. It is actually the other way around – When you rightclick the air, the soup is not cleared. When you rightclick a block, the soup is cleared. The leftclick event is experiencing the same errors. No edits regarding the leftclick event.
    --- Double Post Merged, Jul 17, 2017, Original Post Date: Jul 16, 2017 ---
    UPDATE

    Creating a new issue at github.com/bensku/Skript/etc.





    SOLUTION

    Rightclicking bug – I have simply removed rightclicking from the script. Soups are left-click only.

    Leftclick bug fix:

    1. I have set the players to survival and disabled block-editing.
    2. I am using 2 events – on leftclick and on block damage.
    on block damage fills the void that on leftclick leaves when players leftclick a block.
     
    #1 A248, Jul 17, 2017
    Last edited: Jul 19, 2017
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234

    I can't particularly give you any useful information because you're running a relatively older server version.

    That being said, I tested your code, and I found it was working fine, other than left clicking blocks while in adventure mode. This is most likely because Skript listens for events. In adventure mode, Minecraft prevents the event from happening, so there's nothing for Skript to hear.

    I am unable to reproduce the error of the soup not being removed when rightclicking in air, though; it's working fine on my end.
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    skript community 2017.
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    ?
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    everyone is potato.com/redirect.js
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    I have merely removed the rightclick event from my script, set the players to survival, and used on block damage in addition to on leftclick.

    Will mark as solved.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...