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

Suggestions for an Automatic Player Ping Script

Nick O.
Forum Champion
I've written a script that automatically sends a Shift Ping to a token called PlayerStart after the player ribbon has been moved to a new page. Basically what happens is the ribbon gets moved, the script waits 1.5 seconds for the page to load, and then fires the Shift Ping to center all the player's views onto that point. The hardcoded 1.5 second wait is bugging me, though, because if a player's page takes longer than that to load, the ping will fire while the page is loading and their view won't be centered. Does anyone know of a cleaner way to do this?  on("ready",function() {     on ("change:campaign:playerpageid",function(){         //look for the token named PlayerStart         var tokens = findObjs({                 _pageid: Campaign().get('playerpageid'),                 _type: "graphic",                 _name: "PlayerStart"             });                      var token = tokens[0];         if (token===undefined) //if we don't find PlayerStart, exit gracefully         {             return;         }         //send the ping to PlayerStart 1.5 seconds after the page changes         setTimeout(function(){             sendPing(token.get("left"), token.get("top"), token.get("pageid"),"", true);         },1500);              }); });
The Aaron
Roll20 Production Team
API Scripter
I can't think of any way to get a more accurate tone. Probably delaying longer is the only option correctly, or manually triggering it.  You could switch to pinging specific players, and then give them a macro that takes them to the start point on the map they are on. Then when they are loaded, they can hit it to bring them to the spot. 
Nick O.
Forum Champion
That's a good idea, Aaron. I'll tweak the script so it does an auto-ping after 1.5 s, and then give players an option to do it themselves if they took longer than that to load. Thanks!