Hello I have 2 functions one to return a value
function AddPlayer(steamID, source)
for i,p in ipairs(players) do
if steamID == p[1] then
players[i] = {p[1], p[2], source}
return
end
end
local initialPoints = GetInitialPoints(steamID)
print(initialPoints)
table.insert(players, {steamID, initialPoints, source})
end
function GetInitialPoints(steamID)
local points = 0
print(steamID)
MySQL.Async.fetchAll("Select priority FROM queue where `identifier`= @identifier",
{
['@identifier'] = steamID,
},
function(resp)
points = resp[1].priority
print(points)
end)
return points
end
so the print actually prints the correct value (10,000)
but in the return on function AddPlayer where I print the initial points it is printing 0 which is what I set the variable when declared. When it needs to be printing what I set points to.
function AddPlayer(steamID, source)
for i,p in ipairs(players) do
if steamID == p[1] then
players[i] = {p[1], p[2], source}
return
end
end
print(steamID)
MySQL.Async.fetchAll(
"Select priority FROM queue where `identifier`= @identifier",
{
['@identifier'] = steamID,
},
function(resp)
local initialPoints = resp[1].priority
print(initialPoints)
table.insert(players, {steamID, initialPoints, source})
end
)
end