Code used in the video is below, while there is some comments explaining parts of the code, I highly recommend watching the video for full explanation and thought process.
# Sethome Skript
# /sethome [<home name>] - argument defaults to "home"
# /home [<home name>] - argument defaults to "home"
# /listhomes
# /delhome <home name> - delete a home
command /sethome [<string>]:
permission: homes.create
trigger:
set {_homeName} to "home"
if arg-1 is set:
set {_homeName} to lowercase arg-1
set {homes::%player's uuid%::%{_homeName}%} to location of player
send "&7Your home &f%{_homeName}% &7has been set to &f%location of player%" to player
command /home [<string>]:
permission: homes.tp
trigger:
set {_homeName} to "home"
if arg-1 is set:
set {_homeName} to lowercase arg-1
if {homes::%player's uuid%::%{_homeName}%} is set:
# player has a home
teleport player to {homes::%player's uuid%::%{_homeName}%}
send "&7You have teleported to &f%{_homeName}%" to player
exit
# the player doesn't have a home with this name
send "&cYou do not have a home named &4%{_homeName}%" to player
command /listhomes:
permission: homes.list
trigger:
if size of {homes::%player's uuid%::*} is 0:
# player has no homes
send "&cYou have no homes! :(" to player
exit
send "&7Your homes:" to player
loop {homes::%player's uuid%::*}:
# loop-index - name of home
# loop-value - location of home
# world of loop-value
send "&e%loop-index%&7: &fX: %x coordinate of block at loop-value% Y: %y coordinate of block at loop-value%: Z: %z coordinate of block at loop-value%"
command /delhome <string>:
permission: homes.delete
usage: You need to specify a home
trigger:
set {_homeName} to lowercase arg-1
if {homes::%player's uuid%::%{_homeName}%} is set:
delete {homes::%player's uuid%::%{_homeName}%}
send "&7You have deleted your home &c%{_homeName}%" to player
exit
# home doesn't exist
send "&cYou do not have a home named &4%{_homeName}%&c! Try /listhomes" to player
You must be logged in to comment