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

Noob Help with GM-only Time Tracker API

Hello,  I've found very useful API script for me and my group, developed by  Filip Č. Link Problem is, this script is no longer supported or in development (as I understand) and I have very little knowledge of how API scripting is being done. All I need - is to make this script available not only for GM, but for all players. I've found two places in this script that may limit it's usage to GM only. First in function that sends private message (60 line) - it uses variable that is starting with '/w GM ' that is later used in SendChat operator. But I don't know how to change fixed '/w GM ' into something that will identify player that is triggering API and send message to him.  Second place (89 line) I've managed to find is in IF operator it checks for playerIsGM(senderId). I've tried to delete this line entirely, but script immediately stops working at all, as if I've violated some kind of syntax... I would really appreciate if someone with experience in scripting would spend 5-10 mins to check this script and at least tell - if it's at all possible to quickly and easily change it for all players (vs only for GM) or it would require extensive change in code, so I would stop trying.
1553549538

Edited 1553549572
GiGs
Pro
Sheet Author
API Scripter
You should be able to delete line 89. To be clear, change this if (msg.type === 'api' && playerIsGM(senderId) && args.indexOf('!time') === 0) { To this if (msg.type === 'api' && args.indexOf('!time') === 0) { Try that with no other changes . Create a second roll20 account, add it as a player to your game, and try to launch the script with that account. If it doesnt work, there's something missing, and i dont understand why it doesnt work. If it does work, we can deal with the second needed step: change line 85 senderId = msg . playerid , to who = msg.who, and then that /w gm line (line 60) var content = ' /w GM ' to var content = ' /w ' + who + ' ' Hopefully that should do the trick. If not, there's a method that needs a bit more editing, so hope is not lost!
Thank you very much! Step 1 works. :) But Step 2 doesn't. Even GM lost ability to get feedback message, error message is that who is not defined.
1553636547
GiGs
Pro
Sheet Author
API Scripter
I thought that might happen, I'll post the fix for that later when I have time.
Thank you again for your time and effort! :)
1553658921
GiGs
Pro
Sheet Author
API Scripter
Here's the simplest fix: in addition to the two changes suggested above line 85: var content = ' /w ' + who + ' ' and changing this if (msg.type === 'api' && playerIsGM(senderId) && args.indexOf('!time') === 0) { to this if (msg.type === 'api' && args.indexOf('!time') === 0) { make the following two changes: on line 90-ish, change var handleChatMessage = function(msg) {  var args = msg.content, selected = msg.selected;  to var handleChatMessage = function(msg) {  var args = msg.content, selected = msg.selected;  who = msg.who; and on line 21-ish, change var version = 0.3, author = 'Filip Č.'; to var version = 0.3, author = 'Filip Č.', who; you can simply copy from here and paste over the lines in the script. If you add them manually, pay attention to which lines end in commas and which end in semi-colons.
Still doesn't work... {"who":"error","type":"error","content":"Unable to find a player or character with name: undefined"} It seems that it's not so easy :(
1553724261
GiGs
Pro
Sheet Author
API Scripter
weird, it worked for me. Can you start out with a completely fresh script, and go through the steps in my last post, just to be sure.
1553724318
GiGs
Pro
Sheet Author
API Scripter
also can you post the commands you are using to test it, so i can make sure I am testing the same things.