I'm working on a phone script for Fivem when a player joins the counsel gets this error. "SCRIPT ERROR: @phone/server/server.lua:64: attempt to index a nil value (local 'result')
handler (@phone/server/server.lua:581)"
I am going complete blank on a way to fix this error. Any would-be greatly appreciated.
code from line 64
function getNumberPhone(identifier)
local result = MySQL.Sync.fetchAll("SELECT users.phone_number FROM users WHERE users.identifier = @identifier", {
['@identifier'] = identifier
})
if result[1] ~= nil then
return result[1].phone_number
end
return nil
code from line 581
AddEventHandler('Phone:allUpdate', function()
local sourcePlayer = tonumber(source)
local identifier = getPlayerID(source)
local num = getNumberPhone(identifier)
TriggerClientEvent("Phone:myPhoneNumber", sourcePlayer, num)
TriggerClientEvent("Phone:contactList", sourcePlayer, getContacts(identifier))
TriggerClientEvent("Phone:allMessage", sourcePlayer, getMessages(identifier))
TriggerClientEvent('Phone:getBourse', sourcePlayer, getBourse())
sendHistoriqueCall(sourcePlayer, num)
end)
AddEventHandler
(probablygetNumberPhone
?) triggers a function which leads you to line 64. Whatever is in that function,result
is definitelynil
. I know this because your error says "attempt to index a nil value (local 'result')" – joehinkle11