qb-core icon indicating copy to clipboard operation
qb-core copied to clipboard

feat: some useful functions + command permission change

Open Spudgun opened this issue 2 years ago • 3 comments

Command Permissions Simplify command permissions to be one parameter, as opposed to an infinite amount. I believe this is a lot cleaner and simpler way of doing permissions.

I've also searched the entire framework for QBCore.Commands.Add function and no script is utilizing more than one parameter in this function. So it won't have any conflicts with the base framework or issues.

Useful Functions Adds the ability to manipulate tables (copy, copy strict, combine, and search) and grouping of digits together.

QBShared.GroupDigits(1000000, true) -> $1,000,000 QBShared.GroupDigits(1000000, false) -> 1,000,000

Questions (please complete the following information):

  • Have you personally loaded this code into an updated qbcore project and checked all it's functionality? yes
  • Does your code fit the style guidelines? yes
  • Does your PR fit the contribution guidelines? yes

Spudgun avatar Aug 26 '22 07:08 Spudgun

If you're using lua 5.4 you could also just do table.copy(), I don't see much use for a function like this to be added to the core.

So lua 5.4 is enabled in the fxmanifest.lua for qb-core but when using table.copy(tbl) it doesn't seem to work and throws a CLI error of

SCRIPT ERROR: @qb-core/server/commands.lua:65: attempt to call a nil value (field 'copy')

Am I missing something here or is copy not a function of the table object with Lua 5.4?

Spudgun avatar Sep 10 '22 01:09 Spudgun

refactored the permission change to ensure backward compatibility for extra perms, if supplied as per @tom-osborne request.

Spudgun avatar Sep 10 '22 02:09 Spudgun

update the branch and see if it conflicts with the base branch.

r0adra93 avatar Sep 17 '22 08:09 r0adra93