In my fxmanifest I have
lua54 'yes'
dependencies {
'mysql-async'
}
client_scripts {
'config.lua',
'client/main.lua'
}
server_scripts {
'@mysql-async/lib/MySQL.lua',
'server/server.lua'
}
In my Server.lua I have:
local MySQL = exports['mysql-async']
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
function IsMySQLAsyncAvailable()
local resourceState = GetResourceState('mysql-async')
if resourceState == 'started' then
return true
else
return false
end
end
-- When your resource starts Check if MySQL-ASYNC is available
AddEventHandler('onResourceStart', function(resourceName)
if resourceName == GetCurrentResourceName() then
if not IsMySQLAsyncAvailable() then
print("^8Error: ^7mysql-async resource is not started. Make sure it's added in server.cfg and started.")
-- You can take additional actions here, like stopping your resource
else
-- Continue with your resource's initialization
print("^2Success: ^7mysql-async is available. Your resource can proceed.")
end
end
end)
RegisterServerEvent('sadot:getImpoundedVehicles')
AddEventHandler('sadot:getImpoundedVehicles', function()
print("Line 7 ")
local source = source -- The source of the event (player's server ID)
local impoundedVehicles = {} -- Initialize an array to store the vehicles
TriggerClientEvent('okokNotify:Alert', source, 'Impound', 'Finding impounded vehicles.', 10000, 'error', true)
-- Replace the query with your actual SQL query to fetch impounded vehicles
MySQL.Async.FetchAll('SELECT * FROM owned_vehicles WHERE stored = 2', {}, function(result)
....
However, my console is displaying:
SCRIPT ERROR: @springer-sadot/server/main.lua:39: No such export Async in resource mysql-async
The GetResourceState returns “started” and other resources on the server use MySQL.Async.FetchAll. Why is mine giving me such errors?