#can i get help (resolved)
1 messages · Page 1 of 1 (latest)
let itemEffects = {
"custom:my_helmet": {
type: "night_vision",
duration: 260,
amplifier: 1
}
}
const slots = ["Head","Chest","Legs","Feet"]
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable")
for (let slot of slots) {
let item = equip.getEquipment(slot)
if (itemEffects[item?.typeId] == undefined) continue
player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false })
}
}
}, 2)
let itemEffects = {
"myname:mitril_helmet": {
type: "nigth_vision",
duration: 200,
amplifier: 1
}
}
const slots = ["Head","Chest","Legs","Feet"]
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable")
for (let slot of slots) {
let item = equip.getEquipment(slot)
if (itemEffects[item?.typeId] == undefined) continue
player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false })
}
}
}, 2)
not work
Debug result for [code](#1304754192283602994 message)
Compiler found 1 errors:
[36m<REPL0>.js[0m:[33m14[0m:[33m39[0m - [31merror[0m[30m TS2345: [0mArgument of type 'string' is not assignable to parameter of type 'EquipmentSlot'.
[7m14[0m let item = equip.getEquipment(slot)
[7m [0m [31m ~~~~[0m
There are no errors from ESLint.
oh okay
const EquipmentSlot = {
Head: "head",
Chest: "chest",
Legs: "legs",
Feet: "feet"
};
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
}
};
const slots = [EquipmentSlot.Head, EquipmentSlot.Chest, EquipmentSlot.Legs, EquipmentSlot.Feet];
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
if (itemEffects[item?.typeId] == undefined) continue;
player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false });
}
}
}, 2);
Debug result for [code](#1304754192283602994 message)
Compiler found 4 errors:
[36m<REPL0>.js[0m:[33m1[0m:[33m7[0m - [31merror[0m[30m TS2567: [0mEnum declarations can only merge with namespace or other enum declarations.
[7m1[0m const EquipmentSlot = {
[7m [0m [31m ~~~~~~~~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m3541[0m:[33m14[0m
[7m3541[0m enum EquipmentSlot {
[7m [0m [36m ~~~~~~~~~~~~~[0m
'EquipmentSlot' was also declared here.
``````ansi
[36m<REPL0>.js[0m:[33m22[0m:[33m37[0m - [31merror[0m[30m TS2345: [0mArgument of type '"Chest" | "Feet" | "Head" | "Legs"' is not assignable to parameter of type 'EquipmentSlot'.
Type '"Chest"' is not assignable to type 'EquipmentSlot'.
[7m22[0m let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
[7m [0m [31m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
``````ansi
[36m<REPL0>.js[0m:[33m22[0m:[33m45[0m - [31merror[0m[30m TS8016: [0mType assertion expressions can only be used in TypeScript files.
[7m22[0m let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
[7m [0m [31m ~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
``````ansi
[36m@minecraft/server.d.ts[0m:[33m3541[0m:[33m14[0m - [31merror[0m[30m TS2567: [0mEnum declarations can only merge with namespace or other enum declarations.
[7m3541[0m enum EquipmentSlot {
[7m [0m [31m ~~~~~~~~~~~~~[0m
[36m<REPL0>.js[0m:[33m1[0m:[33m7[0m
[7m1[0m const EquipmentSlot = {
[7m [0m [36m ~~~~~~~~~~~~~[0m
'EquipmentSlot' was also declared here.
There are no errors from ESLint.
@tame ingot wait I will code for u
thanks
you are really nice
import { EquipmentSlot, world, system } from "@minecraft/server";
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
}
};
const slots = [
EquipmentSlot.Head,
EquipmentSlot.Chest,
EquipmentSlot.Legs,
EquipmentSlot.Feet
];
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
let item = equip.getEquipment(slot);
if (!item || !itemEffects[item.typeId]) continue;
player.addEffect(
itemEffects[item.typeId].type,
itemEffects[item.typeId].duration || 5, {
amplifier: itemEffects[item.typeId].amplifier,
showParticles: false
}
);
}
}
}, 2);
@tame ingot this will working probably
okay
You are welcome
[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined
[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined
[Scripting][error]-Plugin [ElysiumCraft - 0.1.0] - [main.js] ran with error: [ReferenceError: 'EquipmentSlot' is not defined at <anonymous> (main.js:948)
]
Wait
Okay
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
}
};
const slots = ["head", "chest", "legs", "feet"];
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
let item = equip.getEquipment(slot);
if (!item || !itemEffects[item.typeId]) continue;
player.addEffect(
itemEffects[item.typeId].type,
itemEffects[item.typeId].duration || 5,
{ amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
);
}
}
}, 2);
@tame ingot
Remember import EquipmentSlot
[Scripting][error]-TypeError: Native type conversion failed. Function argument [0] expected type: EquipmentSlot at <anonymous> (main.js:953)
@uneven pond
// import { EquipmentSlot } from "@minecraft/server";
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
}
};
const slots = [
EquipmentSlot.Head,
EquipmentSlot.Chest,
EquipmentSlot.Legs,
EquipmentSlot.Feet
];
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
try {
let item = equip.getEquipment(slot);
if (!item || !itemEffects[item.typeId]) continue;
player.addEffect(
itemEffects[item.typeId].type,
itemEffects[item.typeId].duration || 5,
{ amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
);
} catch (error) {
console.error(`Error retrieving equipment for slot ${slot}:`, error);
}
}
}
}, 2);
No errors in [code](#1304754192283602994 message)
[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined
[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined
[Scripting][error]-Plugin [ElysiumCraft - 0.1.0] - [main.js] ran with error: [ReferenceError: 'EquipmentSlot' is not defined at <anonymous> (main.js:951)
]
i need import ???
On top of your code
okay
Like this
import { EquipmentSlot } from "@minecraft/server";
its the top of my code
import { world, ItemStack, system } from "@minecraft/server";
import {
ActionFormData,
MessageFormData,
ModalFormData
} from "@minecraft/server-ui";
export function log(text) { world.getDimension('overworld').runCommandAsync(tellraw @a[tag=log] {"rawtext":[{"text":"§7{log} §r${text.replace(/"/g, "\'")}"}]}) }
export function getScore(target, objective) {
target = target.scoreboardIdentity ?? target;
const o = getObjective(objective);
return o.hasParticipant(target) ? o.getScore(target) : o.addScore(target, 0);
}
function getObjective(objective) {
return world.scoreboard.getObjective(objective) ?? world.scoreboard.addObjective(objective);
}
export function runCommandAsync(command) {
try {
return { error: false, ...world.getDimension(overworld).runCommandAsync(command) };
} catch (error) {
return { error: true };
}
}
log("§dServeur juste avent")
log("§fBlitz Kitmap §7>> §9Map reloaded")
runCommandAsync("scoreboard objectives add money dummy")
runCommandAsync("scoreboard objectives add gems dummy")
Wait
import { world, ItemStack, system, EquipmentSlot } from "@minecraft/server";
import {
ActionFormData,
MessageFormData,
ModalFormData
} from "@minecraft/server-ui";
export function log(text) { world.getDimension('overworld').runCommandAsync(`tellraw @a[tag=log] {"rawtext":[{"text":"§7{log} §r${text.replace(/"/g, "\'")}"}]}`) }
export function getScore(target, objective) {
target = target.scoreboardIdentity ?? target;
const o = getObjective(objective);
return o.hasParticipant(target) ? o.getScore(target) : o.addScore(target, 0);
}
function getObjective(objective) {
return world.scoreboard.getObjective(objective) ?? world.scoreboard.addObjective(objective);
}
export function runCommandAsync(command) {
try {
return { error: false, ...world.getDimension(`overworld`).runCommandAsync(command) };
} catch (error) {
return { error: true };
}
}
log("§dServeur juste avent")
log("§fBlitz Kitmap §7>> §9Map reloaded")
runCommandAsync("scoreboard objectives add money dummy")
runCommandAsync("scoreboard objectives add gems dummy")
Nah like this
okay
And then add the code
See if will working
thank you so much
It worked ?
yaeh
Alr I'm happy too
Shouldn't
wait how can i add another part of armor
Wdym
@tame ingot
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
},
"myname:mitril_chestplate": {
type: "strength",
duration: 200,
amplifier: 2
},
"myname:mitril_leggings": {
type: "speed",
duration: 200,
amplifier: 1
},
"myname:mitril_boots": {
type: "jump_boost",
duration: 200,
amplifier: 1
}
};
const slots = [
EquipmentSlot.Head,
EquipmentSlot.Chest,
EquipmentSlot.Legs,
EquipmentSlot.Feet
];
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
try {
let item = equip.getEquipment(slot);
if (!item || !itemEffects[item.typeId]) continue;
player.addEffect(
itemEffects[item.typeId].type,
itemEffects[item.typeId].duration || 5,
{ amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
);
} catch (error) {
console.error(`Error retrieving equipment for slot ${slot}:`, error);
}
}
}
}, 2);
No errors in [code](#1304754192283602994 message)
This may work
..............
U can anytime change the part of top to adjust effect or duration
?
By the indentations you can understand that you inserted this code into some function. Send me all the code you use
its work
Uh maybe I can try
system.runInterval(() => {
itemEffect(player)
});
function itemEffect(player) {
let itemEffects = {
"myname:mitril_helmet": {
type: "night_vision",
duration: 200,
amplifier: 1
},
"myname:mitril_chestplate": {
type: "strength",
duration: 200,
amplifier: 2
},
"myname:mitril_leggings": {
type: "speed",
duration: 200,
amplifier: 1
},
"myname:mitril_boots": {
type: "jump_boost",
duration: 200,
amplifier: 1
}
};
const slots = [
EquipmentSlot.Head,
EquipmentSlot.Chest,
EquipmentSlot.Legs,
EquipmentSlot.Feet
];
for (let player of world.getAllPlayers()) {
let equip = player.getComponent("minecraft:equippable");
for (let slot of slots) {
try {
let item = equip.getEquipment(slot);
if (!item || !itemEffects[item.typeId]) continue;
player.addEffect(
itemEffects[item.typeId].type,
itemEffects[item.typeId].duration || 5, {
amplifier: itemEffects[item.typeId].amplifier,
showParticles: false
}
);
} catch (error) {
console.error(`Error retrieving equipment for slot ${slot}:`, error);
}
}
}
}, 2);
}
I think U means like this
@tame ingot You can choose not to use this, bc it just original
Yes. Absolutely incorrect code, due to which the lags will increase with each tick
But no. But it's still not right
Why was it necessary to remake it like that?
Debug result for [code](#1304754192283602994 message)
Compiler found 4 errors:
[36m<REPL0>.js[0m:[33m2[0m:[33m16[0m - [31merror[0m[30m TS2552: [0mCannot find name 'player'. Did you mean 'Player'?
[7m2[0m itemEffect(player)
[7m [0m [31m ~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m5272[0m:[33m15[0m
[7m5272[0m class Player extends Entity {
[7m [0m [36m ~~~~~~[0m
'Player' is declared here.
``````ansi
[36m<REPL0>.js[0m:[33m55[0m:[33m2[0m - [31merror[0m[30m TS1128: [0mDeclaration or statement expected.
[7m55[0m }, 2);
[7m [0m [31m ~[0m
``````ansi
[36m<REPL0>.js[0m:[33m55[0m:[33m5[0m - [31merror[0m[30m TS1005: [0m';' expected.
[7m55[0m }, 2);
[7m [0m [31m ~[0m
``````ansi
[36m<REPL0>.js[0m:[33m56[0m:[33m1[0m - [31merror[0m[30m TS1128: [0mDeclaration or statement expected.
[7m56[0m }
[7m [0m [31m~[0m
ESLint results:
<REPL0>.js
55:1 error Parsing error: Declaration or statement expected
Oh
@tame ingot just use this
Can U help him/her cuz I just a noob scripter
Ahhh. I just entered the name of the effect incorrectly. Write night_vision
.
@tame ingot
its resolved
Hmm, okay. You just made my code bigger
no
Show the correct code
If this is it, then yes, you just made my code bigger and spelled the word "night" correctly.
can you help me to create a box ???
let ElysiumCraft = {
Box: function(player) {
const form = new ActionFormData();
form.title("Choisissez une box");
form.button("Box en diamant", "textures/items/diamond_box.png");
form.button("Box en mithril", "textures/items/mitril_box.png");
form.button("Box en topaze", "textures/items/topaze_box.png");
form.show(player).then((response) => {
if (response.selection === 0) {
this.diamond_box(player);
} else if (response.selection === 1) {
this.mitril_box(player);
} else if (response.selection === 2) {
this.topaze_box(player);
}
});
},
mitril_box: function(player) {
const chance = Math.floor(Math.random() * 4);
let armure = "";
switch (chance) {
case 0:
armure = "mitril_Chestplate";
break;
case 1:
armure = "mitril_Leggings";
break;
case 2:
armure = "mitril_Boots";
break;
case 3:
armure = "mitril_Helmet";
break;
}
player.sendMessage("Vous avez obtenu : " + armure + " !");
},
diamond_box: function(player) {
player.sendMessage("Vous avez ouvert une box en diamant !");
},
topaze_box: function(player) {
player.sendMessage("Vous avez ouvert une box en topaze !");
}
};
world.events.playerInteract.subscribe((event) => {
let player = event.player;
if (event.action === "interact") {
ElysiumCraft.Box(player);
}
});
Wdym
let ElysiumCraft = {
Box: function(player) {
const form = new ActionFormData();
form.title("Choisissez une box");
form.button("Box en diamant", "textures/items/diamond_box.png");
form.button("Box en mithril", "textures/items/mitril_box.png");
form.button("Box en topaze", "textures/items/topaze_box.png");
form.show(player).then((response) => {
if (response.selection === 0) {
this.diamond_box(player);
} else if (response.selection === 1) {
this.mitril_box(player);
} else if (response.selection === 2) {
this.topaze_box(player);
}
});
},
mitril_box: function(player) {
const chance = Math.floor(Math.random() * 4);
let armure = "";
switch (chance) {
case 0:
armure = "mitril_Chestplate";
break;
case 1:
armure = "mitril_Leggings";
break;
case 2:
armure = "mitril_Boots";
break;
case 3:
armure = "mitril_Helmet";
break;
}
player.sendMessage("Vous avez obtenu : " + armure + " !");
},
diamond_box: function(player) {
player.sendMessage("Vous avez ouvert une box en diamant !");
},
topaze_box: function(player) {
player.sendMessage("Vous avez ouvert une box en topaze !");
}
};
world.events.playerInteract.subscribe((event) => {
let player = event.player;
if (event.action === "interact") {
ElysiumCraft.Box(player);
}
});
@tame ingot U also can write like this
player.sendMessage(`Vous avez obtenu : ${armure} !`);
Up to u
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'playerInteract' of undefined
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'playerInteract' of undefined
[Scripting][error]-Plugin [ElysiumCraft - 0.1.0] - [main.js] ran with error: [TypeError: cannot read property 'playerInteract' of undefined at <anonymous> (main.js:664)
]
This is the new error?
Wait who gives U the last part of this code
Thats might be error
Wait
@tame ingot what are U trying to do with player interact?
It's seems like not have things like this
world.events.playerInteract
Did U generate the code with ai?
If right then tell me what U do I will correct it