Right click on villager

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

zaved

Member
Sep 19, 2022
17
0
1
23
hey,

first of all I want to explain, that I want to have a villager with the name "Kits" and when you rightclick on the villager, it should open an gui where you can buy some kits.

Now I tried something but it stopped me already at the point, of opening a gui. It it just opening the standard villager gui, you have in vanilla

Can somebody help me?

Code:
on right click on villager:
    if display name of clicked entity is "&8» &6&lKits":
        open chest with 3 rows named "&8» &cConfirmation" to player  
        format slot 0 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 1 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 2 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 3 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 4 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 5 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 6 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 7 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 8 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 18 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 19 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 20 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 21 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 22 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 23 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 24 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 25 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 26 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 17 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 8 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 9 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 14 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 18 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 12 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 12 of player with gray stained glass pane named "&8-/-" to be unstealable
 
Before opening chest inventory just add cancel event line. And you should probably loop integers from 0 to 26 and there format loop-value slot instead of repeating same code so many times
 
Code:
on right click on villager:
    if display name of clicked entity is "&8» &6&lKits":
        cancel event

        open chest with 3 rows named "&8» &cConfirmation" to player 
        format slot 0 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 1 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 2 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 3 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 4 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 5 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 6 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 7 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 8 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 9 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 12 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 14 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 18 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 19 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 20 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 21 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 22 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 23 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 24 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 25 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 26 of player with gray stained glass pane named "&8-/-" to be unstealable
        format slot 17 of player with gray stained glass pane named "&8-/-" to be unstealable

You need to cancel the interaction of the villager
Easy fix is
Code:
cancel event
 
Status
Not open for further replies.