#'Symbol.iterator' of undefined
1 messages · Page 1 of 1 (latest)
const players = [...world.getPlayers()];
const INVsee = new ModalFormData()
.title("InvseeUI-N")
.dropdown('§o§c Choose Who To see inv!', players.map(player => player.name))
INVsee.show(player).then(({ formValues: [dropdown] }) => {
const selectedPlayer = players[dropdown]
if (selectedPlayer) {
const inv = selectedPlayer.getComponent("inventory").container;
if (inv.emptySlotsCount === inv.size)
return player.sendMessage(`§4${selectedPlayer.nameTag} §cEmpty Inv`);
invseeUI(player, selectedPlayer);
}
})
}
function invseeUI(player, target) {
const inv = target.getComponent("inventory").container;
const invseeUI = new ChestFormData("large")
.title(`INVSEE-${target.nameTag}`);
for (let i = 0; i < inv.size; i++) {
const item = inv.getItem(i);
if (item === undefined) {
continue;
}
const itemType = item.typeId;
const amount = item.amount;
const getItemName = item.nameTag;
let enchantLore = "";
let enchanted;
for (const enchant of item.getComponent('minecraft:enchantments')?.enchantments) {
const enchantType = enchant?.type.id ?? null;
const enchantLevel = enchant?.level ?? 0;
if (enchantType) {
enchanted = true;
} else {
enchanted = false;
}
enchantLore += `\n§2+ §5${enchantType} v§d${enchantLevel}`;
}
invseeUI.button(i, `§2slot: ${i}`, ["§d§llore§r", `§7Type: ${itemType}\n${getItemName ? `itemName: ${getItemName}` : ""}${enchantLore}`], itemType, amount, enchanted);
}
invseeUI.button(45, "Close", ["", "Close the UI"], "textures/blocks/barrier", 1, true);
invseeUI.pattern([5, 1], [
"xxxxxxxx",
], {
x: { data: { itemName: '', itemDesc: [], enchanted: false, stackAmount: 1 }, iconPath: "minecraft:black_wool" }
});
invseeUI.show(player);
}```
thats the code
the error comes from this i think ```function invseeUI(player, target) {
const inv = target.getComponent("inventory").container;
const invseeUI = new ChestFormData("large")
.title(INVSEE-${target.nameTag});
for (let i = 0; i < inv.size; i++) {
const item = inv.getItem(i);
if (item === undefined) {
continue;
}
const itemType = item.typeId;
const amount = item.amount;
const getItemName = item.nameTag;
let enchantLore = "";
let enchanted;
for (const enchant of item.getComponent('minecraft:enchantments')?.enchantments) {
const enchantType = enchant?.type.id ?? null;
const enchantLevel = enchant?.level ?? 0;
if (enchantType) {
enchanted = true;
} else {
enchanted = false;
}
enchantLore += `\n§2+ §5${enchantType} v§d${enchantLevel}`;
}
invseeUI.button(i, `§2slot: ${i}`, ["§d§llore§r", `§7Type: ${itemType}\n${getItemName ? `itemName: ${getItemName}` : ""}${enchantLore}`], itemType, amount, enchanted);
}
invseeUI.button(45, "Close", ["", "Close the UI"], "textures/blocks/barrier", 1, true);
invseeUI.pattern([5, 1], [
"xxxxxxxx",
], {
x: { data: { itemName: '', itemDesc: [], enchanted: false, stackAmount: 1 }, iconPath: "minecraft:black_wool" }
});
invseeUI.show(player);
}```
i use this?
i think its because of chestformdata
its mostly a preset im pretty sure and im not sure if you can grab players items and put them on that.
this error means basicly that array is propably undefined and you can not for each it or making actions eith it bc that array is not array but undefined