[How-To] Whitelist anything in a resource [Steamhex and Ace Permissions]

How to whitelist anything is any resource


In this short tutorial, you will learn how to add a whitelist to any aspect of a resource, using either a JSON file, or Ace Permissions. Once you have implemented either of these methods, it is as simple as wrapping your code in IF statements. For your convenience, code snippets have been provided, and some examples given at the end.

Prerequisites:

  • A basic understanding of LUA
  • A basic understanding of how resources are created
  • A very basic understanding of JSON syntax
    • Enough to know where commas need to go as to not break your file.

JSON Whitelist

To add a JSON whitelist to your resource, the first thing you will need to do is create the whitelist file. To do this, create a new file inside your resource folder, and name it something like whitelist.json. Once you have done this, open up the __resource.lua for your resource, and if you do not have a files section, add one, like below:


Once you have done this, open your JSON file, and add the following code:

This entry will act as our template, which we will build upon. To get someone’s steam hexadecimal (steamhex), go to VacBanned.com, entry the person’s steam profile url, then copy the Steam3 ID (64bit) => (Hex), then replace it will the one from the template, making sure to keep the steam: prefix, as this is required.

The next step is to create entries that we want whitelisting for; in this tutorial, we will be whitelisting two commands, and a client event. The way we will code the whitelist, is that any entries that are included in someone’s whitelist entry, will be granted (unless set to false), and any entries that are not included, will be denied. For example:

In the above example, person1 will have access to command1, command2, and event; person2 will have access to command1 and event; and person3 will only have access to event. This will make more sense later on in the tutorial.

The next step is setting up the whitelist in our client script. To start, add the following code somewhere near the top of one of your client files:

We now need to replicate what we entered in the JSON file; following the example above:

Once you have entered these, ensure they are all set to false, and place the following code below the above code:

This will pass our whitelist object to the server script for populating. Once you have pasted this code, open a server script of your choice, and add the following code to it:


(Make sure to expand this gist)

Once you have done this, head back to your client script, and add this code:

We now have all we need to add whitelist checking to our script. Below is an example using the example set-up from above:


(Make sure to expand this gist)

You have added a JSON whitelist to your resource, well done.


Ace Permissions Whitelist

To add an Ace Permissions whitelist to your resource, the first thing you will need to do is create the whitelist file. To do this, create a new file inside your resource folder, and name it something like whitelist.cfg. Once you have done this, open up your server.cfg file, and add the following line above your resources:

Once you have done this, go back to your resource folder, and open the whitelist.cfg file, once open, paste in this code:

In this tutorial, we will be whitelisting two groups: user and advanced_user. user will have access to command1, while advanced_user will have access to command1, command2, and event. To learn more about how this works, see the “Further Reading” section at the bottom of this post.

The next step is setting up the whitelist in our client script. To start, add the following code somewhere near the top of one of your client files:

Now, we need to replicate what we entered in the CFG file; following the example above:

Once you have entered these, ensure they are all set to false, and place the following code below the above code:

This will pass our whitelist object to the server script for populating. Once you have pasted this code, open a server script of your choice, and add the following code:


(Make sure to expand this gist)

Once you have done this, head back to your client script, and add this code:

We now have all we need to add whitelist checking to our script. Below is an example using the example code above:


(Make sure to expand this gist)

You have now added an Ace Permissions Whitelist to your resource, congratulations.


Examples:

JSON Example

Ace Example

JSON & Ace Example


Further Reading:


I hope you find this helpful; if you have any problems post in the comments below and I will do my best to assist you. If you think you have a better way of implementing either of the above, by all means please let me know and I will be happy to update the post for everyone’s benefit.

:mascot:

10 Likes

Nice tutorial!

2 Likes

Good tutorial and it is going to help me alot when im going to work with ace

1 Like

whitelist.json

my ıd https://steamcommunity.com/profiles/76561198885088067/home

What?

Could either of these be used to allow access to multiple resources? Basically, having to add people to files behind the scenes to be able to use commands is the bane of my existence unless I can do so with a command in game that I can restrict use of the add command to my FTOs. I’m wondering if there is possibly an easy way that I can run a single whitelist file for all of my Fire/EMS personnel to be able to use the pager, siren, and PASS commands vs having to add them manually to both resources? And the ability for my FTOs to be able to do something like “/lsfdadd steam:HEXID” or “/lsfddel steam:HEXID” would be freaking fantastic, I just have no idea how to do something like that.

If you’re using ace, by executing that .cfg file, the permissions automatically become available automatically all resources, so yes :grin:

If you’re using json, you will need to create the file in one resource, and then import that file in all the other resources you want to use it in.

So in the resource manifest of all the other resources (the ones without the original file), add this:

files {
 
   "@NameOfResourceWithOGFile/path/to/whitelist.json"
}

As for a command, take a look at how we implemented it here, you might be able to use this as your base resource with OG whitelist file?

https://github.com/inferno-collection/Fire-EMS-Pager/blob/9b43699f5de49ff720ed4f40aac0479744761bef/[inferno-collection]/inferno-fire-ems-pager/client.lua#L493&L566

https://github.com/inferno-collection/Fire-EMS-Pager/blob/9b43699f5de49ff720ed4f40aac0479744761bef/[inferno-collection]/inferno-fire-ems-pager/server.lua#L140&L160

Im trying to set this up using the new FivePD mod but i cant for the life of me figure this out. i dont see a “client.lua” or “server.cfg” file i could use for either of the 2 permission methods to actually configure the whitelist to only allow certain users access to FivePD

FivePD is a closed source, complied C# resource, so this won’t work sorry. The thread title is a bit misleading in that regard sorry; this will only work for LUA resources.

Oh i see, thanks for getting back to me on this anyways!
i guess we just have to wait for the FivePD guys to implement a permissions or whitelist system of sorts

1 Like

Is this whitelist possible for peds and vehicles?

Not really, unless you restrict how they are spawned in (i.e. through vMeni permissions and disable scriphook).

I didn’t think you could whitelist certain vehicles using vMenu, just vehicle categories.

Hey quick question i look for a way to get some commands Permission for surten jobs can somone help me with that i have no idea of programming but i can understnad some code i see

Thank you!

Having some issues lately with two new scripts I’ve tried to apply this to. Where I’m trying to whitelist a command.

It will not detect the ace permission (based on Discord roles) and I cannot figure out why.

I’m running DiscordAcePerms and Badger_Discord_API and it works for most other resources. Is it because some part of the code is outdated for the Ace perms part of this perhaps?

1 Like