Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Script:GM Code

From Roll20 Wiki

(Redirected from Script:GMCode)
Jump to: navigation, search
API ScriptAuthor: Tristan Beard
Version: 1.0
Last Modified: 2015-01-07
Code: GMCode
Dependencies: None
Conflicts: None

GMCode generates a unique code to authenticate the GM. The code may then be used to identify the GM for elevated privileges in other scripts.

Syntax

!gmcodehelp
!gencode [code]
!clearcode [code]
!custcode [code <new code>]
Formally:

S

→ gmcodehelp

S

→ gencode optional code


S

→ clearcode optional code


S

→ custcode code change


code change

→ ε

code change

code
code


optional code

→ ε

optional code

code


code

integer
Parameter Values
code Optional if no GM code exists, required otherwise. The value of the generated code, which can be seen in the API console log.
new code Value to change the GM code to.

If no GM code exists, the code parameter is optional in all of the above commands, and the script will generate a new code if it is omitted (regardless of which command besides !gmcodehelp is used).

!gencode will regenerate the GM code, while !clearcode will wipe the code out and !custcode will set the code to a specified value.

Example

The GM code is useful for verifying that the user has GM permissions, as the only means to see the code is in the API console log, which is only accessible by a GM. The value of the GM code can be accessed with state.gmcode, which you can then compare against user input to verify identity, similar to a PIN.

on('chat:message', function(msg) {
    var parameters = msg.content.splitArgs(),
        command = parameters.shift().substring(1).toLowerCase();

    if (msg.type === 'api' && command === 'mycommand') {
        if (state.gmcode && parameters[0] === state.gmcode) {
            // GM authenticated
        }
    }
});