Hello, I am trying to understand how to use MySQL in lua, to get values from the Database.
My attempt was to get the users firstname by checking against the identifier.
My local license already holds the identifier as it is stored inside the database.
The call to MySQL should happen inside my AddEventHandler (which is setup and working).
The MySQL line gives me the error: attempt to index a nil value (Global ‘MySQL’) and I don’t understand why.
-- local license already holds the correct identifier to check for
local fname = ""
MySQL.Async.fetchAll('SELECT firstname FROM users WHERE identifier = @license', {}, function(result)
fname = result
print("Firstname is: ", fname)
end)
Inside my resource-file:
server_scripts{
'@mysql-async/lib/MySQL.lua',
'server.lua'
}