Page 1 of 1

How to allow players to whisper to one other player?

Posted: 16 July 2020, 14:46
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?

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

Posted: 18 July 2020, 12:01
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.

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

Posted: 18 July 2020, 14:00
by Draasill
Ahah I found the same thing, but I don't think it's sane to use such undocumented code :)

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

Posted: 18 July 2020, 14:56
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.

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

Posted: 20 July 2020, 21:37
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.

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

Posted: 21 July 2020, 05:40
by Idsky
True, that is a good way, though I liked the option of using audio or video.

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

Posted: 22 July 2020, 09:07
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.