Hello everyone, I’m trying to create a new work based on gopostal. Almost everything works correctly, the only error is that I can not connect to the database to get the job information.
What am I trying to do?
I created a new job in the database
22 uber 2750 would be (id) (name job) (salary) I created all my work But what I had not realized was that the gopostal worked with old mysql and not mysql async. Then I started converting to mysql async to FX server
Steps that I did to convert from MYSQL to MYSQL Async
added server_script “@mysql-async/lib/MySQL.lua” in __resource
Remove all
-
require “resources/mysql-async/lib/MySQL”
-
require “resources/essential/lib/MySQL”
Chance All MySQL acess
and I changed the format of requesting access to mysql from
MySQL.executeQuery(
for
MySQL.Sync.fetchAll(
And the result in the end? did not work i’m breaking my head, but I can not find the error because all the other scripts I converted so only this one is giving problem. I’ll leave the original code and the new one here for you to take a look and who knows, someone can help me,
SCRIPT ORIGINAL
function nameJob(player)
local executed_query = MySQL:executeQuery("SELECT identifier, job_id, job_name FROM users LEFT JOIN jobs ON jobs.job_id = users.job WHERE users.identifier = '@identifier'", {['@identifier'] = player})
local result = MySQL:getResults(executed_query, {'job_name'}, "identifier")
return tostring(result[1].job_name)
end
RegisterServerEvent('delivery:checkjob')
AddEventHandler('delivery:checkjob', function()
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.identifier
local namejob = nameJob(player)
if namejob == "Delivery guy" then --here you change the jobname (from your database)
TriggerClientEvent('yesdelivery', source)
else
TriggerClientEvent('nodelivery', source)
end
end)
end)
SCRIPT MODIFIED
function nameJob(player)
local executed_query = MySQL.Sync.fetchAll("SELECT identifier, job_id, job_name FROM users LEFT JOIN jobs ON jobs.job_id = users.job WHERE users.identifier = '@identifier'", {['@identifier'] = player})
local result = MySQL:getResults(executed_query, {'job_name'}, "identifier")
return tostring(result[1].job_name)
end
RegisterServerEvent('delivery:checkjob')
AddEventHandler('delivery:checkjob', function()
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.identifier
local namejob = nameJob(player)
if namejob == "Delivery guy" then --here you change the jobname (from your database)
TriggerClientEvent('yesdelivery', source)
else
TriggerClientEvent('nodelivery', source)
end
end)
end)
MY DATABASE
THIS IS ERROR