Permissions required to use a command

I am using a script that create a command (setped id model) to set someone a ped. I need it to work only for permitted people. These are the .Lua files.
Server
main.lua (38.5 KB)
Client
main.lua (89.4 KB)

Add your permitted people to a group using principals and then give this group permission to use the command. You add the principal and ace configuration to your .cfg file where you start resources, or use that file to load a separate .cfg file that contains your permissions setup.

add_principal identifier.license:insert_players_license_identifier_here group.setped
-- repeat for each user you access command

add_ace group.setped command.setped allow

setup your command to require permission

RegisterCommand('setped', function(source, args)
-- your stuff
end, true) -- This sets the command to require permission

There are many other posts on the forum about this, search for Command Permission or something to that effect.

The server and client file could use a lot of optimization, you do not need to use if/else if statements like this and repeat the same functions over and over again if setup properly. In the client file you do not need to register and handle an event for every single ped name, you can do this with a single event and just send the pedname as a param to that single event. You also do not need the first command param to be an id, the source of the player that executes the command is already available. You’d only want that if you have plans to execute that command from rcon/server console on a specific id, or you’re planning on anyone that executes the command being allowed to put someone else’s id and have it run on their client.

I’m still learning and me knowledge doesnt ley me understand how do you mean I can optimize server and client files. It would be amazing if you could send me and example