Permissions on a command

i’m trying to set some permissions on a command , for example /ad , to be used only for someone who has a specific group ( vRP ) or standalone with steam id , but i can’t really figure out how to do it , any help?

2 Likes

Please ask this question in the original forum topic of the resource you are using that takes care of permissions.

Try taking a look at these.

https://runtime.fivem.net/doc/natives/#_0x5FA79B0F

Heres an example of the code, just put it into one of your commands

Server.lua

RegisterCommand("cmd", function(source, args, rawCommand)
    if IsPlayerAceAllowed(source, "fax.cmds") then
        TriggerClientEvent("chatMessage", source, "Output message! Permissions passed!")
    else
        TriggerClientEvent("chatMessage", source, "^1Insufficient Permissions.")
    end
end)

So the

The if IsPlayerAceAllowed(player, "fax.cmds") is the start you need to have. Also, include an else so people that don’t have the perms will get that other event. In this case, it refers to the client.lua which has an event in it. And of course, make sure there is an end.

This is for ace perms so than in the server config for this script to work you need:

add_ace group.admin fax allow                                # allow all commands for FAXES Script admins 
add_ace group.moderator fax allow                        # allow all commands for FAXES Script moderators
add_ace group.moderator fax.cmds deny              # disallow FAXES Script Perms for moderators

add_principal identifier.steam:HEX-ID-HERE group.admin

Hope this helps.

5 Likes

Thank you very much.

2 Likes

I just updated my solution above, making it updated.

2 Likes

what does FaxNoSpeaky means? @FAXES

1 Like

its an ace name, lemme fix my example

So, in this case if I have this permission:
add_ace group.moderator fax.cmds allow
I would be able to use it?
because of fax.cmds
@FAXES

4 Likes

hmmm,
works like a charm but
when I use .admin as group I get the permissions to it
(that’s not bad) and when I make myself user and do a reconnect I have all permissions. Only a restart helps.
So for everyone who wants that everything works REALLY good, I would say that it is better to use a CUSTOMNAME.group for this.
Because there are many bugs if I use .admin or something like that.
(example: when a user joins and does a reconnect he has rights to use it…) <<This was tested on a brand new server! So it is not another ressource that does that!

Have a nice day! and get a :hamburger: :slight_smile:

1 Like

Hey guys !! i just did it all in your script and that was solved BUT someone can ( /Spawn Khanjali ) in my server, Please i need your help man

did you find solution for that?

We downloaded a fireworks script that allows someone to do /sf to place a box of fireworks on the ground and it will shoot them off. By default, this was open to everyone but I want to restrict it to staff and trusted civs so if if I understand the info at the top of the thread correctly, I need to make the register command function look like this?

 RegisterCommand("sf", function()
 	if IsPlayerAceAllowed(source, "fireworks") then
 		TriggerEvent('frobski-fireworks:start')
 	else
 		TriggerClientEvent("chatMessage", source, "^1You do not have permissions to use this")
    end
 end)

(I added lines 2,4,5,&6 per the guide above).
And then I just need to add_ace Staff.Group "fireworks" allow to my ace perms file?

https://prnt.sc/umrhqf how can add permission there?

edit the falses to true on the end of the command code

I am having the same question

Yo ik this is off topic but how did you remove the background off your chat

add_ace group.admin inventory.openinventory allow

Thanks

can someone help me restrict this command to a group.leo
if sm[1] == “/hospital” then