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

GM only api commands

February 07 (11 years ago)
When you get a chat:message event, is it somehow possible to determine if the GM sent the message without relying on a hardcoded player id?
February 07 (11 years ago)
Konrad J.
Pro
API Scripter
I don't think there is anything to do that yet. The best would be to compare d20userid in the player object to a script variable holding the gm's userid similar to what you suggested in your question. That's how I do it in my scripts when I have commands only the GM should be able to run. It would be nice to have a helper function like IsGM() that returns true or false? You could make your own of course using the d20userid and then if roll20 ever supplies a function you just have to change your one function and the script still works great without much of a change.
February 07 (11 years ago)
Konrad J.
Pro
API Scripter
Oops, of course you would use the chat:message property playerid for this. :(
February 07 (11 years ago)

Edited February 07 (11 years ago)
Lithl
Pro
Sheet Author
API Scripter

No, there is no means to do so without some hardcoding. Some people write scripts looking for a name ending in " (GM)", but that only works if the GM is speaking OOC, and a player could potentially change their display name to end with (GM). Hardcoding the d20userid and comparing to that is probably optimal, because it can't be spoofed, and it's a short number instead of a long, indecipherable string (like player.id).

If you're writing a script to be released to the greater R20 community, please remember that campaigns can have multiple GMs. You should probably iterate over an array of hardcoded ids, even if the array only contains 1.

February 07 (11 years ago)
Alex L.
Pro
Sheet Author
Its been requested a few times that we need a way to get a list of GMs as well as know who made the other events trigger so that we can get some sort of propper permissions in to scripts.
February 07 (11 years ago)

Brian said:

No, there is no means to do so without some hardcoding. Some people write scripts looking for a name ending in " (GM)", but that only works if the GM is speaking OOC, and a player could potentially change their display name to end with (GM). Hardcoding the d20userid and comparing to that is probably optimal, because it can't be spoofed, and it's a short number instead of a long, indecipherable string (like player.id).

If you're writing a script to be released to the greater R20 community, please remember that campaigns can have multiple GMs. You should probably iterate over an array of hardcoded ids, even if the array only contains 1.


playerid is only available during a chat event, but then I guess you lookup the playerid and get the d20userid and compare it to the hard coded d20userid. I see. I was just going to make a chat command that logs your playerid so you then know what it is and can hard code it, but the d20userid looks likes its easy for players to get at for you so much better idea! Great!

I didn't even realize you can have multiple GMs, thanks! I'll make an array for sure!
February 07 (11 years ago)
Konrad J.
Pro
API Scripter
Oops, thats what you get for logging in as two different users for testing. I posted that as my 2nd account. :(

Konrad (not Morval)
February 07 (11 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Create a hand out called GMs..... players with edit rights to that sheet are now your GMS.

You can now bump people up and down in the campaign anytime you like.