Implemented adding chat suggestions, closes #512

This commit is contained in:
ElPumpo
2020-02-17 23:07:18 +01:00
parent 4b648a8bef
commit 8a832aee3b
2 changed files with 11 additions and 0 deletions
+9
View File
@@ -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)
+2
View File
@@ -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}