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.

Pass player entity via function and open chest

Discussion in 'Skript' started by FoxyNatha, May 19, 2022.

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

    FoxyNatha Member

    Joined:
    May 19, 2022
    Messages:
    2
    Likes Received:
    0
    Hello..
    How to pass `player` entity via function and called under `open chest`?

    This works fine:
    ```
    command /testButton:
    trigger:
    foo(player)

    function foo(player: player):
    send "FOO" to {_player}
    bar({_player})

    function bar(player: player):
    send "BAR" to {_player}
    baz({_player})

    function baz(player: player):
    send "BAZ" to {_player}
    ```
    Result:
    FOO
    BAR
    BAZ

    But this won't work:
    ```
    command /testButton:
    trigger:
    foo(player)

    function foo(player: player):
    send "FOO" to {_player}
    bar({_player})

    function bar(player: player):
    send "BAR" to {_player}
    open chest with 1 rows named "&cTESTER" to {_player}
    wait 1 ticks
    format slot 5 of {_player} with blaze powder of unbreaking 10 named "&4&lTest Button" to close then run [baz({_player})]

    function baz(player: player):
    send "BAZ" to {_player}
    ```
    Result:
    FOO
    BAR

    and it doesn't execute the `baz` function

    Add-ons:
    > SkRayFal
    > SkQuery
    > Skellet
     
  2. Mich

    Mich Active Member

    Joined:
    Jul 15, 2020
    Messages:
    148
    Likes Received:
    5
    Code (Text):
    1. command /testButton:
    2. trigger:
    3.     foo(player)
    4.  
    5. function foo(player: player):
    6.     send "FOO" to {_player}
    7.     set metadata tag "Tester" of {_player} to chest inventory with 3 rows named "&cTESTER"
    8.     set slot 5 of metadata tag "Tester" of {_{_player}} to blaze powder of umbreaking 10 named "&4&lTest Button"
    9.     open (metadata tag "Tester" of {_player}) to {_player}
    10.  
    11. function baz(player: player):
    12.     send "BAZ" to {_player}
    13.  
    14. on inventory click:
    15.     if event-inventory = (metadata tag "Tester" of player):
    16.         cancel event
    17.         if index of event-slot is 5:
    18.             baz(player)
     
  3. FoxyNatha

    FoxyNatha Member

    Joined:
    May 19, 2022
    Messages:
    2
    Likes Received:
    0
    Hello, thank you for the reply

    The function foo is working as intended, but the on inventory click is not working at all
    I tried to debug it with:
    Code (Text):
    1. send "%event-inventory%" to player
    but it displays "Inventory of <none>"
    --- Double Post Merged, May 20, 2022, Original Post Date: May 20, 2022 ---
    I fixed it temporarily using this
    Code (Text):
    1. if name of event-inventory is "&cTESTER":
    and the rest of the Skript went well :emoji_laughing:
     
  4. Mich

    Mich Active Member

    Joined:
    Jul 15, 2020
    Messages:
    148
    Likes Received:
    5
    Use vanilla GUI (just skript GUI) with metadata tags there is a tutorial. Just go to tutorials
     
Thread Status:
Not open for further replies.

Share This Page

Loading...