[Release] pQueue, a FiveM Queue with a Discord based priority system, written in JS and using Adaptive Cards

pQueue

This is a FiveM server queue with discord based priority built on @Space_Man’s Discord API.
You NEED sPerms and sDiscord for this resource to work.
The script will also reject users who don’t have a Discord ID connected to their account.

Installation

Copy or download the resource here, move it to your resource folder, and add ensure pQueue to your server.cfg

Config

The config (queue.config.json) file can be found in the src folder.
In the config file you will find three different sections the first being the settings section:

"settings": {
        "debug": false,
        "alwaysUse": false,
        "noDiscordRejectMsg": "Change Me",
        "graceListTime": 5
    }

debug Will enable debug messages in your console, such as: users being added to the queue and their priority, users being removed from the queue and the queue itself.

alwaysUse If set to true the queue will ALWAYS be used, regardless of the number of people in server, this will only allow one user to connect at a time. If set to false the queue will only take effect if there’s < 5 open slots.

noDiscordRejectMsg The message presented to a user when rejected for not having a Discord ID.

graceListTime How long a user that has just disconnect/crashed has too reconnect before they will be put at the end of the queue again. (In minutes)

The next section is for customizing the Adaptive Card UI presented to users while in the queue. Should be obvious what the different settings do, see the screenshot or the comments down below if you are still unsure.
Note: If you copy this over to your config file the comments MUST be removed

"adaptiveCard": {
        "card_title_isVisible": false, // decides whether the title is visible, defaults to false as you will most likely have your community name in the header.
        "card_title": "Title", // the cards title, recommended use is for your community's name.
        "card_header": "https://someurl.com/somepic.png", // a link to the header picture
        "card_description": "card description", // a short description can be used for messages such as "While you're waiting check out our Discord"
        "button1_title": "Button 1", // The title for the first button
        "button1_url": "https://someurl.com", // The URL the first button should open.
        "button2_title": "Button 2", // The title for the second button
        "button2_url": "https://someurl.com/" // The URL the second button should open.
    },

Alt text

The third and the final section is the most complicated to set up as it requires an understanding of how sPerms and sDiscord works, as well as some experience with working with objects in JS. But if you follow all the following steps you should be able to set everything up without problems:

  1. Download and set up sDiscord and sPerms

  2. Add the roles you want to set up priority for in the sPerms config file (src/config.json).
    In the config file the individual roles are divided into categories, example configuration:

{
  "discordRoles": {
    "administration": {
      "owner": "Discord Role ID", 
      "coOwner": "Discord Role ID",
      "headDev": "Disord Role ID"
    },
    "staff": {
      "admin": "Discord Role ID",
      "mod": "Discord Role ID"
    }
  },
  "needDiscord": false
}

When sPerms builds the perms object it checks each individual role, but also the different categories (if you have one role in a category, the category will return as true). We can see the built perms object by going into the client script in sPerms (src/client/index.js) and adding console.log(perms) to the sPerms:setPerms event, this will log the object in the player’s console when they first spawn in:

Alt text

  1. Add the roles you want to set up for priority to the pQueue config file (queue.config.json).
{
  "category": "category",
  "role": "roleName",
  "prio": 1
}

category If you want to check for an individual role this should be the category the role is under, ex. staff. If you want to check for a whole category this should just be “category”

role If you are checking for a role, this should be the name of the role, ex. owner. If you are checking a whole category it should be the name of the category ex. staff.

prio This is the priority, the lower the number the higher the priority. (Use whole numbers)

Here is an example for how you could set up the priority:

{
    "category": "administration",
    "role": "owner",
    "prio": 1
},
{
    "category": "category",
    "role": "administration",
    "prio": 2
},
{
    "category": "category",
    "role":  "staff",
    "prio": 3
}

NOTE: Make sure you sort the priority from highest to lowest, if not the script might not use the highest priority if a user has multiple roles

Lastly, set defaultPrio to a higher number than all the priority roles/categories, in the last example it would be 4 or higher.

That should be it, if you run into any trouble while configuring the script let me know and I’ll help you out.

11 Likes

Seems like I’ve been using an older version of sPerms, and the event that I’ve been using to get the permissions is removed. Currently working with Space to get it fixed.
For now adding this to the server sided script of sPerms (src/server/index.js), should fix any eventual issues until we can get a fix implemented:

onNet('sPerms:getPerms', (source, cb) => {
  getPerms(source, perms => {
    cb(perms);
  })
})
1 Like

Does this have a grace period for people where they get like a 5 minute window to reconnect and be put at the front of queue? If not, is this something you could implement? :slight_smile:

@syko Not a feature at the moment, but it shouldn’t be very hard to do, I’ll take a look and implement it when I find a good solution.

2 Likes

@devpetrikov Awesome to hear! I hope to change queue systems and I know that would be one feature my community would be disappointed to know disappeared, thank you for your work :slightly_smiling_face:

Will test it, thank you for share is amazing!

@strianodev Thanks :slight_smile: Lmk if you have any questions

@syko Sorry for taking so long, been busy. Just committed a update to the GitHub with a “gracelist” implementet, you can customize the time in the config file under graceListTime (In minutes)

1 Like

sPerms has been updated to include the event, download the newest version here

Appreciate the grace period update :slight_smile:

We having a problem though, our maxclients is 100 we have alwaysUse set to false because setting this to true puts everyone in a queue all the time even when there is no one on the server, and now the queue system is letting more then 100 people into server.

1 Like

Yea, it’s a know issue, it’s because GetNumPlayerIndices() doesn’t update before the player is spawned. Currently the queue is set to activate whenever there’s less than 5 open slots, so if more than 5 people connect at once it will allow more than 100 total players. I haven’t been able to find a good solution for this but I’m open to suggestions :slight_smile:

Would there be any issues using this and a whitelist system integrated with txAdmin? Would one override another Love the UI and the system, just ensuring compatibility.

1 Like

Haven’t tested it but I don’t think that should be an issue

Can somone help me?

What does your queue.config.json file look like?

{
“settings”: {
“debug”: true,
“alwaysUse”: true,
“noDiscordRejectMsg”: “Nao conseguimos encontrar o teu Discord ID,por favor verifica se tens o discord aberto e se estas loggado.” ,
“graceListTime”: 2
},
“adaptiveCard”: {
“card_title_isVisible”: true,
“card_title”: “Austin RP”,
“card_header”: “”,
“card_description”: " ‎‎‌",
“button1_title”: “My discord”,
“button1_url”: “https://www.twitch.tv/”,
“button2_title”: “Discord”,
“button2_url”: “https://discord.gg/
},
“priority_setup”: [
{
“category”: “administration”,
“role”: “Fundador”,
“prio”: 1
},
{
“category”: “category”,
“role”: “Membro”,
“prio”: 4
}
“defaultPrio”: 4
}

You’re missing ], before “defaultPrio”: 4
Try this

{
   “settings”: {
       “debug”: true,
       “alwaysUse”: true,
       “noDiscordRejectMsg”: “Nao conseguimos encontrar o teu Discord ID,por favor verifica se tens o discord aberto e se estas loggado.” ,
       “graceListTime”: 2
       },
   “adaptiveCard”: {
       “card_title_isVisible”: true,
       “card_title”: “Austin RP”,
       “card_header”: “”,
       “card_description”: " ‎‎‌",
       “button1_title”: “My discord”,
       “button1_url”: “https://www.twitch.tv/”,
       “button2_title”: “Discord”,
       “button2_url”: “https://discord.gg/”
   },
   “priority_setup”: [
       {
           “category”: “administration”,
           “role”: “Fundador”,
           “prio”: 1
       },
       {
           “category”: “category”,
           “role”: “Membro”,
           “prio”: 4
       }
   ],
       “defaultPrio”: 4
}

Tank u 4 the support.I fixed the problem!I can’t join my localhost server.Its because os the debug mode?

image

Do you have sPerms and sDiscord installed?