#player.teleport

1 messages · Page 1 of 1 (latest)

light bough
#

go learn how Vector works

stone rose
#

to where?

dusky galleon
#

you need xrot and yrot

#

player.teleport(new Vector3(x, y, z), dimension, 0, 0, false)

#

Like this

stone rose
#

for me it was optional

dusky galleon
#

It is needed

#

So just copy the code

stone rose
#

I will test here thanks

#

no, i did something wrong

dusky galleon
#

send👏your👏content👏logs👏

stone rose
#

code?

#

player.addTag(HOME|${r.formValues[0]}| ${Object.values(player.location).map(Math.floor).join(" ")} |${dim} )

stone rose
#

code is there

stone rose
#

?

stone groveBOT
#
No Errors

No errors in [code](#1094058622952149062 message)

stone groveBOT
#
No Errors

No errors in [code](#1094058622952149062 message)

glass zodiac
#

btw, this is what I get from that codejs [Scripting][warning]-[ "HOME", "homeTest", " -63 77 736 minecraft", "overworld " ]

stone rose
#

"Home:test: -62 50 10 minecraft:overworld"

#

This is the tag

stone rose
#

what is wrong?

silent yoke
#

i would suggest fo you to save your tags differently

#

like "Home|test|-62|50|10|minecraft:overworld"

stone rose
#

player.addTag(HOME|${r.formValues[0]}| ${Object.values(player.location).map(Math.floor).join(" ")} |${dim} )

silent yoke
#
player.addTag(`HOME|${r.formValues[0]}|${Object.values(player.location).map(Math.floor).join("|")}|${dim}`)
#

@stone rose

stone rose
#

I would leave it with space

silent yoke
#

why

#

that will just break everything

stone rose
#

ha

silent yoke
#

wdym "ha" bruh

stone rose
#

?

silent yoke
#

..

stone rose
#

ha = like this

#

did not teleport

silent yoke
#

welll yeah u gotta change ur tp code

stone rose
#

I changed

silent yoke
#

show

stone rose
#
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`)
       
    })
}
silent yoke
#

hmm idk that seems good

stone rose
#

AND

dusky galleon
stone rose
dusky galleon
#

Ok

stone rose
#
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]}"`)
  })
}
dusky galleon
# stone rose ```js function exgui6(player) { const tags = player.getTags().filter(tag => tag....

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`)
       
    })
}
dusky galleon
dusky galleon
stone rose
#

Ok kk

silent yoke
stone rose
#

it wasn't the same

dusky galleon
dusky galleon
#

huh

silent yoke
#

anyway im willing to bet its smt with this

#

is vector even a default js class

dusky galleon
#

?

stone rose
#

?

silent yoke
#

?

stone rose
#

none of the 2 worked

silent yoke
#

well ofc, they both do the same thing, except i dont strip the namespace lol

dusky galleon
silent yoke
#

is vector even a default js class

dusky galleon
silent yoke
#

dont u have to inport Vector

dusky galleon
#

Yes

silent yoke
#

actually Vector3

#

from mc

#

/server

stone rose
#

I didn't care

dusky galleon
#

Both Vector and Vector3 works

silent yoke
silent yoke
stone rose
#

Vector

silent yoke
#

u lit said it doesnt work and we are tryna find out why

#

try importing vector

dusky galleon
#

why tf you don't care on importing Vector/Vector3 in minecraft

silent yoke
#

from @˙minecraf/server

stone rose
#

I've already tried

dusky galleon
#

ok

#

rip script

stone rose
#

?

#

What?

dusky galleon
#

idk, it takes weeks for someone to help you again

stone rose
#

sad

#

Anybody know?

light bough
#

what

stone rose
#

is not teleporting

stone rose
#

?

stone rose
#

I don't understand, what are you talking about

#

Problem is it is not teleporting

stone groveBOT
#
Debug Result

There is 1 error in this [code](#1094058622952149062 message):

<repl>.js:10:17 - error TS2552: Cannot find name 'exgui5'. Did you mean 'exgui6'?

10                 exgui5(player);
                   ~~~~~~

  <repl>.js:1:10
    1 function exgui6(player) {
               ~~~~~~
    'exgui6' is declared here.

bronze trench
#

Have you tried just doing normal teleport withiut the variables?

#

If that works then theres a problem with parsing the chat

gilded flare
#

I didn't know thanks

stone rose
#

I'm getting the data from the TAG bro

bronze trench
#

I know that. I'm saying, if the teleport code works without the data, then that means your script has troublr getting the data

light bough
#

mm

stone rose
#

not tested

#

But if that were the case, the button data wouldn't be wrong either?

#

?

bronze trench
#

Could you change

new Vector(x, y, z)

To

{x:x, y:y, z:}
#

shrug Bedrock moment?

stone rose
#

Nobody knows what's wrong

#

'(

light bough
#

what do you want

#

were do you put the player location

dusky galleon
#

were

light bough
#

@stone rose

stone rose
#

Just look in the Code

#

I want to make the player teleport in the coordinates and dimension where he set the home

light bough
#

give me one sec i will make you the code

stone rose
#

Ok

light bough
#

@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!'); ```

glass zodiac
#

Why code so long

light bough
#

mm

#

idk

light bough
#

@glass zodiac i don't even know if the code works

#

is it good or bad

glass zodiac
#

uhh, i'd say use native methods and less cmds

gilded flare
#

Db

light bough
#

what

glass zodiac
#

with tag

gilded flare
#

Alr

light bough
#

oh with tags

gilded flare
#

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

glass zodiac
#

if ppl dont want to reveal thier home coords, then it's an issue

light bough
#

then dont use tag

#

use a database

#

what do i do

gilded flare
#

Okay, wasn't sure if there was a way to stop/msg

light bough
#

yea

#

make a plugin that remove the /msg command

glass zodiac
#

not sure tho, but darknavi mentioned to limit the selectors to only use name in future update

#

there was a discussion in Bedrock OSS

gilded flare
#

Oh that would be nice if they changed that

gilded flare
glass zodiac
#

it can be used with selectors

light bough
#

you can make a realm that puts you in a server then xbox players can join custom servers

stone rose
#

this one also does not teleport in the dimension that home was created

silent yoke
#

💀

#

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

stone rose
#

?

gilded flare
silent yoke
#

pff

#

easy solution learn to code and dont use chatgpt

#

good thread

stone rose
#

It's getting away from the subject

silent yoke
#

not really

stone rose
#

what's wrong then

glass zodiac
glass zodiac
#

well

#

what's on line 44?

light bough
#

oh he want to make it into a form

stone rose
#

wrong picture

#

did not teleport

glass zodiac
#

did u remove ur tags...

stone rose
#

no

#

because I always create new map...

light bough
#

are you try to make a home system with form

#

@stone rose

stone rose
#

when copying the code ended up replacing some lines

light bough
#

what are you try to do

stone rose
#

it already worked

light bough
#

@glass zodiac what is he trying to do

glass zodiac
#

making home in dimensions

light bough
#

that's easy

stone rose
#

Is there a way to remove these .3?

light bough
#

yea

glass zodiac
#
tag[2].split(' ').map(Number)
light bough
#

what is he using tags or database

glass zodiac
#

tags

light bough
#

ah

#

why not a database

#

way better

#

it's taking you guys way too long to do this

glass zodiac
#

making a database will be a different topic

stone rose
light bough
#

oh

#

tag are good to

light bough
#

mm @stone rose do you need anything else

stone rose
#

No

#

Calm

light bough
#

what

stone rose
light bough
#

can you show the code

glass zodiac
#
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
    }
})
light bough
#

why i hive been server Muted

#

what did i do