Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

script request

Is there a way to make a script that would be able to let the DM know what the players are saying in whispers to each other?
1442375795

Edited 1442375913
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes: on('chat:message', function(msg) { if(msg.type === 'whisper' && msg.who.indexOf('->') === -1) { var name = 'Whisper: ' + msg.who + ' -> ' + msg.target_name; sendChat(name, '/w gm ' + msg.content); } });
And that's all you need in the script?
1442376087
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yep, it's pretty simple.
ok, thanks.
1442376681

Edited 1442377363
Is there a way to negate whispers that are aimed to or from the DM? I keep getting duplicate whispers that I send or or sent to me.
1442384722

Edited 1442385017
Lithl
Pro
Sheet Author
API Scripter
on('chat:message', function(msg) { if (msg.type === 'whisper' && msg.who.indexOf('->') === -1) { if (playerIsGM(msg.playerid)) return; // Don't echo whispers sent by a GM var target = findObjs({ type: 'player', displayname: msg.target_name })[0]; if (target && playerIsGM(target.id)) return; // Don't echo whispers originally sent to a GM var name = 'Whisper: ' + msg.who + ' -> ' + msg.target_name; sendChat(name, '/w gm ' + msg.content); } }); Should work. Actually, /w gm might produce a target_name of "gm". I haven't checked. If that's the case, you'd need this instead: on('chat:message', function(msg) { if (msg.type === 'whisper' && msg.who.indexOf('->') === -1) { if (playerIsGM(msg.playerid)) return; // Don't echo whispers sent by a GM var target = findObjs({ type: 'player', displayname: msg.target_name })[0]; if (target && playerIsGM(target.id)) return; // Don't echo whispers originally sent to a GM by name if (!target && toLowerCase(msg.target_name) === 'gm') return; // Don't echo whispers in the form /w gm var name = 'Whisper: ' + msg.who + ' -> ' + msg.target_name; sendChat(name, '/w gm ' + msg.content); } });
I hope you told your players you installed this script. It's a violation of their trust and privacy.
1442438098

Edited 1442438142
Thank you Brian, this will be very helpful; should I need to implement it. HoneyBadger said: I hope you told your players you installed this script. It's a violation of their trust and privacy. HoneyBadger, as far as letting my players know, they already think that I can already see their whispers. When we first started playing on of them asked if I could see what they whisper to other players, and although I couldn't at the time, I told them that yes I could because I was the DM. All players were ok with that. I just wanted to know if there was a script that would actually allow me to see the whispers and I haven't used the script in game yet, just on a test basis. It would be nice to actually be able to see the whispers though, as here lately there is a lot of side chatter going on.
Brian said: on('chat:message', function(msg) { if (msg.type === 'whisper' && msg.who.indexOf('->') === -1) { if (playerIsGM(msg.playerid)) return; // Don't echo whispers sent by a GM var target = findObjs({ type: 'player', displayname: msg.target_name })[0]; if (target && playerIsGM(target.id)) return; // Don't echo whispers originally sent to a GM var name = 'Whisper: ' + msg.who + ' -> ' + msg.target_name; sendChat(name, '/w gm ' + msg.content); } }); Should work. Actually, /w gm might produce a target_name of "gm". I haven't checked. If that's the case, you'd need this instead: on('chat:message', function(msg) { if (msg.type === 'whisper' && msg.who.indexOf('->') === -1) { if (playerIsGM(msg.playerid)) return; // Don't echo whispers sent by a GM var target = findObjs({ type: 'player', displayname: msg.target_name })[0]; if (target && playerIsGM(target.id)) return; // Don't echo whispers originally sent to a GM by name if (!target && toLowerCase(msg.target_name) === 'gm') return; // Don't echo whispers in the form /w gm var name = 'Whisper: ' + msg.who + ' -> ' + msg.target_name; sendChat(name, '/w gm ' + msg.content); } }); 1st one is giving me echo whispers, 2nd one is giving me this error : /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: toLowerCase is not defined at evalmachine. :3485:24 at eval ( What would be the fix for this? If you just want to post correction code and what line it goes on I can put it there, just not too sure how to fix. Just starting to learn JavaScript language and not familiar with how to debug yet.
1443098772
The Aaron
Pro
API Scripter
Replace  toLowerCase(msg.target_name) with  msg.target_name.toLowerCase()
Thanks, Aaron.