#what is bad?
1 messages · Page 1 of 1 (latest)
import { world, Player } from "@minecraft/server";
import { system } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:player") {
const name = (entity as Player).name;
const currentScore = player.scoreboard.getScore(obj);
player.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
system.runCommandAsync(`gamemode spectator ${name}`);
system.runCommandAsync(`kick ${name}`);
}
}
});
There are 5 errors in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m9[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m9[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
[36m<repl>.js[0m:[33m10[0m:[33m26[0m - [31merror[0m[30m TS2552: [0mCannot find name 'player'. Did you mean 'Player'?
[7m10[0m const currentScore = player.scoreboard.getScore(obj);
[7m [0m [31m ~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m3318[0m:[33m15[0m
[7m3318[0m class Player extends Entity {
[7m [0m [36m ~~~~~~[0m
'Player' is declared here.
[36m<repl>.js[0m:[33m11[0m:[33m5[0m - [31merror[0m[30m TS2552: [0mCannot find name 'player'. Did you mean 'Player'?
[7m11[0m player.scoreboard.setScore( obj, currentScore + 1);
[7m [0m [31m ~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m3318[0m:[33m15[0m
[7m3318[0m class Player extends Entity {
[7m [0m [36m ~~~~~~[0m
'Player' is declared here.
[36m<repl>.js[0m:[33m14[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m14[0m system.runCommandAsync(`gamemode spectator ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
[36m<repl>.js[0m:[33m15[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m15[0m system.runCommandAsync(`kick ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
There are 5 errors in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m9[0m:[33m29[0m - [31merror[0m[30m TS8016: [0mType assertion expressions can only be used in TypeScript files.
[7m9[0m const name = (entity as Player).name;
[7m [0m [31m ~~~~~~[0m
[36m<repl>.js[0m:[33m10[0m:[33m26[0m - [31merror[0m[30m TS2552: [0mCannot find name 'player'. Did you mean 'Player'?
[7m10[0m const currentScore = player.scoreboard.getScore(obj);
[7m [0m [31m ~~~~~~[0m
[36m<repl>.js[0m:[33m11[0m:[33m5[0m - [31merror[0m[30m TS2552: [0mCannot find name 'player'. Did you mean 'Player'?
[7m11[0m player.scoreboard.setScore( obj, currentScore + 1);
[7m [0m [31m ~~~~~~[0m
[36m<repl>.js[0m:[33m14[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m14[0m system.runCommandAsync(`gamemode spectator ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
[36m<repl>.js[0m:[33m15[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m15[0m system.runCommandAsync(`kick ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
discord is not collaborating with me, but basically, you used a variable called player without even having defined it, and the runCommandAsync method is from the world constant and not from the system constant, apart from that it would be easier for you use the runCommandAsync directly on the entity using the @s selector
import { system } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:Player") {
const name =
Player.name;
const currentScore = Player.scoreboard.getScore(obj);
Player.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
});```
this will not work as Player is a class not an object
import { world } from "@minecraft/server";
import { system } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:player") {
const name = entity.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator @s`);
entity.dimension.runCommandAsync(`kick ${name}`);
}
}
});
actually the runCommandAsync method is from the Dimension class and not from the world constant
hoe to use the debug stable?
press and hold the message (or press the three dots in the corner), go to apps and debug (stable)
There is 1 error in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m9[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m9[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
this error is not true, it just occurs because the name property only exists in the Player class and not in the Entity class
There is 1 error in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m9[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m9[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
You have player.scoreboard in there, but you never say what “player” is
You need to change player to entity
import { system , world } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:player") {
const name = entity.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
}); ```
@lean creek
There are 3 errors in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m8[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m8[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
[36m<repl>.js[0m:[33m13[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m13[0m system.runCommandAsync(`gamemode spectator ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
[36m<repl>.js[0m:[33m14[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'runCommandAsync' does not exist on type 'System'.
[7m14[0m system.runCommandAsync(`kick ${name}`);
[7m [0m [31m ~~~~~~~~~~~~~~~[0m
There is 1 error in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m8[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m8[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
import { world } from "@minecraft/server";
import { system } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:Player") {
const name =
Player.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
});```
@lean creek this should work now
No that won’t work
Use this
How do I get the bot to read this as JavaScript?
You on pc?
yes
On pc, right click on the messages then click the three dots, then go to apps, then click debug (stable)
Holdon lemme do it
import { world } from "@minecraft/server";
import { system } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:Player") {
const name =
Player.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
});```
No errors in [code](#1088679208584233010 message)
gooooood
This wouldn’t work anyway
No it won’t work
@lean creek Player.name will not get you the player. It will get you the class called Player
Use the thing that I sent
@lean creek use this:
import { system , world } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:player") {
const name = entity.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
}); ```
but another question, I'm talking about always putting the code, I do what you told me but it tells me that I should change it to JacaScript, I'm new to that bot
You know how you have those “`` things at the start of the code block? The bot just needs you to add “js” to it, so it would look like this: “```js”
And once you’ve added the ```js, the code should change colours
ooh ya, thks 😄
Anyway did you try the script I sent
have a this error D:
[Scripting][error]-TypeError: cannot read property 'getScore' of undefined at <anonymous> (main.js:10)
Send the code
I don't understand what happens with GetScore
import { system , world } from "@minecraft/server";
const score = world.scoreboard;
const obj = score.addObjective("Muertes", "Muertes");
score.setObjectiveAtDisplaySlot("sidebar", { objective: obj })
world.events.entityDie.subscribe(eventData => {
const entity = eventData.deadEntity;
if (entity.typeId === "minecraft:player") {
const name = entity.name;
const currentScore = entity.scoreboard.getScore(obj);
entity.scoreboard.setScore( obj, currentScore + 1);
if (currentScore + 1 >= 3) {
entity.runCommandAsync(`gamemode spectator ${name}`);
entity.runCommandAsync(`kick ${name}`);
}
}
}); ```
I made a modification to be displayed on the side of the screen is the only change (line 5)
Does it display it properly?
There is 1 error in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m9[0m:[33m25[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m9[0m const name = entity.name;
[7m [0m [31m ~~~~[0m
@lean creek
yeah, it shows on the side "Muertes" but nothing is added to what I die and that error comes out
No errors in [code](#1088679208584233010 message)
hm ok lemme test it
okok
hm
well this is the closest I could get
const score = world.scoreboard;
const obj = score.addObjective("Deaths", "Deaths");
score.setObjectiveAtDisplaySlot("sidebar", { objective: obj })
world.events.entityDie.subscribe(eventData => {
const { deadEntity } = eventData
if (deadEntity.typeId == "minecraft:player") {
const name = deadEntity.name;
const entityScoreboard = deadEntity.scoreboard
const currentScore = world.scoreboard.getScore(obj, entityScoreboard);
world.scoreboard.setScore(obj, entityScoreboard, currentScore + 1);
if (currentScore + 1 >= 3) {
deadEntity.runCommandAsync(`gamemode spectator ${name}`);
deadEntity.runCommandAsync(`kick ${name}`);
}
}
})```
so you can't run getScore on entities
you needa get the entity's scoreboard id and use that in the getScore
but it's not working for me
this is on the right track, but i don't really have time to finish
sorry bout that
There are 3 errors in this [code](#1088679208584233010 message):
[36m<repl>.js[0m:[33m7[0m:[33m33[0m - [31merror[0m[30m TS2339: [0mProperty 'name' does not exist on type 'Entity'.
[7m7[0m const name = deadEntity.name;
[7m [0m [31m ~~~~[0m
[36m<repl>.js[0m:[33m9[0m:[33m58[0m - [31merror[0m[30m TS2345: [0mArgument of type '{ objective: ScoreboardObjective; }' is not assignable to parameter of type 'ScoreboardObjective'.
Object literal may only specify known properties, and 'objective' does not exist in type 'ScoreboardObjective'.
[7m9[0m const currentScore = world.scoreboard.getScore({ objective: obj }, entityScoreboard);
[7m [0m [31m ~~~~~~~~~~~~~~[0m
[36m<repl>.js[0m:[33m10[0m:[33m37[0m - [31merror[0m[30m TS2345: [0mArgument of type '{ objective: ScoreboardObjective; }' is not assignable to parameter of type 'ScoreboardObjective'.
Object literal may only specify known properties, and 'objective' does not exist in type 'ScoreboardObjective'.
[7m10[0m world.scoreboard.setScore({ objective: obj }, entityScoreboard, currentScore + 1);
[7m [0m [31m ~~~~~~~~~~~~~~[0m