Advertisement Create a free account

SendPing Updates and Changes

1560873588

Edited 1560873698
Stephanie B.
Roll20 Team
Greetings! This morning we pushed code that fixes and changes how sendPing functions. The sendPing API function moveAll = True now moves all players, not just the GM, if they are all on page specified in the API call. If no value is provided for moveAll, it defaults to false; when it is false, no players are moved, and everyone sees the ping. The sendPing API can now ping the same location more than once. The sendPing API now has a new option available, visibleTo, which can be used to specify which players are affected by the ping. Other players will not be moved or see the ping. If sending to a single player, you can include their player ID as a string or variable. If sending multiple IDs, they can be included either as an array, or as a comma-delimited text string. The player ID can obtained using the findObjs() function and you can then use playerIsGM(playerID) to determine if an individual player ID is a GM. In this way, you should be able to find and pass in the player IDs of GMs into the sendPing function. There's a code example and updated syntax in the wiki documentation . Because this changes how some API scripts may currently be set up, a hotfix for APIs is scheduled for Friday morning, June 21. Please have API script changes in by Thursday, June 20, at 10 AM PDT to get into the hotfix. If you were previously exploiting the  moveAll = true  bug in your script, you should update it, and we will give priority to reviewing pull requests for affected API scripts.
1561216913
The Aaron
Forum Champion
API Scripter
For anyone looking for a way to duplicate the former behavior of sendPing() , you can use these function: const getGMPlayers = (pageid) => findObjs({type:'player'}) .filter((p)=>playerIsGM(p.id)) .filter((p)=>undefined === pageid || p.get('lastpage') === pageid) .map(p=>p.id) ; const sendGMPing = (left, top, pageid, playerid=null, moveAll=false) => { let players = getGMPlayers(pageid); if(players.length){ sendPing(left,top,pageid,playerid,moveAll,players); } }; This is really a testament to how awesome this new version of the function is.  Mad props to the dev that did the visibleTo implementation.(*cough* Winget *cough*! =D ) sendGMPing() will ping only the GMs on the page the ping is issued for, taking the color from the playerid (or using yellow if omitted).  (Technically the new sendPing() only pings players who are on the page already, which is fabulously awesome and well done, but I left the behavior in getGMPlayers() as it might be useful for other things.) Cheers and thanks again for this awesome API update, Devs!
1564725224
Pat
Pro
Thinking of doing something with the API to try and use this to help players get to their characters easier when they arrive on a page... not sure how... may have to cycle through the available tokens on the current page to see which ones match the player pressing the button... 
1567882045
Would be nice of this page was also updated to avoid confusion: <a href="https://wiki.roll20.net/API:Function_documentation#sendPing" rel="nofollow">https://wiki.roll20.net/API:Function_documentation#sendPing</a>