#Home System

1 messages · Page 1 of 1 (latest)

hazy ermine
#

Im stuck in this thing, i don't understand how they store it then teleport into it

untold dome
#

Im your future, it turns out its easy

#

No its really not

summer merlin
#

You could store it as a tag.

homeName:test x:100 y:100 z:100

x, y, and, z can act as markers that you can filter for to extract their position following after those so you can plug them in the teleport command using the API. While the homeName marker can be used to grab the correct one if you allow a command that implements a parameter looking for a string to verify against and report back if it doesn't exist in the list. I would probably limit this unless you want to allow many tags on a single player. 5 seems reasonable.

#

That's just one idea. 🤷‍♂️

untold dome
summer merlin
# untold dome can i do replace here? Or slice

Yea, it's what I do personally. I allow the player to enter a command gohome followed with a parameter for a string. I grab that string then validate if that string exists within homeName in the above example. If true, I grab the coordinates from x, y and z in a similar fashion. Then I plug those in to teleport the player back to that saved location.

#

If it returns false I tell the player that the saved home location doesn't exist.

#

To make it easier, I lowercase the strings to eliminate case sensitivity while filtering.

#

You can also go the extra mile and implement a timer to prevent abuse and enforcing players to wait a specific amount of time before being able to teleport again.

haughty shoal
#
const tag = 'homes[["Home1",100,100,100],["Home2",100,100,100]]'
const homes = JSON.parse(tag.replace('homes',''))
for (const home of homes) {
   console.log(home)
}
summer merlin
#

Something like that right there