Solved Right click event on villager not working?

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

CKR367

Member
Feb 1, 2017
64
2
0
I am trying to create a tutorial NPC, and the rightclick on villager event is not working.

Skript Version: Latest Bensku Version
SkQuery : Latest 1.11 Lime Version
SkUtilities: Latest
SkRayFall: Latest
Skellett: Latest

I have found some posts about this issue on Benku's GitHub, but it was apparently already fixed, but it isn't. All help is appreciated.

Spawning NPC Code (without trigger):
code_language.skript:
spawn a villager at location of player
add "{Silent:1,NoAI:1,Invulnerable:1}" to nbt of last spawned entity
set display name of last spawned entity to "&c&lTutorial"
message "&6NPC &8> &7You spawned the tutorial NPC."
stop

RightClick Event Code:
code_language.skript:
on rightclick on villager:
    if display name of clicked entity is "&c&lTutorial":
        cancel event
        message "&6Tutorial &8> &7Tutorial coming soon!"
        stop
 
Last edited:
code_language.skript:
on rightclick on entity:
    "%event-entity%" is "entities.normal.name"
    cancel event
    wait 1 tick
    close inventory of player

You can see the trading menu for a brief moment but it's better than nothing and also I didn't test a villager with a display name.
 
You're spawning it with the name
code_language.skript:
"&c&lTutorial"
put checking if its name is
code_language.skript:
"&a&lTutorial"
 
You're spawning it with the name
code_language.skript:
"&c&lTutorial"
put checking if its name is
code_language.skript:
"&a&lTutorial"
Oops, I fixed that problem right after I copy/pasted my code into this thread. It still does not work with the fixed name. It just comes up with the trade GUI still....
[doublepost=1496070100,1496069788][/doublepost]
code_language.skript:
on rightclick on entity:
    "%event-entity%" is "entities.normal.name"
    cancel event
    wait 1 tick
    close inventory of player

You can see the trading menu for a brief moment but it's better than nothing and also I didn't test a villager with a display name.
https://github.com/bensku/Skript/issues/311. Apparently there was a workaround for using that method, which I already tried. Nothing seems to work....
 
code_language.skript:
on rightclick on entity:
    "%event-entity%" is "entities.normal.name"
    cancel event
    wait 1 tick
    close inventory of player

This closes the gui for me. It doesn't for you?
 
code_language.skript:
on rightclick on entity:
    "%event-entity%" is "entities.normal.name"
    cancel event
    wait 1 tick
    close inventory of player

This closes the gui for me. It doesn't for you?
Hmm.... Well now I am right clicking and nothing happens, not even the trade gui....which I guess is a good thing. I removed the display name to see if that changed anything, which could be the cause for nothing happening.
code_language.skript:
command /npc [<text>]:
    executable by: players
    trigger:
        if network variable {rank.%player%} is "Owner":
            if argument 1 is "1":
                spawn a villager at location of player
                add "{Silent:1,NoAI:1,Invulnerable:1}" to nbt of last spawned entity
                message "&6NPC &8> &7You spawned the tutorial NPC."
                stop

code_language.skript:
on rightclick on entity:
    "%event-entity%" is "entities.normal.name"
    cancel event
    wait 1 tick
    close inventory of player
    broadcast "IT WORKED"
[doublepost=1496071417,1496070868][/doublepost]Changed the code and this seemed to work.....

code_language.skript:
on rightclick on entity:
    "%event-entity%" is "Villager"
    cancel event
    wait 1 tick
    close inventory of player
    broadcast "IT WORKED"

The gui doesn't even show up.
 
Changed the code and this seemed to work.....

code_language.skript:
on rightclick on entity:
    "%event-entity%" is "Villager"
    cancel event
    wait 1 tick
    close inventory of player
    broadcast "IT WORKED"

The gui doesn't even show up.

This doesn't work for me, but if it works for you then great!
 
This doesn't work for me, but if it works for you then great!
Okay, well it only partially worked. Sometimes on server restart/player quit the gui will show up again.

code_language.skript:
on rightclick on entity:
    if "%event-entity%" is "Villager":
        cancel event
        wait 0.1 ticks
        close inventory of player
        if display name of event-entity is "&c&lTutorial":
            broadcast "&6Tutorial &8> &7Tutorial coming soon!"
            stop
 
Status
Not open for further replies.