Opening a sign to a player.

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

Flasser

New Member
Oct 19, 2021
7
0
1
19
Hi, I am currently working on a script where I would like for the player to have a sign opened to them.

The sign would look like if you had just placed it and were editing the sign.
Then when the play closed the sign edit thing, the server would execute a command written on the 1st line, the 3 other lines would have text which won't be used to do anything, tho when the player opens the sign thing, the text from line 2, 3 and 4 would already have been set.

Code:
command /test:
    trigger:
        set {_sign} to sign
        set 2nd line og {_sign} to "Test line 2"
        set 3rd line og {_sign} to "Test line 3"
        set 4th line og {_sign} to "Test line 4"
        open {_sign} to player

On sign close:
    If 2nd line = "Test line 2":
        send "%1st line%" to player

That is how i want it to work, (I know that code doesn't work in any way, but it's a demonstration)
 
Hi, I am currently working on a script where I would like for the player to have a sign opened to them.

The sign would look like if you had just placed it and were editing the sign.
Then when the play closed the sign edit thing, the server would execute a command written on the 1st line, the 3 other lines would have text which won't be used to do anything, tho when the player opens the sign thing, the text from line 2, 3 and 4 would already have been set.

Code:
command /test:
    trigger:
        set {_sign} to sign
        set 2nd line og {_sign} to "Test line 2"
        set 3rd line og {_sign} to "Test line 3"
        set 4th line og {_sign} to "Test line 4"
        open {_sign} to player

On sign close:
    If 2nd line = "Test line 2":
        send "%1st line%" to player

That is how i want it to work, (I know that code doesn't work in any way, but it's a demonstration)

https://skripthub.net/docs/?id=4361

Check the docs next time
 
Hi, I am currently working on a script where I would like for the player to have a sign opened to them.

The sign would look like if you had just placed it and were editing the sign.
Then when the play closed the sign edit thing, the server would execute a command written on the 1st line, the 3 other lines would have text which won't be used to do anything, tho when the player opens the sign thing, the text from line 2, 3 and 4 would already have been set.

Code:
command /test:
    trigger:
        set {_sign} to sign
        set 2nd line og {_sign} to "Test line 2"
        set 3rd line og {_sign} to "Test line 3"
        set 4th line og {_sign} to "Test line 4"
        open {_sign} to player

On sign close:
    If 2nd line = "Test line 2":
        send "%1st line%" to player

That is how i want it to work, (I know that code doesn't work in any way, but it's a demonstration)
You'd need packets for that
 
Oh ok, but how do I do that then?
Mr.Gigi has made a snippet for that, here
Code:
event "signGUIDone":
    patterns:
        sign (gui|menu) (done|close|finish)
        close of sign (gui|menu)
    event-values: player, location
expression line(-| )%number% [of sign [(gui|menu)]]:
    return type: string
    usable in:
        custom event "signGUIDone"
    get:
        return event.getData("%expr-1%")
effect:
    patterns:
        open [a] [new] (sign|%-itemtype%) [(gui|menu)] to %players% [with [(text|lines)] %-strings%]
        open [a] [new] (sign|%-itemtype%) [(gui|menu)] [with [(text|lines)] %-strings%] to %players%
    trigger:
        set {_openSignEditorPacket} to new play_server_open_sign_editor packet
        set {_signType} to expr-1 ? oak sign
        set {_viewers::*} to exprs-2 if pattern is 1, else exprs-3
        set {_lines::*} to exprs-3 if pattern is 1, else exprs-2
        set {_lines} to ["", "", "", ""]
        loop 4 times:
            set {_lines}[loop-value - 1] to {_lines::%loop-value%}
        loop {_viewers::*}:
            set {_location} to location behind loop-value
            set {_signs::%loop-index%} to {_location}
            make loop-value see block at {_location} as {_signType}
            loop-value.sendSignChange({_location}, {_lines})
        wait a tick
        loop {_signs::*}:
            set location field 0 of {_openSignEditorPacket} to loop-value
            send packet {_openSignEditorPacket} to {_viewers::%loop-index%}
on packet event play_client_update_sign:
    set {_location} to location field 0 of event-packet
    block at {_location} is not a sign
    set {_values::player} to player
    set {_values::location} to location
    loop string array field 0 of event-packet:
        add 1 to {_index}
        set {_lines::%{_index}%} to loop-value
    make player see block at {_location} as block at {_location}
    call custom event "signGUIDone" with {_values::*} and data {_lines::*}
 
Status
Not open for further replies.