mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
chat: add suggestions for commands, reduce 'joined' spam, make server prints white
This commit is contained in:
@@ -34,7 +34,7 @@ AddEventHandler('__cfx_internal:commandFallback', function(command)
|
||||
end)
|
||||
|
||||
-- player join messages
|
||||
AddEventHandler('playerConnecting', function()
|
||||
AddEventHandler('chat:init', function()
|
||||
TriggerClientEvent('chatMessage', -1, '', { 255, 255, 255 }, '^2* ' .. GetPlayerName(source) .. ' joined.')
|
||||
end)
|
||||
|
||||
@@ -44,4 +44,36 @@ end)
|
||||
|
||||
RegisterCommand('say', function(source, args, rawCommand)
|
||||
TriggerClientEvent('chatMessage', -1, (source == 0) and 'console' or GetPlayerName(source), { 255, 255, 255 }, rawCommand:sub(5))
|
||||
end)
|
||||
|
||||
-- command suggestions for clients
|
||||
local function refreshCommands(player)
|
||||
if GetRegisteredCommands then
|
||||
local registeredCommands = GetRegisteredCommands()
|
||||
|
||||
local suggestions = {}
|
||||
|
||||
for _, command in ipairs(registeredCommands) do
|
||||
if IsPlayerAceAllowed(player, ('command.%s'):format(command.name)) then
|
||||
table.insert(suggestions, {
|
||||
name = '/' .. command.name,
|
||||
help = ''
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
TriggerClientEvent('chat:addSuggestions', player, suggestions)
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('chat:init', function()
|
||||
refreshCommands(source)
|
||||
end)
|
||||
|
||||
AddEventHandler('onServerResourceStart', function(resName)
|
||||
Wait(500)
|
||||
|
||||
for _, player in ipairs(GetPlayers()) do
|
||||
refreshCommands(player)
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user