Ghmattimysql: My MySQL Implementation for FiveM [1.3.2]

I followed the instructions on replacing mysql-async but now am getting these errors is there something else I have to do?

cfx> Error running system event handling function for resource esx_shops: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:655: No such export QueryResultAsync in resource GHMattiMySQL
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:655: in metamethod '__index'
        @mysql-async/lib/MySQL.lua:28: in field 'fetchAll'
        server/main.lua:8: 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>

The resource obviously has not started by the time you run this.

Either move start GHMattiMySQL in the server.cfg to the first position, or add dependency 'GHMattiMySQL' in the respective resource.lua

Even if it is on first position, maybe someone is forgoing the MySQL.ready check. It might be better to add the dependency.

2 Likes

yeah the error is same and theres more errors like the one above related to esx.

Edit: oh yeah I forgot I got this error to.

System.IO.FileNotFoundException: Unable to find the specified file.
  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
  at (wrapper cominterop) CitizenFX.Core.IScriptHost:OpenHostFile (string)
  at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:OpenHostFile (string)
  at CitizenFX.Core.MonoScriptRuntime.LoadFile (System.String scriptFile) [0x00007] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:91
Failed to load script GHMattiMySQL.net.dll.

Well i think that might be your core issue.

It neither finds nor loads the GHMattiMySQL.net.dll; so ofc it cannot find the exports, because they are defined in that dll file.

the only instructions I followed was the mysql-sync replacement so I dont know if I missed anything.

Did you follow step 1 of the Instructions? After finishing them, the folder /resources/GHMattiMySQL/ should look like this:

image

lol I didnt get those files, the only files I got was settings and server.lua

Edit: Found the files now it works but now it says parameters are not in dictionary-shape is that normal?

Depends do you have mysql_debug set to true? If yes, then it is just a warning that your are doing querys without parameters, which might be prone to injection.

If you have not set mysql_debug then the code supplied is sending something that is not null as parameters, maybe an empty table or so, on a Sync operation, or actually faulty parameters. Async operations do not complain there.

edit: Ideally you want the resource to shut up, because if it is saying nothing it runs a lot faster.

Brilliant implementation! Much lower frame time on my servers and can’t be happier.

I am getting a weird stacktrace that I haven’t seen before though: https://hastebin.com/ubipikogad.pas

Any pointers to what this could be as I’m not sure if this is related but I’m only now seeing it after swapping to your implementation @zr0iq

Cheers

See in the first post, under Known “Issues”.

That is pretty much the reason. You run a sync query in an async one.

I have this problem, can someone help me about this?

[GHMattiMySQL ERROR] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF NOT EXISTS plate varchar(10) COLLATE utf8mb4_bin DEFAULT NULL’ at line 1

The error might be before or after the shown piece of mysql query. You need to show the full query for someone to help you.

I tried using this on my servers instead of mysql-async and it works beautifully, much faster and I can say goodbye to most hitch warnings, they are almost extinct!
Congratulations, very good and thanks for the implementation!

1 Like

Hello,
I still get quite a few hitch warnings, when the server reaches over 20 people the warnings go mental, I followed the guide for those who come from mysql-async.

Does it use prepared statements internally or manually parsed query ?

Also, we are discussing about adding support for your resource to vRP and the way of doing it here if you have any concerns about it.

@NotWhoever The hitch warnings are very likely not from my resource as it happens on a different thread from the server thread. I can send about 50% more queries than the resource can handle (on my 8 core system) and I do not recieve a single hitch.

@Imagic Using prepared statements. Even the MultiRow Inserter, first creates a prepared statement, and then lets the DBCommand add the parameters to prevent injection.

Okay, thanks.
Just to let you know that I created a “bridge” for vRP, you can find it here: https://github.com/ImagicTheCat/vRP-db-drivers

1 Like

Exception thrown by a task: System.AggregateException: One or more errors occurred. —> System.AggregateException: One or more errors occurred. —> System.InvalidCastException: Unable to convert MySQL date/time to System.DateTime

It popups this error when i try to use a collum wit datetime

2 Likes

This doesn’t help to reproduce that error. It works fine on my end.

I actually handle my bans with DATETIME. My test schema includes DATE.

So unless you make it reproducable for me, I am pretty sure I cannot help you with it.
C#/Lua, Database Version, Query and Schema should be included in such cases.

1 Like

I had to change to string in order to work, how its your datetime format ? As i was searching in the google i found out that could be a issue wit the format, mine its: yyyy-mm-dd h:i:s