How to show a message when someone join? #410
Answered
by
vincentfretin
vincentfretin
asked this question in
Q&A
-
How to show a message when someone join? |
Beta Was this translation helpful? Give feedback.
Answered by
vincentfretin
Apr 18, 2023
Replies: 1 comment
-
You can send your own message when you connect and do anything you want with it. const sendJoinMessage = (playerInfo) => {
const name = playerInfo.nametag;
const data = { type: "joined", name: name };
NAF.connection.broadcastDataGuaranteed("chatbox", data);
};
const receiveData = (_, dataType, data) => {
if (data.type === "joined") {
console.log(`${data.name} joined`);
}
};
function onConnect() {
NAF.connection.subscribeToDataChannel("chatbox", receiveData);
sendJoinMessage(document.getElementById('rig').components['player-info'].data);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
vincentfretin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can send your own message when you connect and do anything you want with it.
For example if you start with the nametag example where you have the
player-info
component. You could do something like this: