hello I have created a function to retrieve the info of the player but it does not return any result outside the function, if I call a print in the function its works, but I want to recover the result outside the function
ps :sry for my bad english
function getPlayerInfo(id)
local player = getIdentifier(id)
MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', {['@identifier'] = tostring(player)}, function(result)
if result[1] ~= nil then
return result
else
createUser(id)
return nil
end
end)
end)
Because you are returning it to the nested function (the callback) that you pass in the async fetch all arguments.
I’ve ran into a similair problem, i’ve solved it by using an self writting asynchronous wrapper that will store all the results into a table and tell the system to continue if the piece of data is contained inside the table.
You can use the following library to achieve the same: