#How get the name of a player that send chat ?

1 messages · Page 1 of 1 (latest)

obsidian rain
#

I received this error and this is my code, how solve it ?

import { world, system } from "@minecraft/server";
import {
    ActionFormData,
    MessageFormData,
    ModalFormData
} from "@minecraft/server-ui";
const form = new ActionFormData()
    .button("salut")
    .button("salut2")
    .body("sasa")
world.beforeEvents.itemUse.subscribe(async (eventData) => {
    const player = eventData.source;
    const itemUsed = eventData.itemStack;
    if (itemUsed.typeId == "minecraft:compass") {
        await form.show(player);
    }
});
red karma
light pewter
#

read more in resouces

obsidian rain
#

thx

#

How can I test if the player who useitem is a player with a specific name ?

#

How get the name of a player that send chat ?

stone trail
obsidian rain
#

Thanks

#

What this error mean ?
Here is my code:

import { world, system } from "@minecraft/server";
import {
    ActionFormData,
    MessageFormData,
    ModalFormData
} from "@minecraft/server-ui";
const form = new ActionFormData()
    .button("sable", "textures/blocks/sand")
    .button("gravier", "textures/blocks/gravel")

const choice = new ModalFormData()

    .textField('Number', "Number of blocks")

world.beforeEvents.itemUse.subscribe(async (eventData) => {
    const player = eventData.source;
    console.log(player)
    const itemUsed = eventData.itemStack;
    system.run(async () => {
        if (itemUsed.typeId == "minecraft:compass" && itemUsed.nameTag === "Form Opener006855") {
            await form.show(player).then(async (r) => {
                if (r.canceled) return
                await choice.show(player).then(async (res) => {
                    if (res.canceled) return
                    // const choices = {
                    //     0: "sand"
                    // }
                    let [textField] = r.formValues;
                    console.warn(r.selection)
                    console.warn(textField)
                    await world.getDimension('overworld').runCommandAsync(`/give @s sand ${res.formValues}`)
                })


            })
        }
    })
});
light pewter
obsidian rain
#

How can I fix it ?

#

Oh,okay i find the problem thanks, just the textField is not r.formValues but res.formValues

light pewter
#

👀