I am making a rtp feature for a server and i just want it so when i move like, 2 block when i already clicked on tp, it would cancel. but i dont want it to cancel when jumping or turning the view, but it just cancels every move a player can do. uhh... I wrote some in korean so if you guys cant understand..well..sorry
command /rtp:
trigger:
rtp(player)
function rtp(p: player):
set {_gui} to chest inventory with 3 rows named "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ"
updateRTPGUI({_p}, {_gui})
open {_gui} to {_p}
loopRTPGUI({_p}, {_gui})
function updateRTPGUI(p: player, gui: inventory):
set {_count} to number of all players where [world of input is "world"]
set {_overworldItem} to grass block named "&aᴏᴠᴇʀᴡᴏʀʟᴅ"
set {_lore::*} to "&fClick to select region", "&7(아직 선택 기능 미구현)", "&r", "&f현재 오버월드 인원: %{_count}%명"
set lore of {_overworldItem} to {_lore::*}
set slot 11 of {_gui} to {_overworldItem}
set slot 13 of {_gui} to netherrack named "&aɴᴇᴛʜᴇʀ" with lore "&fClick to randomly teleport"
set slot 15 of {_gui} to end stone named "&aᴇɴᴅ" with lore "&fClick to randomly teleport"
function loopRTPGUI(p: player, gui: inventory):
set {rtp::%{_p}%::gui-open} to true
loop 999 times:
wait 1 second
if {rtp::%{_p}%::gui-open} is not set:
stop
if current inventory of {_p} is not {_gui}:
delete {rtp::%{_p}%::gui-open}
stop
updateRTPGUI({_p}, {_gui})
on inventory click:
if name of event-inventory is "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ":
if clicked inventory is not player inventory:
cancel event
if clicked slot is 11:
close player's inventory
send action bar "&aᴏᴠᴇʀᴡᴏʀʟᴅ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world")
else if clicked slot is 13:
close player's inventory
send action bar "&cɴᴇᴛʜᴇʀ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world_nether")
else if clicked slot is 15:
close player's inventory
send action bar "&dᴇɴᴅ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world_the_end")
on inventory close:
if name of event-inventory is "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ":
delete {rtp::%player%::gui-open}
function teleportWithCountdown(p: player, worldName: text):
set {rtp::%{_p}%::countdown} to 5
set {rtp::%{_p}%::location} to location of {_p}
set {rtp::%{_p}%::world} to {_worldName}
loop 5 times:
if location of {_p} is not {rtp::%{_p}%::location}:
send action bar "&c이동해서 텔레포트가 취소되었습니다!" to {_p}
delete {rtp::%{_p}%::*}
stop
send action bar "&e%{rtp::%{_p}%::countdown}%초 후 텔레포트됩니다. 움직이지 마세요!" to {_p}
subtract 1 from {rtp::%{_p}%::countdown}
wait 1 second
teleport {_p} to location(100, 100, 100, world({_worldName}))
send action bar "&a텔레포트 완료!" to {_p}
delete {rtp::%{_p}%::*}
command /rtp:
trigger:
rtp(player)
function rtp(p: player):
set {_gui} to chest inventory with 3 rows named "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ"
updateRTPGUI({_p}, {_gui})
open {_gui} to {_p}
loopRTPGUI({_p}, {_gui})
function updateRTPGUI(p: player, gui: inventory):
set {_count} to number of all players where [world of input is "world"]
set {_overworldItem} to grass block named "&aᴏᴠᴇʀᴡᴏʀʟᴅ"
set {_lore::*} to "&fClick to select region", "&7(아직 선택 기능 미구현)", "&r", "&f현재 오버월드 인원: %{_count}%명"
set lore of {_overworldItem} to {_lore::*}
set slot 11 of {_gui} to {_overworldItem}
set slot 13 of {_gui} to netherrack named "&aɴᴇᴛʜᴇʀ" with lore "&fClick to randomly teleport"
set slot 15 of {_gui} to end stone named "&aᴇɴᴅ" with lore "&fClick to randomly teleport"
function loopRTPGUI(p: player, gui: inventory):
set {rtp::%{_p}%::gui-open} to true
loop 999 times:
wait 1 second
if {rtp::%{_p}%::gui-open} is not set:
stop
if current inventory of {_p} is not {_gui}:
delete {rtp::%{_p}%::gui-open}
stop
updateRTPGUI({_p}, {_gui})
on inventory click:
if name of event-inventory is "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ":
if clicked inventory is not player inventory:
cancel event
if clicked slot is 11:
close player's inventory
send action bar "&aᴏᴠᴇʀᴡᴏʀʟᴅ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world")
else if clicked slot is 13:
close player's inventory
send action bar "&cɴᴇᴛʜᴇʀ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world_nether")
else if clicked slot is 15:
close player's inventory
send action bar "&dᴇɴᴅ 텔레포트를 준비 중입니다..." to player
teleportWithCountdown(player, "world_the_end")
on inventory close:
if name of event-inventory is "ʀᴀɴᴅᴏᴍ ᴛᴇʟᴇᴘᴏʀᴛ":
delete {rtp::%player%::gui-open}
function teleportWithCountdown(p: player, worldName: text):
set {rtp::%{_p}%::countdown} to 5
set {rtp::%{_p}%::location} to location of {_p}
set {rtp::%{_p}%::world} to {_worldName}
loop 5 times:
if location of {_p} is not {rtp::%{_p}%::location}:
send action bar "&c이동해서 텔레포트가 취소되었습니다!" to {_p}
delete {rtp::%{_p}%::*}
stop
send action bar "&e%{rtp::%{_p}%::countdown}%초 후 텔레포트됩니다. 움직이지 마세요!" to {_p}
subtract 1 from {rtp::%{_p}%::countdown}
wait 1 second
teleport {_p} to location(100, 100, 100, world({_worldName}))
send action bar "&a텔레포트 완료!" to {_p}
delete {rtp::%{_p}%::*}