#when i rightclick on a npc it does NOTHING?!

1 messages · Page 1 of 1 (latest)

echo sonnet
#
on right click on entity:
    if event-entity's name = "&7ʀɪɢʜᴛ-ᴄʟɪᴄᴋ &8| &7/ᴄᴏᴍᴍᴀɴᴅѕ":
        commands(event-player)
        broadcast "a"```
#

alright so fuck

#

i made a recording showing the problem

#

but im still embed muted

#

i'll try to explain, i used /npc rename &7ʀɪɢʜᴛ-ᴄʟɪᴄᴋ &8| &7/ᴄᴏᴍᴍᴀɴᴅѕ with citizens to set it's name to this, and when you right click this npc it would run a function. problem: it doesn't do anything. it does not broadcast a at all.

lost ridge
#

so uh event-entity might be the player. try clicked entity or player's target entity

echo sonnet
#

that's weird

#

this used to work

#

oh btw it should be display name instead of name, i did that on accident

on right click on entity:
    if event-entity's display name = "&7ʀɪɢʜᴛ-ᴄʟɪᴄᴋ &8| &7/ᴄᴏᴍᴍᴀɴᴅѕ":
        commands(event-player)
        broadcast "a"```
lost ridge
#

hmm are you sure the if statement is passing?

echo sonnet
#

it's not

#

do you want me to dm you the video btw? might clear some things up idk

lost ridge
echo sonnet
#

already did that

#
on right click on entity:
    broadcast "a"
    if player's target entity's display name = "&7ʀɪɢʜᴛ-ᴄʟɪᴄᴋ &8| &7/ᴄᴏᴍᴍᴀɴᴅѕ":
        commands(event-player)
        broadcast "b"```
it broadcasts a, but not b
lost ridge
#

so then broadcast the name and check

echo sonnet
#

ah smart

lost ridge
#

broadcast raw (X's name)

echo sonnet
#

i tried this but it sent <none>

set {_a} to target entity's displayname
broadcast "%{_a}%"```
echo sonnet
lost ridge
#

raw just means it wont format the string

#

like itll show &7some stuff not some stuff in grey

echo sonnet
#

i know what it does, just not how to use it in code

lost ridge
#

so broadcast the name and make sure its the one you check in the code

echo sonnet
#

because that sent <none> and i don't know why

lost ridge
#

try just name of player's target entity

echo sonnet
#

it sends CIT-314bdbf8b7a73

#

updated code btw:

on right click on entity:
    broadcast "a"
    set {_a} to name of player's target entity
    broadcast "%{_a}%"
    if player's target entity's display name = {_a}:
        commands(event-player)
        broadcast "b"```
#

i tried displayname of player's target entity but that gave <none> again

dry hatch
#

maybe check the entity's nbt, then get the name that way (will require SkBee)

green verge
#

i would recommand adding a command within citizens to trigger a function

clever surge
# echo sonnet updated code btw: ```vb on right click on entity: broadcast "a" set {_a}...

This doesn't work because the displayname of the entity is stored in the CustomName tag, and its stored as nbt which means it needs to be de-serialized into a text component. If I remember tomorrow I might be able to write you up a function that can do it.

There's currently some functionality that can turn a text component INTO one of these serialized json strings, but nothing that can convert a serialized json string BACK into a normal text component: https://skripthub.net/docs/?id=11376

echo sonnet
#

i'm confused, when i used this a few months ago this would've worked?

echo sonnet
clever surge
#

maybe it worked before but they updated something that caused it to bug out

echo sonnet
#

okay

#

could you help me with creating that function then?

clever surge
#

Yeah when I get an hour or so

echo sonnet
livid hatch
#

why not just make the npc run a command through citizens

echo sonnet
#

smart

#

although idk how

#

(yet)