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

[Help] Button that can be clicked only by the original user

September 23 (8 years ago)
Havoc
Sheet Author
API Scripter
Let's say I have rolls made by the API and sometimes when the roll is failed, it has a button to do a reroll. I want this reroll to be made only by the original user, other's wouldn't be able to start the script. Is there a way to check this?
September 23 (8 years ago)
Tetsuo
Forum Champion
One solution is have it whisper the reroll button to the gm on a failed roll. Then only the original roller and the GM could reroll
September 23 (8 years ago)

Edited September 23 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Alternatively, if you need everyone to see the roll, simply pass the playerid of the original player as part of the created roll buttons command, then compare that to the playerid of the player clicking the button in your script.
September 23 (8 years ago)
Havoc
Sheet Author
API Scripter

Scott C. said:

Alternatively, if you need everyone to see the roll, simply pass the playerid of the original player as part of the created roll buttons command, then compare that to the playerid of the player clicking the button in your script.

So obvious...

Thanks! It worked like a charm.
September 23 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Happy to help
September 23 (8 years ago)
The Aaron
Pro
API Scripter

Scott C. said:

Alternatively, if you need everyone to see the roll, simply pass the playerid of the original player as part of the created roll buttons command, then compare that to the playerid of the player clicking the button in your script.
You could also store the id of the original player along with a random number/hash in the script in a map, then pass that hash to the command.  That would allow you to let the original person do the reroll, have a public button, and not have someone change the id maliciously.  You could also hang other details in that map (like the original status of the roll, what the actual action is, etc) further preventing shenanigans. I use this technique in MutantYearZero, if you wanna look at an example. =D

September 23 (8 years ago)
The Aaron
Pro
API Scripter
I use a monotonically increasing integer for my hash, but you could use whatever.  It also lets me prevent them from trying to reroll more times than they are allowed, etc.
September 24 (8 years ago)
Havoc
Sheet Author
API Scripter
Thanks for the idea and example! I used a random string (5 characters) for this check. Now it works perfectly.
September 24 (8 years ago)
The Aaron
Pro
API Scripter
No problem!  =D. Happy Rolling!