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

API Output if GM send only to GM if not GM send to all

I am looking for a way to set up and API so that if the player running the script (either directly or via a character sheet button) is the GM it will output the results only to the GM, but if it is a nonGM player then it can be displayed in the chat for everyone. The use case would be for NPC rolls that would use the same API as PCs but that you do not really want to display to the user (aka behind the screen rolls). This seems like it would have been done before, could any one point me to a script that does it well?
1424981284
The Aaron
Pro
API Scripter
The thing that has prevented much of this in the past is the inability to tell if a particular player is a GM. I have a script for this that has been used quite a bit. There is an official version coming with the Update of Holding, so you should see more of it. If you were going to write a script to do this with my isGM script, you could do this: on('chat:message',function(msg) { var whisper; if('api' !== msg.type) { return; } whisper = isGM(msg.playerid); sendChat('test', (whisper ? '/w gm ' : '') + 'This is output!'); }); On the Dev Server and in future production, you can just use isPlayerGM() instead of isGM(). (though the current version of isGM() will fallback to the isPlayerGM() function if it is available.)