ESX Twitter? Need Assistance [Solved]


#1

Hey, Im trying to have the twitter command display their first and last name besides the players steam username
here is the script below, I’ve tried multiple different methods nothing seems to be working I know its all there just facepalm super hard cause I can’t seem to figure it out if someone could assist I’d appreciate it

function getIdentity(source, callback)
  local identifier = GetPlayerIdentifiers(source)[1]
  MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", {['@identifier'] = identifier},
  function(result)
    if result[1]['firstname'] ~= nil then
      local data = {
        identifier    = result[1]['identifier'],
        firstname     = result[1]['firstname'],
        lastname      = result[1]['lastname'],
        dateofbirth   = result[1]['dateofbirth'],
        sex           = result[1]['sex'],
        height        = result[1]['height']
      }
      callback(data)
    else
      local data = {
        identifier    = '',
        firstname     = '',
        lastname      = '',
        dateofbirth   = '',
        sex           = '',
        height        = ''
      }
      callback(data)
    end
  end)
end

AddEventHandler('chatMessage', function(source, name, message)
  getIdentity(source, function(data)
    if string.sub(message, 1, string.len("/")) ~= "/" then
      TriggerClientEvent("sendProximityMessage", -1, source, data.firstname, message)
    end
  end)
  CancelEvent()
end)

TriggerEvent('es:addCommand', 'me', function(source, args, user)
    table.remove(args, 1)
    getIdentity(source, function(data)
      TriggerClientEvent("sendProximityMessageMe", -1, source, data.firstname, table.concat(args, " "))
    end)
end)

TriggerEvent('es:addCommand', 'do', function(source, args, user)
    table.remove(args, 1)
    getIdentity(source, function(data)
      TriggerClientEvent("sendProximityMessageDo", -1, source, data.firstname, table.concat(args, " "))
    end)
end)

TriggerEvent('es:addCommand', 'tweet', function(source, args, user)
  table.remove(args, 1)
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] (^5@" .. GetPlayerName(source) .. "^0)", {30, 144, 255}, table.concat(args, " "))
end, {help = 'Send a tweet. [IC]'})

TriggerEvent('es:addCommand', 'ooc', function(source, args, user)
  table.remove(args, 1)
  TriggerClientEvent('chatMessage', -1, "OOC | " .. GetPlayerName(source), {128, 128, 128}, table.concat(args, " "))
end, {help = 'Send an out of character message to the whole server.'})

function stringsplit(inputstr, sep)
  if sep == nil then
    sep = "%s"
  end
  local t={} ; i=1
  for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
    t[i] = str
    i = i + 1
  end
  return t
end

Currently looks like this
image
Would like it to be like this
[Twitter](@FirstName LastName): testing


#2

I’ve tried this format also
doesnt seem to do anything

TriggerEvent('es:addCommand', 'tweet', function(source, args, user)
  table.remove(args, 1)
    getIdentity(source, function(data)
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] (^5@" .. source, data.firstname .. "^0)", {30, 144, 255}, table.concat(args, " "))
end, {help = 'Send a tweet. [IC]'})

#3

Function TriggerClientEvent() for 'chatMessage' accepts 3 additional arguments: name, color and message, you have 4. Look at the comma between source and data.firstname

You should have a syntax error on the server console.


#4

don’t I need source and data.firename to be separated though


#5

You don’t need it entirely. I think what you’re trying to accomplish is this:
TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] (^5@" .. data.firstname .. data.lastname"^0)", {30, 144, 255}, table.concat(args, " "))

You concatenate two strings using ..


#6
TriggerEvent('es:addCommand', 'tweet', function(source, args, user)
  table.remove(args, 1)
  getIdentity(source, function(data)
  TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] (^5@" .. data.firstname .. " " .. data.lastname  "^0)", {30, 144, 255}, table.concat(args, " "))
end, {help = 'Send a tweet. [IC]'})

#7

How’d that work for you? :slight_smile:


#8

Did that and nothing showed up

TriggerEvent(‘es:addCommand’, ‘tweet’, function(source, args, user)
table.remove(args, 1)
getIdentity(source, function(data)
TriggerClientEvent(‘chatMessage’, -1, “^0[^4Twitter^0] (^5@” … data.firstname … " " … data.lastname “^0)”, {30, 144, 255}, table.concat(args, " "))
end, {help = ‘Send a tweet. [IC]’})

added a end cause it was expecting one then nothing showed up also


#9

I still don’t seem to have luck with it


#10

Ok, this is not only 1 file which you need to replace here is link for the downloading my custom twitter (Esx_Rpchat) that have some modifications like you can write special alphabets on twitter (äöå)


#11

Thank you so much :slight_smile: You have helped me a great deal, I seee where it was wrong and I appreciate you helping me see what I needed to do thank you :slight_smile: