Pass player entity via function and open chest

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

FoxyNatha

Member
May 19, 2022
2
0
1
28
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
 
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
Code:
command /testButton:
trigger:
    foo(player)

function foo(player: player):
    send "FOO" to {_player}
    set metadata tag "Tester" of {_player} to chest inventory with 3 rows named "&cTESTER"
    set slot 5 of metadata tag "Tester" of {_{_player}} to blaze powder of umbreaking 10 named "&4&lTest Button"
    open (metadata tag "Tester" of {_player}) to {_player}

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

on inventory click:
    if event-inventory = (metadata tag "Tester" of player):
        cancel event
        if index of event-slot is 5:
            baz(player)
 
Code:
on inventory click:
    if event-inventory = (metadata tag "Tester" of player):
        cancel event
        if index of event-slot is 5:
            baz(player)

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:
send "%event-inventory%" to player
but it displays "Inventory of <none>"
[doublepost=1653006753,1653005460][/doublepost]I fixed it temporarily using this
Code:
if name of event-inventory is "&cTESTER":

and the rest of the Skript went well :emoji_laughing:
 
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:
send "%event-inventory%" to player
but it displays "Inventory of <none>"
[doublepost=1653006753,1653005460][/doublepost]I fixed it temporarily using this
Code:
if name of event-inventory is "&cTESTER":

and the rest of the Skript went well :emoji_laughing:
Use vanilla GUI (just skript GUI) with metadata tags there is a tutorial. Just go to tutorials
 
Status
Not open for further replies.