[Release] MySQL Async Library - 3.0.8

dev
mysql
basemods

#427

Hello, I have the same problem as oliverjrose99 with v2 of mysql-async.
But v3.0.2 is fonctional provided someone connect to the server within 10sec if not the first initialization requests make a TimeOut…

FiveM Server 792 on Linux


#428

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


#429

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


#430

Sorry forgot being a helpful community member isn’t allowed.


#431

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


#432

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


#433

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


#434

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

#435

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 ?


#436

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


#437

Okay so for windows I should stick with 3.0.2 ?

Because the only problem left was this error :

image


#438

If I can reproduce the error I can fix it.


#439

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)

#440

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

#441

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


#442

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>

#443

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.


#444

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?


#445

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


#446

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