import { world, system } from '@minecraft/server'
//Sets the inCombat score to 30s:
world.events.entityHurt.subscribe((combatLog) => {
const hit = combatLog.hurtEntity
const attacker = combatLog.damageSource.damagingEntity
if (hit.typeId !== "minecraft:player" || attacker?.typeId !== "minecraft:player") return;
//Telling the player if they are inCombat:
if (getScore(attacker, 'inCombat') == 0) {
attacker.tell("§l§cYou are now in §o§4Combat!")
}
if (getScore(hit, 'inCombat') == 0) {
hit.tell("§l§cYou are now in §o§4Combat!")
}
console.warn('Hit detected')
hit.runCommandAsync('scoreboard players set @s inCombat 600')
attacker.runCommandAsync('scoreboard players set @s inCombat 600')
//Kill system:
const health = hit.getComponent("minecraft:health").current
if (hit.typeId !== "minecraft:player" || attacker?.typeId !== "minecraft:player") return;
if (health <= 0) {
attacker.runCommandAsync('scoreboard players add @s kills 1')
attacker.runCommandAsync('effect @s instant_health 255 1 true')
}
})
//Getting the player inCombat score:
function getScore(player, inCombat) {
return world.scoreboard.getObjective(inCombat).getScore(player.scoreboard)
}
//Testing if the player has properly loaded in:
world.events.playerSpawn.subscribe((join) => {
if (!join.initialSpawn) return;
let player = join.player
if (getScore(player, 'inCombat') !== 0) {
world.say(`§l§4${player.name} §chas been killed for Combat Logging!`)
player.runCommandAsync("scoreboard players set @s inCombat 0")
player.runCommandAsync("kill @s")
}
})
world.events.entityHurt.subscribe((ev) => {
const hit = ev.hurtEntity
const attacker = ev.damageSource.damagingEntity
console.warn('Test')
})
#Everything broke in .60.
1 messages · Page 1 of 1 (latest)
Hello! So, ever since the 1.19.60 update, all my scripts have completely stopped working. I have no idea why, as nothing is appearing in the content log, and the code looks correct. I've put it through multiple debuggers and they have said nothing is wrong with the code.
Heres all my files. I don't see anything wrong with any of these files, any help is appreciated as nothing is showing up in the logs
Even the bottom console warn isn't logging
When I hit my other account, nothing happens
And in the logs no errors are related to scripts
Debug Result
There are errors in this [code](#1075246113294123048 message):
[36mindex.js[0m:[33m1[0m:[33m26[0m - [31merror[0m[30m TS2307: [0mCannot find module './db/Database.js' or its corresponding type declarations.
[7m1[0m import { Database } from './db/Database.js';
[7m [0m [31m ~~~~~~~~~~~~~~~~~~[0m
Debug Result
There are errors in this [code](#1075246113294123048 message):
[36mkillcount.js[0m:[33m12[0m:[33m12[0m - [31merror[0m[30m TS2339: [0mProperty 'tell' does not exist on type 'Entity'.
[7m12[0m attacker.tell("§l§cYou are now in §o§4Combat!")
[7m [0m [31m ~~~~[0m
[36mkillcount.js[0m:[33m15[0m:[33m5[0m - [31merror[0m[30m TS2339: [0mProperty 'tell' does not exist on type 'Entity'.
[7m15[0m hit.tell("§l§cYou are now in §o§4Combat!")
[7m [0m [31m ~~~~[0m
No way
import { world, system } from '@minecraft/server'
//Sets the inCombat score to 30s:
world.events.entityHurt.subscribe((combatLog) => {
console.warn('T')
const hit = combatLog.hurtEntity
const attacker = combatLog.damageSource.damagingEntity
if (hit.typeId !== "minecraft:player" || attacker?.typeId !== "minecraft:player") return;
//Telling the player if they are inCombat:
if (getScore(attacker, 'inCombat') == 0) {
attacker.sendMessage("§l§cYou are now in §o§4Combat!")
}
if (getScore(hit, 'inCombat') == 0) {
hit.sendMessage("§l§cYou are now in §o§4Combat!")
}
console.warn('Hit detected')
hit.runCommandAsync('scoreboard players set @s inCombat 600')
attacker.runCommandAsync('scoreboard players set @s inCombat 600')
//Kill system:
const health = hit.getComponent("minecraft:health").current
if (hit.typeId !== "minecraft:player" || attacker?.typeId !== "minecraft:player") return;
if (health <= 0) {
attacker.runCommandAsync('scoreboard players add @s kills 1')
attacker.runCommandAsync('effect @s instant_health 255 1 true')
}
})
//Getting the player inCombat score:
function getScore(player, inCombat) {
return world.scoreboard.getObjective(inCombat).getScore(player.scoreboard)
}
//Testing if the player has properly loaded in:
world.events.playerSpawn.subscribe((join) => {
if (!join.initialSpawn) return;
let player = join.player
if (getScore(player, 'inCombat') !== 0) {
world.say(`§l§4${player.name} §chas been killed for Combat Logging!`)
player.runCommandAsync("scoreboard players set @s inCombat 0")
player.runCommandAsync("kill @s")
}
})
world.events.entityHurt.subscribe((ev) => {
const hit = ev.hurtEntity
const attacker = ev.damageSource.damagingEntity
console.warn('Test')
})
Done, still not working
No errors again
@delicate radish
There’s probably a lot more to fix
Debug Result
There are errors in this [code](#1075246113294123048 message):
[36m<repl>.js[0m:[33m13[0m:[33m14[0m - [31merror[0m[30m TS2339: [0mProperty 'sendMessage' does not exist on type 'Entity'.
[7m13[0m attacker.sendMessage("§l§cYou are now in §o§4Combat!")
[7m [0m [31m ~~~~~~~~~~~[0m
[36m<repl>.js[0m:[33m16[0m:[33m9[0m - [31merror[0m[30m TS2339: [0mProperty 'sendMessage' does not exist on type 'Entity'.
[7m16[0m hit.sendMessage("§l§cYou are now in §o§4Combat!")
[7m [0m [31m ~~~~~~~~~~~[0m
@scenic veldt .sendMessage() isn't in 1.19.60. It is still .tell(). That's a change they made in the preview version for 1.19.70. You can see the other changes in that version here: #1074038906430955620 message
Doing .tell still don't do shit
I've been gettin no errors in the content log despite havin it on
Ion what's happening :(
The files you shared in your post above is the source? Or just specific files in general?
The ones above
None of them are working
Ever since 1.19.60
I've got no errors in the content log
So idk whats going on as nothing has changed
I'll load them up and see if I notice anything. I'm not doing anything at this moment.
Alright thank you
With your script above that is named killcount.js it appears that there is no method for .tell() when using the entityHurt event. So you may need to change those methods to .runCommandAsync() and use tellraw to send the message to that designated player.
Ok, so it seems the method .tell() falls under the Player Class and does not exist under the Entity Class according to what I am seeing on VSC and their documentation which frankly I find to be very odd.
Player Class with Methods
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/player#methods
Entity Class with Methods
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#methods
Nope
Lmfao
I got my mate to try it and it works fine for him
So idk wtf is wrong with my goofy phone
entityHurt gets the entity object from the Entity Class. According to their documentation as well as what I saw in the code when loaded up in visual studio code it shouldn't work. Based solely upon what you shared above and assuming there is no extra that could potentially have a role or change of effect. So I'm uncertain about your situation at the moment.
Hold up
I'll send a clip
Of it working for him
The script worked pre 1.19.60, and is now suddenly broken
I've tried literally everything
And it just won't work for me
Turns out it had something to do with the fucking manifest lmfaoooo
Like a week
Of trying to find this stupid error and it was because of my manifest 🗿🗿🗿
Hmm, and what issue did you have with the manifest?
Absolutely no clue
.... Yea, sounds fake lmao.
Program Output
/home/jail/prog.js:2
"format_version": 2,
^
SyntaxError: Unexpected token ':'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs
Bedic Mag#4317 | javascript | nodejs-16.14.0 | wandbox.org
Old manifest
And
One sec
New manifest
You can literally try the script yourself it works lmfao
Tryna say I'm faking what? Fixing my issue? 🤡
I'm not convinced with entityHurt. That is all.
You don't think the script works?
I loaded the script you shared from above into vsc, converted it to TypeScript to get realtime feedback, and quickly identified that the method didn't exist because the event being utilized was targeting the entity object versus a player object and therefore didn't exist.
Just giving insight on how I approached my conclusion.
I said earlier the script worked pre .60, so it makes sense on why I had to update my manifest. My mate sent me his pack that had the working script, and I used his manifest as he uses bridge which I'm assuming updates the manifest for you
Bro...
Typescript is going to give you an error if you use player in entity class
It'll still work regardless
I never said I used player. I was speaking about the two different objects and how one supports a method and the other does not.
Well... Have you tried testing the script?