#Chat Ranks and Chat Colors being independent
1 messages · Page 1 of 1 (latest)
@spice pelican
world.beforeEvents.chatSend.subscribe((data) => {
const player = data.sender;
const message = data.message;
const objective = world.scoreboard.getObjective("Team") ?? world.scoreboard.addObjective("Team", "Team");
data.cancel = true;
const score = objective.getScore(player);
if (score == 0) {
world.sendMessage(`<§7${player.name}§r> §f${message}`);
} else if (score == 1) {
world.sendMessage(`<§7${player.name}§r> §c${message}`);
} else if (score == 2) {
world.sendMessage(`<§7${player.name}§r> §b${message}`);
}
});
Ah so thats how you get a scoreboard to work
world.scoreboard.getObjective("Team")
So this would fix the multiplayer issue, however I still want to try to implement a rank system independent from this. I'm thinking I define a rank variable but I don't know how I'd change the rank properly based on a scoreboard.
Say I want a green text color, but member for the rank, so I'd have a score for Team and Rank.
As in how do we change Rank per score
With the text colors
world.beforeEvents.chatSend.subscribe((data) => {
const player = data.sender;
const message = data.message;
const objective = world.scoreboard.getObjective("Team") ?? world.scoreboard.addObjective("Team", "Team");
data.cancel = true;
const score = objective.getScore(player);
if (score == 0) {
world.sendMessage(`<§7${player.name}§r> §f${message}`);
} else if (score == 1) {
world.sendMessage(`<§7${player.name}§r> §c${message}`);
} else if (score == 2) {
world.sendMessage(`<§7${player.name}§r> §b${message}`);
} else if (score == 3) {
world.sendMessage(`<§7${player.name}§r> [Member] §b${message}`);
}
});
I meant like
They are seperate scoreboards.
One determines the rank, one determines the text color
I'm thinking we use ${rank} or something simillar. I'm just not sure how
ik what
i ant type olor sign on mobile but
selected olor and then rank
use dynamic properties
I'll have to look into how dynamic properties work then. One moment
I've never really messed with dynamic properties before. So I may have a little trouble with this
same
From my understanding its just a basic way to store info, but I'm more wandering on how to modify or change this value. Eg from String "Member" to string "Admin". I'm reading the wiki right now though
We can I just like
Don't really understand how it works very well
I'm trying out something rn though
Well I'm trying out documentation code and its throwing errors saying DynamicPropertiesDefinition isn't defined
Yeah I'm kind of clueless on how Dynamic Properties work
I never defined it. That's why I'm confused
I also did not import it
I tried it off and on imported
I used it to test some of the documeted code examples, but a little modified. But it fails on the first line saying its undefined
This is what I'm using
world.afterEvents.worldInitialize.subscribe((event) => {
const propertiesDefinition = new DynamicPropertiesDefinition();
propertiesDefinition.defineBoolean('isAngry');
event.propertyRegistry.registerEntityTypeDynamicProperties(propertiesDefinition, 'minecraft:zombie');
});
It says at the first line "DynamicPropertiesDefinition" is not defined for some reason. This is from the official wiki so I would assume it should work
https://wiki.bedrock.dev/scripting/script-server.html
You may have to scroll down a bit. But its registering dynamic properties
Under the "Saving and Loading" section
Yes
Ah okay
I'm honestly really confused on how to do this. Unless their is another way then dynamic properties
It looks like DynamicPropertiesDefinition has been removed but not updated on the wiki
So there is probably a diffrent way to register then/use Dyamic properties. I just have no idea how since it seems unproperly documented on the wiki
Alright I'll try it then
I actually have no idea what im doing in terms of using it as a per player thing
Yeah I have no idea how to use dynamic properties well enough to properly use it