you put a function in your parameters
Sorry what do you mean? I’m still relatively new at this. Cheers for the reply though!
Show the code that give this error, will tell you why then
I wish I knew, I’ve just setup mysql async and as soon as I log into the Server this pops up.
I’m off to bed, literally been at this for 11 hours - If you have any suggestions how to fix them please post and ill try in the morning. Thanks for replying already anyway! Your a champion.
New Expiremental API for mysql-async only available since build 363 of fivem, this API, will be the official and recommended way in future
https://github.com/brouznouf/fivem-mysql-async/tree/feature/promise-await
- New api using coroutine to have a sync feeling while still being async : local result = MySQL.[execute|fetchScalar|fetchAll|insert](query, params) which is possible due to the
Citizen.Await
function which allow to wait in an asynchronous way promises.
-- Not blocking the main thread, but block current execution context
print(MySQL.fetchScalar('SELECT NOW() as world'))
- All async functions now returns a promise which can be chained by using the next method
-- Promise api
local p = MySQL.Async.fetchScalar("SELECT 1")
p:next(function (result)
print(result)
return "test"
end):next(function (result)
print(result)
error 'An error'
end):next(nil, function(err)
print(err)
return ""
end)
-- Synchronisation
promise.all({
MySQL.Async.execute('SELECT SLEEP(1)'),
MySQL.Async.fetchScalar('SELECT "test"'),
}):next(function (results)
print(json.encode(results))
end)
did you forget to call Await in the first sample or do you provide it in your wrapper?
It’s provide in the wrapper :
- MySQL.x : Async + Await (non blocking io)
- MySQL.Async.x : Async (return promise)
- MySQL.Sync.x : blocking api (faster in many cases as there is no async / thread overhead, but blocking)
im have one error fetchScalar with last build mysql-async
https://gyazo.com/8fa9ee7bf3fa159f209b6d5ad1be645c
cause this error is no result with request not return nil
Look at the changelog it was fixed in the last version, simply update your mod
i’m have error after update with fetchScalar
[ERROR] [MySQL] An critical error happens on MySQL for query "SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe" {=}": Object reference not set to an instance of an object. at MySQLAsync.FetchScalar.Reader (MySql.Data.MySqlClient.MySqlCommand command) [0x00007] in <4566d747b17a449f9901d640a8efcabd>:0
at MySQLAsync.Operation`1[TResult].Execute (System.String query, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters, System.Boolean debug) [0x0004c] in <4566d747b17a449f9901d640a8efcabd>:0
[ERROR] [MySQL] An critical error happens on MySQL for query "SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe" {=}": Object reference not set to an instance of an object. at MySQLAsync.FetchScalar.Reader (MySql.Data.MySqlClient.MySqlCommand command) [0x00007] in <4566d747b17a449f9901d640a8efcabd>:0
at MySQLAsync.Operation`1[TResult].Execute (System.String query, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters, System.Boolean debug) [0x0004c] in <4566d747b17a449f9901d640a8efcabd>:0
nil
my request
MySQL.Sync.fetchScalar('SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe"',{}, function(rowsChanged)
print(rowsChanged)
end)
local countPlayer = MySQL.Sync.fetchScalar('SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe"')
Having the same error too.
please repair im need fetchScalar with api promise …
10 YEAR LATER … no update
Then don’t use this library or fix it yourself, i’m not at your service.
2.0.2 released should resolve the null bug and avoid fatal error (see 2.0.1)
nice sorry im not patient thx for fix you have a best plugin
to execute thread: ui_srv.lua:63: attempt to call a nil value (field 'fetchScalar')
stack traceback:
ui_srv.lua:63: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:163: in function <citizen:/scripting/lua/scheduler.lua:162>
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:162: in function <citizen:/scripting/lua/scheduler.lua:131>
not work after update i’m change with Sync for fix temporarily
This is in the experimental branch on github only, will do a 2.1.0 when i will have time to better test this myself
Haaj everybody
Can pls somebody help me explain set this up.
I have es_rp and banking running just like essential mode.
And now I need this for cops but I don’t get it work
Thanks allready