vPerms
General¶
vPerms is a real time permission system utilizting vDiscord. The script was originally created by SpaceTheDev (forums, github), so if you enjoy the script please show him some love. The only changes I have made to the script is adding some additional customizability in terms of the role hierarchy (adding subcategories), and making some minor changes to make it work with vDiscord
. Check out the original release here.
The script is event based, meaning that it allows for real-time roles (no need for relogging or restarting the server for perms to update!). The perms are based on discord roles.
Demo video:¶
Installation¶
-
Install and configure
vDiscord
, if you run into problems check out the docs. -
Download or clone the resource from this repository.
-
Move
vPerms
into your resource folder and addensure vPerms
to your server.cfg.
Warning
You have to configure the script before running it.
Configuration¶
-
Navigate to src/config.perms.json and open it.
-
Change the categories/subcategories/roles to suit your needs. There's no limits to how many you can add. Watch the video below for a breakdown of how the permissions should be set up.
Config breakdown:¶
Exports¶
getPlayerPerms¶
Allows you to get the perms of a player (Server side).
Function
const perms = getPlayerPerms(source);
Parameter | Type | Description |
---|---|---|
source |
Player source | Source of the player you want to get perms for. |
Example Code
Config file used for the example:
{
"permSetup": {
"staff": {
"adminstration": {
"owner": "ID goes here",
"admin": "ID goes here"
},
"moderation": {
"mod": "ID goes here",
"trial_mod": "ID goes here"
},
"developer": "ID goes here"
}
}
}
const perms = getPlayerPerms(source);
console.log(perms)
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}
#To-come
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}
#To-come
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}
Events¶
setPerms¶
Event triggered when perms are set for a user (Client side).
Function
onNet('vPerms:setPerms', ( perms ) => { } );
Parameter | Type | Description |
---|---|---|
perms |
Object | Object containing all permissisons for the user |
Example Code
Config file used for the example:
{
"permSetup": {
"staff": {
"adminstration": {
"owner": "ID goes here",
"admin": "ID goes here"
},
"moderation": {
"mod": "ID goes here",
"trial_mod": "ID goes here"
},
"developer": "ID goes here"
}
}
}
onNet('vPerms:setPerms', ( perms ) => {
console.log(perms);
});
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}
#To-come
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}
#To-come
Output
{
category: {
staff: true / false
},
subcategory: {
adminstration: true / false,
moderation: true / false
},
staff: {
adminstration: {
owner: true / false,
admin: true / false
},
moderation: {
mod: true / false,
trial_mod: true / false
},
developer: true / false
}
}