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] player1: Hello
[VIP] player1: Hello
We don't want that.
So it's good to add
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.
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 if
s 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.
04:20 AM 08/11/2020
[ Content Removed ]
04:21 AM 08/11/2020
Formatting breaks the code, please give snippets in pastebin instead.
02:58 PM 01/12/2020
Quote from Piero , 04:27 AM 08/11/2020I'm sorry, but on the original thread I already had done the tutorial port to Markdown.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.
https://gist.github.com/Core-commits/25c960b3d3227d0c5b3ea6adb809fae0