Optimize chat suggestions

Original PR from @TassieRPCx

Just removed table.insert for performance
This commit is contained in:
GhzGarage
2021-09-25 01:00:45 -05:00
parent 2b5e9929ca
commit f07fbbcf81
+7 -1
View File
@@ -22,15 +22,21 @@ end
function QBCore.Commands.Refresh(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local suggestions = {}
if Player then
for command, info in pairs(QBCore.Commands.List) do
local isGod = QBCore.Functions.HasPermission(src, 'god')
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
local isPrincipal = IsPrincipalAceAllowed('group.admin', 'command')
if isGod or hasPerm or isPrincipal then
TriggerClientEvent('chat:addSuggestion', src, '/' .. command, info.help, info.arguments)
suggestions[#suggestions+1] = {
name = '/' .. command,
help = info.help,
params = info.arguments
}
end
end
TriggerClientEvent('chat:addSuggestions', tonumber(source), suggestions)
end
end