#player.teleport
1 messages · Page 1 of 1 (latest)
to where?
you need xrot and yrot
player.teleport(new Vector3(x, y, z), dimension, 0, 0, false)
Like this
for me it was optional
send👏your👏content👏logs👏
code?
player.addTag(HOME|${r.formValues[0]}| ${Object.values(player.location).map(Math.floor).join(" ")} |${dim} )
code is there
?
No errors in [code](#1094058622952149062 message)
No errors in [code](#1094058622952149062 message)
what tags do u have
btw, this is what I get from that codejs [Scripting][warning]-[ "HOME", "homeTest", " -63 77 736 minecraft", "overworld " ]
what is wrong?
you need 'minecraft:overworld' not just 'overworld'
i would suggest fo you to save your tags differently
like "Home|test|-62|50|10|minecraft:overworld"
player.addTag(HOME|${r.formValues[0]}| ${Object.values(player.location).map(Math.floor).join(" ")} |${dim} )
player.addTag(`HOME|${r.formValues[0]}|${Object.values(player.location).map(Math.floor).join("|")}|${dim}`)
@stone rose
I would leave it with space
ha
wdym "ha" bruh
?
..
welll yeah u gotta change ur tp code
I changed
show
function exgui6(player) {
const tags = player.getTags().filter(tag => tag.startsWith("HOME|"))
if (tags.length === 0) {
const gui8 = new ActionFormData()
gui8.title("§lTeleportar Home")
gui8.body("Voce nao possui home para teleportar!")
gui8.button("§lCriar Home");
gui8.show(player).then(result => {
if(result.selection === 0){
exgui5(player);
}
})
return;
}
const tp = new ActionFormData()
.title("§lTeleportar Home")
.body("Selecione uma home:")
for (const tag of tags) {
const loc = tag.split("|")
const home = loc[1]
const x = loc[2]
const y = loc[3]
const z = loc[4]
tp.button(`§l${home}\n§2${x} ${y} ${z}`)
}
tp.show(player).then(result => {
const r = tags[result.selection].split("|")
const home = r[1]
const x = r[2]
const y = r[3]
const z = r[4]
const dimension = world.getDimension(r[5])
player.teleport(new Vector(x, y, z), dimension, 0, 0, false)
player.sendMessage("§aSucesso ao se teleportar na home§f " + home)
player.runCommandAsync(`playsound random.orb @s`)
})
}
hmm idk that seems good
AND
Send the code for making the home, like the sethome code
Oorrr
Home is creating right
Ok
function exgui5(player) {
const dim = player.dimension.id
const createForm = new ModalFormData()
.title("§lCriar home")
.textField("Nome da home:", "...")
createForm.show(player).then(r => {
if (r.canceled) return;
const [name] = r.formValues
if (name === "") {
player.sendMessage("§cColoque o nome da home!")
return;
}
player.addTag(`HOME|${r.formValues[0]}|${Object.values(player.location).map(Math.floor).join("|")}|${dim}`)
player.sendMessage(`§aHome criada com sucesso§f "${r.formValues[0]}"`)
})
}
Try this
function exgui6(player) {
const tags = player.getTags().filter(tag => tag.startsWith("HOME|"))
if (tags.length === 0) {
const gui8 = new ActionFormData()
gui8.title("§lTeleportar Home")
gui8.body("Voce nao possui home para teleportar!")
gui8.button("§lCriar Home");
gui8.show(player).then(result => {
if(result.selection === 0){
exgui5(player);
}
})
return;
}
const tp = new ActionFormData()
.title("§lTeleportar Home")
.body("Selecione uma home:")
for (const tag of tags) {
const loc = tag.split("|")
const home = loc[1]
const x = loc[2]
const y = loc[3]
const z = loc[4]
tp.button(`§l${home}\n§2${x} ${y} ${z}`)
}
tp.show(player).then(result => {
const r = tags[result.selection].split("|")
const home = r[1]
const x = r[2]
const y = r[3]
const z = r[4]
const dimension = world.getDimension(r[5]).replace("minecraft:", "")
player.teleport(new Vector(x, y, z), dimension, 0, 0, false)
player.sendMessage("§aSucesso ao se teleportar na home§f " + home)
player.runCommandAsync(`playsound random.orb @s`)
})
}
You see, you didn't remove the minecraft: in your dimension
Just try bro
Ok kk
u need the 'minecraft:'............
it wasn't the same
Its unecessary on getDimension, i did remove the minecraft: in my addon too, and it works fine
huh
?
?
?
none of the 2 worked
well ofc, they both do the same thing, except i dont strip the namespace lol
Wdym
wdym wdym wdim
dont u have to inport Vector
Yes
I didn't care
Both Vector and Vector3 works
oh alr
??
Vector
why tf you don't care on importing Vector/Vector3 in minecraft
from @˙minecraf/server
I've already tried
idk, it takes weeks for someone to help you again
what
is not teleporting
.
?
There is 1 error in this [code](#1094058622952149062 message):
[36m<repl>.js[0m:[33m10[0m:[33m17[0m - [31merror[0m[30m TS2552: [0mCannot find name 'exgui5'. Did you mean 'exgui6'?
[7m10[0m exgui5(player);
[7m [0m [31m ~~~~~~[0m
[36m<repl>.js[0m:[33m1[0m:[33m10[0m
[7m1[0m function exgui6(player) {
[7m [0m [36m ~~~~~~[0m
'exgui6' is declared here.
Have you tried just doing normal teleport withiut the variables?
If that works then theres a problem with parsing the chat
I didn't know thanks
From the chat?
I'm getting the data from the TAG bro
I know that. I'm saying, if the teleport code works without the data, then that means your script has troublr getting the data
mm
were
@stone rose
Just look in the Code
I want to make the player teleport in the coordinates and dimension where he set the home
give me one sec i will make you the code
Ok
@stone rose there you go ```js
import { world, system, PlayerSpawnEvent } from '@minecraft/server';
world.events.beforeChat.subscribe((data) => {
let message = data.message;
let player = data.sender;
if (message.startsWith('.sh ')) {
data.cancel = true;
let homename = message.replace('.sh ', '');
if (homename.length > 15 || homename.length < 1 || homename.includes(' ')) {
player.sendMessage(§cInvalid home name!);
player.playSound('random.orb');
return;
}
let x = player.location.x.toFixed(2);
let y = player.location.y.toFixed(2);
let z = player.location.z.toFixed(2);
let key = key:${homename},value:${x},${y},${z}
player.addTag(key)
player.sendMessage(§aSuccessfully set home ${homename} at ${x}, ${y}, ${z}!);
player.playSound('random.orb');
}
if (message.startsWith(.tph )) {
data.cancel = true;
let homename = message.replace('.tph ', '');
if (homename.length > 15 || homename.length < 1 || homename.includes(' ')) {
player.sendMessage(§cInvalid home name!);
player.playSound('random.orb');
return;
}
let key = key:${homename};
let home = player.getTags().find(tag => tag.includes(key));
console.warn(home);
if (home == undefined) {
player.sendMessage(§cYou don't have a home named ${homename}!);
player.playSound('random.orb');
return;
}
let coords = home.split('value:')[1].split(',');
let x = coords[0];
let y = coords[1];
let z = coords[2];
console.warn(tp "${player.nameTag}" ${x} ${y} ${z})
player.runCommandAsync(tp "${player.nameTag}" ${x} ${y} ${z});
player.sendMessage(§aSuccessfully teleported to home ${homename}!);
player.playSound('random.orb');
}
if (message.startsWith(.rh)) {
data.cancel = true;
let homename = message.replace('.rh ', '');
if (homename.length > 15 || homename.length < 1 || homename.includes(' ')) {
player.sendMessage(§cInvalid home name!);
player.playSound('random.orb');
return;
}
let key = key:${homename};
let home = player.getTags().find(tag => tag.includes(key));
console.warn(home);
if (home == undefined) {
player.sendMessage(§cYou don't have a home named ${homename}!);
player.playSound('random.orb');
return;
}
player.removeTag(home);
player.sendMessage(§aSuccessfully removed home ${homename}!);
player.playSound('random.orb');
}
});
console.warn('Home script loaded!'); ```
Why code so long
uhh, i'd say use native methods and less cmds
Is this without tags using a dv
Db
what
with tag
Alr
oh with tags
Blaze was saying something today about tags can be found using /msg @a[tag=
I haven't tested
But not sure of that is much of an issue
if ppl dont want to reveal thier home coords, then it's an issue
Okay, wasn't sure if there was a way to stop/msg
not sure tho, but darknavi mentioned to limit the selectors to only use name in future update
there was a discussion in Bedrock OSS
for non-op ig
Oh that would be nice if they changed that
A plugin? Would this be server only? I haven't looked into this for bedrock
it can be used with selectors
you can make a realm that puts you in a server then xbox players can join custom servers
practically nothing has changed except that this one is via chat
this one also does not teleport in the dimension that home was created
💀
damn is bedrock that badly coded
also why not encrypt the text then
and still use tags
you are never gonna reach the tag length limit anyway if thats the issue
?
I will have to see how chatgpt4 encrypts it's own tags very interesting to test when I can haha
pff
easy solution learn to code and dont use chatgpt
good thread
It's getting away from the subject
not really
what's wrong then
@stone rose
oh he want to make it into a form
did u remove ur tags...
when copying the code ended up replacing some lines
what are you try to do
it already worked
@glass zodiac what is he trying to do
making home in dimensions
that's easy
Is there a way to remove these .3?
yea
tag[2].split(' ').map(Number)
what is he using tags or database
tags
making a database will be a different topic
database I don't know yet
yea
mm @stone rose do you need anything else
what
I put the (Number) continued the same thing
can you show the code
const homeInfos = tags.map(tag => {
tag = tag.split("|")
const home = tag[1]
const [x, y, z] = tag[2].split(' ').map(parseFloat)//converting string to number
const dim = tag[3]
tp.button(`§l${home}\n§2${x.toFixed()} ${y.toFixed()} ${z.toFixed()}`)
return {
home,
location: { x, y, z },
dim
}
})
Bedrock moment?