#How to add to a dynamic property?
1 messages · Page 1 of 1 (latest)
this is what I was trying to do
world.afterEvents.playerSpawn.subscribe((data) => {
const { initialSpawn, player: source } = data;
let player = data.player;
let amount = 0
if (initialSpawn) {
}
amount++
world.setDynamicProperty("players_unique", amount);
const D = world.getDynamicProperty("players_unique");
console.warn(D);
});```
anddd it didn't work
Is this what you are looking for?: ```js
world.afterEvents.playerSpawn.subscribe((data) => {
const { initialSpawn, player: source } = data;
if (!initialSpawn || source.hasTag('joined')) return; //If it's the first time the player has joined since the server started stop any code below. This will work reguarless of if the player joined already.
source.addTag('joined');
const D = world.getDynamicProperty("players_unique");
world.setDynamicProperty("players_unique", D + 1);
console.warn(D);
});
yep, thanks. by the way, how do you make it so you the text is colored?
Yes, Using this symbol: ```js
§
§0 Black
§1 Dark Blue
§2 Dark Green
§3 Dark Aqua
§4 Dark Red
§5 Dark Purple
§6 Gold
§7 Gray
§8 Dark Gray
§9 Blue
§a Green
§b Aqua
§c Red
§d Light Purple
§e Yellow
§f White
§g Minecoin Gold
§m Redstone
§n Copper
§p Gold
§q Emerald
§s Diamond
§t Lapis
§u Amethyst
§h Quartz
§i Iron
§j Netherite
§k Obfuscated
§l Bold
§o Italic
§r Reset formatting
Note that Strikethrough and Underline currently do not work:
oh, no, I know that already. I meant like this
import { world, system } from "@minecraft/server"
world.afterEvents.playerSpawn.subscribe((data) => {
const { initialSpawn, player: source } = data;
let player = data.player;
let amount = 0
if (initialSpawn) {
}
amount++
world.setDynamicProperty("players_unique", amount);
const D = world.getDynamicProperty("players_unique");
console.warn(D);
});
That's correct!