Skript Unique search system!

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

loadka95

Active Member
Feb 24, 2017
78
6
8
26
In the past week i was trying to create a nice search system in minecraft and i finally got it!
And because im a very nice guy so, Im sharing the code with you and you can build it into your skript! :emoji_slight_smile:

It's using sign:
Névtelen.png


code_language.skript:
function SignSearch(lines: strings, player: player):
   set {_loc} to location of {_player}
   set {_block} to type of block at {_loc}
   set block at {_loc} to sign
   loop {_lines::*}:
      (loop-index parsed as int) < 5
      set line (loop-index parsed as int) of block at {_loc} to "%colored loop-value%"
   wait a tick
   set {_packet} to new play_server_open_sign_editor packet
   set location pinfo 0 of {_packet} to {_loc}
   send {_player} packet {_packet}
   set block at {_loc} to {_block}

command /signsearch <player>:
    trigger:
        set {usingsign.%player%} to true
        set {_lines::*} to "", "/\/\/\/\", "Enter your" and "search!"
        SignSearch({_lines::*},arg)

on packet event play_client_update_sign:
    if {usingsign.%player%} is true:
        set {_lines::*} to string array pinfo 0 of event-packet
        message "You searched for: %{_lines::1}%"
        set {usingsign.%player%} to false
        stop
How to use it?
  • If you want to search for something use the command /signsearch <player> (you can open the search sign for other people) then enter your search into the first line and click on the DONE button
  • You can get the lines under the on packet event, from {_lines::*}, then do whatever you want with it!

What is it good for?!
If you have lot of players on your server, you can search for peoples easly with this system
code_language.skript:
        loop all players:
            if loop-player's is equal to {_lines::1}:
                message "the player is online"

you can search for things in list variables
code_language.skript:
        loop {yourvariable::*}:
            if loop-value is equal to {_lines::1}:
                message "Yeah I FOUND IT"

Other:

You need to have ProtocolLib in your plugin folder!

Sorry for the mistakes in the text, my english is not that good! :/
 
I made a slight change to make sure that the sign does not break things such as plants:
Code:
function packetSign(lines: strings, player: player):
    loop blocks in radius 4 around location of {_player}:
        if loop-block is air:
            set {_loc} to location of loop-block
            set block at {_loc} to sign
            loop {_lines::*}:
                (loop-index parsed as int) < 5
                set line (loop-index parsed as int) of block at {_loc} to "%colored loop-value-2%"
            wait a tick
            set {_packet} to new play_server_open_sign_editor packet
            set location pinfo 0 of {_packet} to {_loc}
            send {_player} packet {_packet}
            set block at {_loc} to air
            stop
    send "&4&lError: &cCould not place temporary sign" to {_player}

Basically it just finds the nearest air block and uses that location for the sign, instead of the location of the player's feet.