if you use “esx_rpchat” you can use this code. Just add this into server/Main.lua
RegisterCommand('anontwt', function(source, args, rawCommand)
if source == 0 then
print('esx_rpchat: you can\'t use this command from rcon!')
return
end
args = table.concat(args, ' ')
local name = GetPlayerName(source)
if Config.EnableESXIdentity then name = GetCharacterName(source) end
TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', 'Anonymous'), args }, color = { 0, 153, 204 } })
print(('%s: %s'):format(name, args))
end, false)
Now you need to add the command in client/Main.lua
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/twt', _U('twt_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
TriggerEvent('chat:addSuggestion', '/anontwt', _U('twt_help'))
TriggerEvent('chat:addSuggestion', '/me', _U('me_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
TriggerEvent('chat:addSuggestion', '/do', _U('do_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
end)
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
TriggerEvent('chat:removeSuggestion', '/twt')
TriggerEvent('chat:removeSuggestion', '/anon')
TriggerEvent('chat:removeSuggestion', '/me')
TriggerEvent('chat:removeSuggestion', '/do')
end
end)
I added this into that script. Works well. I take no credit in esx_rpchat but if you do use it there you go.