[Release] MySQL Async Library - 3.3.2

I have spoke to oliverjrose99 i helped him fix it by just downgrading base FiveM server files to the ones on the 10th sep. and use MySQL Async 2.1.1

maybe report the bug instead of reverting artifacts? that doesnt help to get the problem fixed.

Sorry forgot being a helpful community member isnā€™t allowed.

what? iā€™m just telling you to report the issue instead of reverting the artifacts, that would make you an helpful community member.

Please see my edit, recent builds seem to fix it.

yes, 2.1.1 is ok with last FiveM Server (796)

Updated the C# Version

Changes:

  • Added default options for connection strings and mysql_debug, so it should not error anymore, hopefully.
  • SslMode is set to none by default contributed by @Syntasu
1 Like

Thank you for this update.
The phone is working again :smiley:

Just need to do some test but the last version of FiveM Artefacts doesnā€™t work good for the commands just like last timeā€¦ invalid call ref attempt are backā€¦

But with the version 3.0.2 the ā€œ/ā€ command work

EDIT: Also is there a reason why the version is 2.1.2 when the last one was 3.0.2 ? mistake on typo ?

Because I pushed for the linux build the 2.x branch for some fixes for them. This was done after the 3.x updates.

Okay so for windows I should stick with 3.0.2 ?

Because the only problem left was this error :

image

If I can reproduce the error I can fix it.

The problem is when sending a message with GCPhone, it does add the SQL line inside the db but it doesnā€™t get updated because we get the error i showed above.

Server side

RegisterServerEvent('gcPhone:sendMessage')
AddEventHandler('gcPhone:sendMessage', function(phoneNumber, message)
    local sourcePlayer = tonumber(source)
    local identifier = getPlayerID(source)
    addMessage(sourcePlayer, identifier, phoneNumber, message)
end)

RegisterServerEvent('gcPhone:_internalAddMessage')
AddEventHandler('gcPhone:_internalAddMessage', function(transmitter, receiver, message, owner, cb)
    cb(_internalAddMessage(transmitter, receiver, message, owner))
end)

function _internalAddMessage(transmitter, receiver, message, owner)
    local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner);"
    local Query2 = 'SELECT * from phone_messages WHERE `id` = (SELECT LAST_INSERT_ID());'
	local Parameters = {
        ['@transmitter'] = transmitter,
        ['@receiver'] = receiver,
        ['@message'] = message,
        ['@isRead'] = owner,
        ['@owner'] = owner
    }
	return MySQL.Sync.fetchAll(Query .. Query2, Parameters)[1]
end

function addMessage(source, identifier, phone_number, message)
    local sourcePlayer = tonumber(source)
    local otherIdentifier = getIdentifierByPhoneNumber(phone_number)
    local myPhone = getNumberPhone(identifier)
    if otherIdentifier ~= nil then 
        local tomess = _internalAddMessage(myPhone, phone_number, message, 0)
        getSourceFromIdentifier(otherIdentifier, function (osou)
            if tonumber(osou) ~= nil then 
                -- TriggerClientEvent("gcPhone:allMessage", osou, getMessages(otherIdentifier))
                TriggerClientEvent("gcPhone:receiveMessage", tonumber(osou), tomess)
            end
        end) 
    end
    local memess = _internalAddMessage(phone_number, myPhone, message, 1)
    TriggerClientEvent("gcPhone:receiveMessage", sourcePlayer, memess)
end

client side

RegisterNetEvent("gcPhone:receiveMessage")
AddEventHandler("gcPhone:receiveMessage", function(message)
  -- SendNUIMessage({event = 'updateMessages', messages = messages})
  SendNUIMessage({event = 'newMessage', message = message})
  if message.owner == 0 then
    local text = '~o~Nouveau message'
    if ShowNumberNotification == true then
      text = '~o~Nouveau message ~y~'.. message.transmitter
      for _,contact in pairs(contacts) do
        if contact.number == message.transmitter then
          text = '~o~Nouveau message de ~g~'.. contact.display
          break
        end
      end
    end
    SetNotificationTextEntry("STRING")
    AddTextComponentString(text)
    DrawNotification(false, false)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    Citizen.Wait(300)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    Citizen.Wait(300)
    PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
  end
end)

it should work if you are using a connection string that works with mysql_async 2.x, like:

set mysql_connection_string "server=localhost;database=essentialmode;uid=myuser;password=password"

otherwise you can always fall back to running two queries.

function _internalAddMessage(transmitter, receiver, message, owner)
  local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner)"
  local Query2 = 'SELECT * from phone_messages WHERE `id` = @id'
  local Parameters = {
    ['@transmitter'] = transmitter,
    ['@receiver'] = receiver,
    ['@message'] = message,
    ['@isRead'] = owner,
    ['@owner'] = owner
  }
  local lastInsertId = MySQL.Sync.insert(Query, Parameters)
  return MySQL.Sync.fetchAll(Query2, {['id'] = lastInsertId})[1]
end
1 Like

Thank you it work with the bit of code :smiley:

Iā€™m getting these errors when some one joins?
How do i fix this

Im using the lates artifacts/fivem/build_server_windows/master 07-Oct-2018 08:08

Error loading script mysql-async.js in resource TODO: TypeError: global.exports is not a function
stack:
TypeError: global.exports is not a function
    at Object.<anonymous> (mysql-async.js:5058:8)
    at __webpack_require__ (mysql-async.js:20:30)
    at mysql-async.js:84:18
    at mysql-async.js:87:10
Failed to load script mysql-async.js.
Started resource mysql-async
Error running system event handling function for resource esplugin_mysql: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:655: No such export mysql_fetch_all in resource mysql-async
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:655: in metamethod '__index'
        @mysql-async/lib/MySQL.lua:143: in field 'fetchAll'
        server.lua:15: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:175: in function <citizen:/scripting/lua/scheduler.lua:174>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:138>
hitch warning: frame time of 595 milliseconds
Error running system event handling function for resource esx_ambulancejob: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:655: No such export mysql_fetch_scalar in resource mysql-async
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:655: in metamethod '__index'
        @mysql-async/lib/MySQL.lua:157: in field 'fetchScalar'
        server/main.lua:163: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:175: in function <citizen:/scripting/lua/scheduler.lua:174>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:138>

it somehow did not recognize the export calls as exports. Are you running a custom build? did you try clearing the cache?

I am not sure if I have seen the issue before and I cannot investigate until I get a new GPU.

iā€™ve cleared the cache multiple times,

And iā€™ve also tested it with v3.0.0 and v3.0.1 they all give the same error

maybe you got an idea that i could try?

It works for me on 801, which was the last one I checked.

Ill try it on the 801, right now im using the 805

ā€œEditā€
I have tested it, and it is not giving me the same error on build 801

Update 3.0.3

  • Fixed that dates were not returned as in 2.x. Timestamps are now returned in seconds. DateTime is tableified.
{ 
  ["dttest"] = { 
    ["Millisecond"] = 0,
    ["Hour"] = 19,
    ["Day"] = 9,
    ["Year"] = 2018,
    ["Minute"] = 25,
    ["Second"] = 34,
    ["Month"] = 9
  } ,
  ["tstest"] = 1539105934
}
  • For this fix to work you must not have dateStrings=true on your connection string.
  • I probably introduced some bugs with this.
  • Some rough progress was made with getting 3.x to run stable on linux.