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

Give api permission to players

So, basically I'm toying with this script: <a href="https://app.roll20.net/forum/post/4714258/script-faerun-calender-and-down-day-counter/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/4714258/script-faerun-calender-and-down-day-counter/?pagenum=1</a> A simple calendar, I would like to modify it to allow players to use the "log" function. What it does is basically ask for the note to write, create an handout ( or editing one if it's not the first time the handout is being writed ), prefixing the date and hour ( which should be some variables in the api ) and post the note. Right now only the GM can use the "log" function, and for the life of me I cannot understand what to change to let the players use it. It would be cool for them to take notes and get them automatically sorted with dates. Heeelp ! :) My guess is that on line 64: if(playerIsGM(msg.playerid)){ &nbsp; &nbsp; switch(args[0]) {... It starts to code the menu for the GM, with boxes connected to api script and this should be edited somehow, but I'm a total beginner and I'm really struggling
1613309710
The Aaron
Roll20 Production Team
API Scripter
You're right on the money. The easiest thing you can do is replace playerIsGM(...) with true: if(true){ That will give them access to all the commands. Slightly more complicated is removing the if block entirely, or moving the check to individual commands.&nbsp;
1613310322

Edited 1613310718
timmaugh
Pro
API Scripter
You are correct that that line handles the test of whether the person executing the command is a GM. Everything inside of the { } is conditional on that test passing... if (playerIsGM(msg.playerid)) { &nbsp; &nbsp; // ... conditionally executed code } Inside that is a switch(){} statement, which is watching for what sort of command came in. But that's only running for the GM. So go to the ending brace of the if() statement, and after that you will see an else . if (playerISGM(msg.playerid)) { &nbsp; &nbsp; switch (args[0]) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // ... cases to evaluate &nbsp; &nbsp; } } else { &nbsp; &nbsp; // ... stuff executed if the player is NOT a GM } Right now, the only thing that side of the if branch further tests for is if the command began with !cal . This is where you want to add the permission to do what you want them to be able to do. I'm not sure which of the cases of the switch() statement you want to allow for players, but, as an example, if you wanted to include the 'setdown' ability, the whole else block might look like: // ... previous stuff } else { &nbsp; &nbsp; if (args[0]=='!cal') { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;showcal(msg); &nbsp; &nbsp; } else if (args[0] === '!setdown') { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var down = Number(args[1]); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state.Calendar.now.down = down; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getdown(down); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;calmenu(); &nbsp;&nbsp;&nbsp;&nbsp;} } Of course, if that nested if() test gets too branchy, you might write it as a switch, instead. =D
Ok guys thanks, with your help I managed to fixed it. I added the }else if (args[0]=='!log') { &nbsp; &nbsp; &nbsp; &nbsp; log(msg); since the !log function was the one I was intrested in, and then created attributes macro for every player like this: ?{Menu? |Show Day, !cal |Log in the Journal, !log&amp;#44; yes&amp;#44;"name of every pc:" ?{Notes?: &amp;#125; } It's not elegant or pretty from a "coding" prospective, but it works i guess :) thanks