From f07fbbcf8104d444f55d2f7e551306ec38ff0108 Mon Sep 17 00:00:00 2001 From: GhzGarage Date: Sat, 25 Sep 2021 01:00:45 -0500 Subject: [PATCH] Optimize chat suggestions Original PR from @TassieRPCx Just removed table.insert for performance --- server/commands.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/commands.lua b/server/commands.lua index e92c088..d4e59b2 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -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