On Tab Completer
Tab completer is the command's argument completer, in a manner of speaking, obviously.
In this case we can complete the /gamemode arguments using the TAB key
To use the tab completer in skript, we need a script with our command, this is the mine:
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:
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.
Here more examples:
Here is an example:
In this case we can complete the /gamemode arguments using the TAB key
To use the tab completer in skript, we need a script with our command, this is the mine:
command /gm <gamemode>:
trigger:
set player's gamemode to arg-1
send "&aChanged your gamemode to %arg-1%"
trigger:
set player's gamemode to arg-1
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:
on tab completer for "/gm":
#In this line we need to put the command.
set {_completers::*} to "adventure", "creative", "spectator" and "survival"
#In this line we need to put the arguments to complete.
loop {_completers::*}:
add loop-value to completions
#In this line we need to put the command.
set {_completers::*} to "adventure", "creative", "spectator" and "survival"
#In this line we need to put the arguments to complete.
loop {_completers::*}:
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.
Here more examples:
Command script:
Completer script:
Screenshot:
command /sethome <string>:
trigger:
if {homes::%player%::*} is set:
set {home::%player%::%arg-1%} to player's position
add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
send "&aYour house %arg-1% was set"
else:
set {home::%player%::%arg-1%} to player's position
set {homes::%player%::*} to "%arg-1%"
send "&aYour house %arg-1% was set"
command /home <string>:
trigger:
if {home::%player%::%arg-1%} is set:
teleport player to {home::%player%::%arg-1%}
send "&aYou was teleported to %arg-1%"
else:
send "&4Invalid house name"
command /homes:
trigger:
send "&aYour houses: %{homes::%player%::*}%" to player
command /delhome <string>:
trigger:
if {home::%player%::%arg-1%} is set:
delete {home::%player%::%arg-1%}
remove "%arg-1%" from {homes::%player%::*}
send "&aYour house was deleted"
else:
send "&4Invalid house name"
trigger:
if {homes::%player%::*} is set:
set {home::%player%::%arg-1%} to player's position
add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
send "&aYour house %arg-1% was set"
else:
set {home::%player%::%arg-1%} to player's position
set {homes::%player%::*} to "%arg-1%"
send "&aYour house %arg-1% was set"
command /home <string>:
trigger:
if {home::%player%::%arg-1%} is set:
teleport player to {home::%player%::%arg-1%}
send "&aYou was teleported to %arg-1%"
else:
send "&4Invalid house name"
command /homes:
trigger:
send "&aYour houses: %{homes::%player%::*}%" to player
command /delhome <string>:
trigger:
if {home::%player%::%arg-1%} is set:
delete {home::%player%::%arg-1%}
remove "%arg-1%" from {homes::%player%::*}
send "&aYour house was deleted"
else:
send "&4Invalid house name"
Completer script:
on tab completer for "/home":
set {_completers::*} to {homes::%player%::*} #We can use variables
loop {_completers::*}:
add loop-value to completions
set {_completers::*} to {homes::%player%::*} #We can use variables
loop {_completers::*}:
add loop-value to completions
Screenshot: