Adding too BlockySoda's Chat Tags tutorial

[Pie] Piero
Joined 19/02/2020
Posts 1,296
04:19 AM 08/11/2020
Best you read Blocky's first before reading this one:
https://www.brick-hill.com/forum/thread/771419/

Was working on a script for names in chat and learned that you should use else if if you have people who fit multiple tags.

For example, if I were a creator of a game and wanted the tag [Developer] and I have a [VIP] tag as well for owning the asset that grants me it, I would get both tags at once and it will look something like this:

[Developer] player1: Hello
[VIP] player1: Hello

We don't want that.

So it's good to add else if instead of if for the script will run down the player and if you fit the first if it will then skip the rest of the ifs and thus only have one tag in the chat.

Game.on("chat", async(player, message) => {
if(player.userId == 224337){
Game.messageAll("[Developer] " + "[#C60000]" + player.username + "[#FFFFFF]" + ": " + message)
}
else if(player.admin){
Game.messageAll("[Admin] " + "[#3292D3]" + player.username + "[#FFFFFF]" + ": " + message)
}
else if(player.ownsAsset(208266)){
Game.messageAll("[VIP] " + "[#F3B700]" + player.username + "[#FFFFFF]" + ": " + message)
}
else{
Game.messageAll("[#FFFFFF]" + player.username + ": " + message)
}
});


So if I were an admin on Brick-Hill and I made a game and decided to put my ID for the Developer tag then the script will stop at Developer.


[P00R] Prince Weed
Joined 26/07/2020
Posts 10,644
04:20 AM 08/11/2020
[ Content Removed ]


[Pie] Piero
Joined 19/02/2020
Posts 1,296
04:20 AM 08/11/2020
Why did I put too instead or to? Must have been a brain fart.


SmartLion
Joined 16/04/2017
Posts 1,970
04:21 AM 08/11/2020
Formatting breaks the code, please give snippets in pastebin instead.


[Pie] Piero
Joined 19/02/2020
Posts 1,296
04:27 AM 08/11/2020
Quote from SmartLion , 04:21 AM 08/11/2020
Formatting breaks the code, please give snippets in pastebin instead.
Will do, sorry about that.

https://pastebin.com/uUJ1CCMc

Hopefully this works.


[TLVK] Edge.
Joined 19/05/2020
Posts 2,266
02:58 PM 01/12/2020
Quote from Piero , 04:27 AM 08/11/2020
Quote from SmartLion , 04:21 AM 08/11/2020
Formatting breaks the code, please give snippets in pastebin instead.

Will do, sorry about that.

https://pastebin.com/uUJ1CCMc

Hopefully this works.
I'm sorry, but on the original thread I already had done the tutorial port to Markdown.

https://gist.github.com/Core-commits/25c960b3d3227d0c5b3ea6adb809fae0

1