Hi , I’m trying to read spawn coordinates from mariadb using MySQL Async and I’m able to fetch and use the data, but whatever I write after mysql.ready() is not working.
RegisterServerEvent("spawnCoords")
AddEventHandler("spawnCoords", function(spawnClass, spawnLocation)
spawncoordinates.x = 0
MySQL.ready(function()
spawnClass=string.lower(spawnClass)
spawnLocation=string.lower(spawnLocation)
MySQL.Async.fetchAll('SELECT * FROM spawndetails WHERE spawnclass = @spawnClasss AND locname = @locnames',{['@spawnClasss']=spawnClass, ['@locnames']=spawnLocation}, function(spawnlocsdb)
if (spawnlocsdb[1].locname == spawnLocation) then
spawncoordinates["x"] = tonumber(spawnlocsdb[1].coordx)
print(spawncoordinates['x'])
spawncoordinates["y"] = tonumber(spawnlocsdb[1].coordy)
print(spawncoordinates['y'])
spawncoordinates["z"] = tonumber(spawnlocsdb[1].coordz)
print(spawncoordinates['y'])
spawncoordinates["model"] = spawnlocsdb[1].model
print(spawncoordinates['model'])
--
end
end)
end)
print("Outside mysql.ready")
TriggerClientEvent("getCoords", spawncoordinates["x"], spawncoordinates["y"], spawncoordinates["z"], spawncoordinates["model"])
end)
The last two lines, i.e print(“outside mysql.ready”) and client event trigger are not occurring
All the other print statements are working properly