1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Skript On Tab Completer

Discussion in 'Tutorials' started by Slaim36, Jul 24, 2020.

  1. Slaim36

    Slaim36 Member

    Joined:
    Apr 9, 2020
    Messages:
    5
    Likes Received:
    1
    Tab completer is the command's argument completer, in a manner of speaking, obviously.
    Here is an example:
    [​IMG]

    In this case we can complete the /gamemode arguments using the TAB key
    [​IMG]

    To use the tab completer in skript, we need a script with our command, this is the mine:
    Code (Text):
    1. command /gm <gamemode>:
    2.     trigger:
    3.         set player's gamemode to arg-1
    4.         send "&aChanged your gamemode to %arg-1%"
    Now, we need to create another script, with any name, it doesn't matter. Now, in the script we need to write the tab completer, this is the mine:
    Code (Text):
    1. on tab completer for "/gm":
    2. #In this line we need to put the command.
    3.     set {_completers::*} to "adventure", "creative", "spectator" and "survival"
    4.     #In this line we need to put the arguments to complete.
    5.     loop {_completers::*}:
    6.         add loop-value to completions
    For this to work, first you have to reload / enable the command script and then the completion script.
    Now, our command has the tab completions.
    [​IMG]
    Here more examples:
    Command script:
    Code (Text):
    1. command /sethome <string>:
    2.     trigger:
    3.         if {homes::%player%::*} is set:
    4.             set {home::%player%::%arg-1%} to player's position
    5.             add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
    6.             send "&aYour house %arg-1% was set"
    7.         else:
    8.             set {home::%player%::%arg-1%} to player's position
    9.             set {homes::%player%::*} to "%arg-1%"
    10.             send "&aYour house %arg-1% was set"
    11.        
    12. command /home <string>:
    13.     trigger:
    14.         if {home::%player%::%arg-1%} is set:
    15.             teleport player to {home::%player%::%arg-1%}
    16.             send "&aYou was teleported to %arg-1%"
    17.         else:
    18.             send "&4Invalid house name"
    19.            
    20. command /homes:
    21.     trigger:
    22.         send "&aYour houses: %{homes::%player%::*}%" to player
    23.        
    24. command /delhome <string>:
    25.     trigger:
    26.         if {home::%player%::%arg-1%} is set:
    27.             delete {home::%player%::%arg-1%}
    28.             remove "%arg-1%" from {homes::%player%::*}
    29.             send "&aYour house was deleted"
    30.         else:
    31.             send "&4Invalid house name"
    Completer script:
    Code (Text):
    1. on tab completer for "/home":
    2.     set {_completers::*} to {homes::%player%::*} #We can use variables
    3.     loop {_completers::*}:
    4.         add loop-value to completions
    Screenshot:
    [​IMG]
     
    • Like Like x 1
Loading...