/tweet command for esx_rpchat

I am trying to convert this standalone command to work with RP chat which will allow for a tweet command with a custom handle. I am trying to create a twt command to send anonymous tweets in short. or if anyone can point me in the direction to make a second twt command for rp chat to send anonymous tweets this will be used for the criminals on my server.

ex:
/twt Anonymous Hostile

Thanks for the help

1 Like

there is a thousand different places on the forum that literally show the exact thing to do, how about you search the forum next time

I have searched the forum and have seen the many twitter commands however I am looking for help with the coding for the anonymous handle part as RP chat ties into esx Identity.

You would probably be better off creating your own command.

Yep I figured this out … This can be closed :slight_smile: Thanks for the assistance

1 Like

How did you do it?

1 Like
RegisterCommand("tweet", function(source, args, rawCommand)
    TriggerClientEvent("chatMessage", -1, "TWITTER", {255,0,0}, GetPlayerName(source) ..table.concat(args, " "))
end)
1 Like

Nice! So how does it work, it does it post, (Tweet) @Anonymous?

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.

1 Like

Untitled

how to disable admin in chat?

sorry bad english

How to repair? I copyright your text #8 and when I write /anon so I write 2 text anon and local text

Just put that under the original form of tweet , and its work :slight_smile:

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)

That is because you are using two chat scripts. Disable the default

Bad advice, never disable the default chat resource or any resource in [system] for that matter. You should use a theme instead and the built in functions to adapt it to your liking.

I added twitter to my phone so when i send a message on my phone in comes in the chat
This is what I did:
in gcphone i replaced RegisterServerEvent('gcPhone:twitter_postTweets') with

RegisterServerEvent('gcPhone:twitter_postTweets')
AddEventHandler('gcPhone:twitter_postTweets', function(username, password, message)
  local sourcePlayer = tonumber(source)
  local srcIdentifier = getPlayerID(source)
  TwitterPostTweet(username, password, message, sourcePlayer, srcIdentifier)
  TriggerClientEvent('chat:addMessage', -1, {
      template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(28, 160, 242, 0.6); border-radius: 3px;"><i class="fab fa-twitter"></i> @{0}:<br> {1}</div>',
      args = { username, message }
  })
end)
only when you dont register a account you also can send a message and you see than in chat @ 
How can i do that you need to register a account before you can send a message?