From 8a832aee3bed36c734d1a34705289c9a7b2a9416 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 17 Feb 2020 23:07:18 +0100 Subject: [PATCH] Implemented adding chat suggestions, closes #512 --- client/main.lua | 9 +++++++++ server/functions.lua | 2 ++ 2 files changed, 11 insertions(+) diff --git a/client/main.lua b/client/main.lua index caccc586..fd2fc759 100644 --- a/client/main.lua +++ b/client/main.lua @@ -328,6 +328,15 @@ AddEventHandler('esx:createMissingPickups', function(missingPickups) end end) +RegisterNetEvent('esx:registerSuggestions') +AddEventHandler('esx:registerSuggestions', function(registeredCommands) + for name,command in pairs(registeredCommands) do + if command.suggestion then + TriggerEvent('chat:addSuggestion', ('/%s'):format(name), command.suggestion.help, command.suggestion.arguments) + end + end +end) + RegisterNetEvent('esx:removePickup') AddEventHandler('esx:removePickup', function(id) ESX.Game.DeleteObject(pickups[id].obj) diff --git a/server/functions.lua b/server/functions.lua index e9f0d5be..0abdb9a7 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -36,6 +36,8 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion) if suggestion then if not suggestion.arguments then suggestion.arguments = {} end if not suggestion.help then suggestion.help = '' end + + TriggerClientEvent('chat:addSuggestion', -1, ('/%s'):format(name), suggestion.help, suggestion.arguments) end ESX.RegisteredCommands[name] = {group = group, cb = cb, allowConsole = allowConsole, suggestion = suggestion}