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

sendPing... why it no worky?

I use a player called "Gloria" on a big screen to show the players a ship viewscreen like in StarTrek. I want to send a series of pings for the players to see where a radio transmission is coming from. It does not work. In fact, I cannot seem to make a ping appear via the API at all! Here's my code:  *on("ready", () => {     on("chat:message", (msg) => {         if (msg.type === "api" && msg.content === "!distress") {             startPinging();         }     });     const pingInterval = 5000; // Time between pings in milliseconds (5 seconds)     const duration = 55000; // Total duration in milliseconds (55 seconds)     const numPings = Math.floor(duration / pingInterval); // Number of pings to send    const graphicName = "GRID-1";    const bar3Value = "planet";    const startPinging = () => {         const graphic = findObjs({             _type: "graphic",             name: graphicName,             bar3_value: bar3Value         })[0];         if (!graphic) {             log(`No graphic found with name '${graphicName}' and bar3 value '${bar3Value}'`);             return;         }         const pageId = graphic.get("pageid");         const left = graphic.get("left");         const top = graphic.get("top");         for (let i = 0; i < numPings; i++) {             setTimeout(() => {                  sendPing(left, top, pageId,  '-Nj_Dg6a5ikbFyo8uxEM', false );             }, i * pingInterval);         }     }; });
1731386134
The Aaron
Roll20 Production Team
API Scripter
sendPing() is not working on Jumpgate currently. They are working on a fix for that. 
I dont use Jumpgate for fear of my many custom scripts, and because it consistently failed to copy my stuff over. Im making the move in 2025 or so.
1731542535
The Aaron
Roll20 Production Team
API Scripter
Hmm. I started digging into this, and it appears that sendPing() is broken.  I'll get a repro script to the devs.
1731543553
The Aaron
Roll20 Production Team
API Scripter
Ok, now I'm not so sure.  It seemed to not be working originally, but now I'm getting it to work consistently.  Try this version.  The only real thing I changed is grabbing the creating player's player id and using that for the ping color: on("ready", () => { const getCreator = () => findObjs({type:'player'}).reduce( (m,p) => (m.id < p.id) ? m : p ); let PingPlayerID = getCreator().id; on("chat:message", (msg) => { if (msg.type === "api" && msg.content === "!distress") { startPinging(); } }); const pingInterval = 5000; // Time between pings in milliseconds (5 seconds) const duration = 55000; // Total duration in milliseconds (55 seconds) const numPings = Math.floor(duration / pingInterval); // Number of pings to send const graphicName = "GRID-1"; const bar3Value = "planet"; const startPinging = () => { const graphic = findObjs({ _type: "graphic", name: graphicName, bar3_value: bar3Value })[0]; if (!graphic) { log(`No graphic found with name '${graphicName}' and bar3 value '${bar3Value}'`); return; } const pageId = graphic.get("pageid"); const left = graphic.get("left"); const top = graphic.get("top"); for (let i = 0; i < numPings; i++) { setTimeout(() => { sendPing(left, top, pageId, PingPlayerID, false); }, i * pingInterval); } }; });
1731592601

Edited 1731592669
GM
Pro
HMMM.... It still doesnt work. Perhaps it's because I am the GM and I'm making an NPC the ping target as a token action? For context, Im using this to make a planet ping out like the radar script would while a distress call track is playing. The character represented is named 'planet', the token is named 'GRID-1'. I feel like somewhere in there is the issue. If I can't solve this, I'll just try a setInterval with the !radar script and see how that goes? Also, THANK YOU. You, Timmaugh and a few others deserve a frosty or caffeinated beverage or 3 on me. The Aaron said: Ok, now I'm not so sure.  It seemed to not be working originally, but now I'm getting it to work consistently.  Try this version.  The only real thing I changed is grabbing the creating player's player id and using that for the ping color: on("ready", () => { const getCreator = () => findObjs({type:'player'}).reduce( (m,p) => (m.id < p.id) ? m : p ); let PingPlayerID = getCreator().id; on("chat:message", (msg) => { if (msg.type === "api" && msg.content === "!distress") { startPinging(); } }); const pingInterval = 5000; // Time between pings in milliseconds (5 seconds) const duration = 55000; // Total duration in milliseconds (55 seconds) const numPings = Math.floor(duration / pingInterval); // Number of pings to send const graphicName = "GRID-1"; const bar3Value = "planet"; const startPinging = () => { const graphic = findObjs({ _type: "graphic", name: graphicName, bar3_value: bar3Value })[0]; if (!graphic) { log(`No graphic found with name '${graphicName}' and bar3 value '${bar3Value}'`); return; } const pageId = graphic.get("pageid"); const left = graphic.get("left"); const top = graphic.get("top"); for (let i = 0; i < numPings; i++) { setTimeout(() => { sendPing(left, top, pageId, PingPlayerID, false); }, i * pingInterval); } }; });
1731596350

Edited 1731596371
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Is the player flag on the page where the script is being run?
keithcurtis said: Is the player flag on the page where the script is being run? Yep. That was my 1st “lemme check” moment prior to posting. 😎
1731652679
The Aaron
Roll20 Production Team
API Scripter
When you say you're using an NPC ID, are you taLking about as a parameter to sendPing()?
The Aaron said: When you say you're using an NPC ID, are you taLking about as a parameter to sendPing()? I omitted the playerId and now it works fine. SO weird. I have a "display character". I use that character's view (the ship's AI) on a bigscreen during in-person play, while the Crew uses their laptops to do their own tasks. Think captain Kirk/Picard saying "on screen". So, it works now, though it would be cooler if I could decide the color of the ping... but now Im asking too much, sir. Here's the hacked together quick demo I posted elsewhere last week if you're curious.&nbsp;<a href="https://youtu.be/bAP1EkkPKSk?si=fgb1CN3MoFdkTvtl" rel="nofollow">https://youtu.be/bAP1EkkPKSk?si=fgb1CN3MoFdkTvtl</a>
1731676781
David M.
Pro
API Scripter
I'm just here to say bravo to your incredible in-person game setup! Really top-notch immersion. That certainly took a lot of effort to implement, but the results are fantastic!
David M. said: I'm just here to say bravo to your incredible in-person game setup! Really top-notch immersion. That certainly took a lot of effort to implement, but the results are fantastic! You have no idea how much that means to me. Im guessing you watched my demo? That's less than half of what Ive done over the past year of working on this. It's a labor oof love
1734571189
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
FWIW, sendPing on Jumpgate is now fixed.
1734583828
timmaugh
Pro
API Scripter
Going to second what David said. That's impressive game setup, my person!
timmaugh said: Going to second what David said. That's impressive game setup, my person! Thanks so much. I owe it all to you guys. Here is a hacky, super incomplete demo. There’s far more. I even turned one screen into a sci-fi clone of panzer general 2.&nbsp; 7min demo&nbsp; <a href="https://youtu.be/bAP1EkkPKSk?si=jGdOfmdiogh4Ol7c" rel="nofollow">https://youtu.be/bAP1EkkPKSk?si=jGdOfmdiogh4Ol7c</a> Panzer General Clone 30sec Airstrike&nbsp; <a href="https://imgur.com/gallery/rL99lpr" rel="nofollow">https://imgur.com/gallery/rL99lpr</a> 30sec Mechs!&nbsp; <a href="https://imgur.com/gallery/ylS8GJP" rel="nofollow">https://imgur.com/gallery/ylS8GJP</a>
timmaugh said: Going to second what David said. That's impressive game setup, my person! timmaugh &nbsp;said: Going to second what David said. That's impressive game setup, my person! Thanks so much. I owe it all to you guys. Here is a hacky, super incomplete demo. There’s far more. I even turned one screen into a sci-fi clone of panzer general 2.&nbsp; 7min demo&nbsp; <a href="https://youtu.be/bAP1EkkPKSk?si=jGdOfmdiogh4Ol7c" rel="nofollow">https://youtu.be/bAP1EkkPKSk?si=jGdOfmdiogh4Ol7c</a> Panzer General Clone 30sec Airstrike&nbsp; <a href="https://imgur.com/gallery/rL99lpr" rel="nofollow">https://imgur.com/gallery/rL99lpr</a> 30sec Mechs!&nbsp; <a href="https://imgur.com/gallery/ylS8GJP" rel="nofollow">https://imgur.com/gallery/ylS8GJP</a>