How to allow players to whisper to one other player?

Game development with Board Game Arena Studio
Post Reply
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

How to allow players to whisper to one other player?

Post by Idsky »

Is there a simple way to allow players to whisper to one other player?
If I go to a player profile and click 'message' I get a chat window just for them.
Can a game make links like that for individual players at the table?
If (for example) 2 players wanted to discuss suspicions about a 3rd player, or a game might be 2vs2 and the teams should discuss strategy privately.
I think it would be great if the system put a small button next to the player name on each player board for this.

Same with live audio -- can you speak to just one other player, or temporarily 'deafen' someone you don't want to hear?
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

Re: How to allow players to whisper to one other player?

Post by Idsky »

To be clear, I do not condone private message chat to team up against other players in normal competitive games.
But for some special case games, talking to just 1 other player is part of the rules.

I investigated and found a way. in jour game.js file…

Code: Select all

dojo.connect($("your_button"),"onclick",this,function() {
  var playerID=2328094;// replace with player IDs at the table.
  
  var a_src=$("avatar_"+playerID).src; //get avatar hash from player board -- also available in PHP player list -> player_avatar
  var avatar_hash=a_src.substring(a_src.lastIndexOf('h=')+2);
  
  this.createChatBarWindow({
        type: "privatechat",
        id: playerID,
        label: "idsky2",
        url: "/player?id=" +playerID,
        channel: "/player/p" +playerID,
        window_id: "privatechat_" + playerID,
        avatar: avatar_hash,
        subscribe: false,
        start: "expanded"
    }, false);
    this.expandChatWindow("privatechat_" +playerID);
    this.ackUnreadMessage("privatechat_" + playerID);
    this.loadPreviousMessage("privatechat", playerID);
    $("chatbarinput_privatechat_"+playerId+"_input").focus();
});
From there, you can start audio or video chat.
User avatar
Draasill
Posts: 197
Joined: 26 April 2020, 00:00

Re: How to allow players to whisper to one other player?

Post by Draasill »

Ahah I found the same thing, but I don't think it's sane to use such undocumented code :)
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

Re: How to allow players to whisper to one other player?

Post by Idsky »

The code and ability is all there. Needs to be a game option / setting to get a private-message button on player boards.
User avatar
Lymon Flowers
Posts: 196
Joined: 01 April 2020, 21:14

Re: How to allow players to whisper to one other player?

Post by Lymon Flowers »

If that is in the rules that you can whisper to other players, I would personally implement this with the notifyPlayer function and add in-game chat using game elements. That way, it is replayable once the game has finished and will not create hundred of chat sessions that would pollute the players history.
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

Re: How to allow players to whisper to one other player?

Post by Idsky »

True, that is a good way, though I liked the option of using audio or video.
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

Re: How to allow players to whisper to one other player?

Post by Idsky »

Could implement an in-game chat system using notify player, *and* have a button for audio or video connect using the undocumented functions.

That way, at least the text bit will always work, there's no polluting the user's message feed and it gracefully degrades if the undocumented js function goes away, only losing the non-essential audio/video option.
Post Reply

Return to “Developers”