Hello,
I am a server owner and I am getting a couple of Script Errors. Here is the area where I am getting the Error:
RegisterServerEvent(“emsmdt:getOffenderDetailsById”)
AddEventHandler(“emsmdt:getOffenderDetailsById”, function(char_id)
local src = source
exports.oxmysql:fetch('SELECT * FROM `players` WHERE `citizenid` = @id', {
['@id'] = char_id
}, function(result)
local offender = result[1]
GetLicenses(src, function(licenses) offender.licenses = licenses end)
while offender.licenses == nil do Citizen.Wait(0) end
exports.oxmysql:fetch('SELECT * FROM `user_mdt_ems` WHERE `char_id` = @id', {
['@id'] = offender.id
}, function(result)
offender.notes = ""
offender.mugshot_url = ""
offender.fingerprint = ""
if result[1] then
offender.notes = result[1].notes
offender.mugshot_url = result[1].mugshot_url
offender.fingerprint = result[1].fingerprint
end
exports.oxmysql:fetch('SELECT * FROM `user_convictions_ems` WHERE `char_id` = @id', {
['@id'] = offender.id
}, function(convictions)
if convictions[1] then
offender.convictions = {}
for i = 1, #convictions do
local conviction = convictions[i]
offender.convictions[conviction.offense] = conviction.count
end
end
TriggerClientEvent("emsmdt:returnOffenderDetails", src, offender)
end)
end)
end)
end)
The Error that I am getting is:
SCRIPT ERROR: @qb-emsmdt/sv_mdt.lua:125: attempt to index a nil value (upvalue ‘offender’)
The second area is:
RegisterServerEvent(“emsmdt:saveOffenderChanges”)
AddEventHandler(“emsmdt:saveOffenderChanges”, function(id, notes, mugshot, convictions, convictions_removed, identifier, fingerprint)
exports.oxmysql:fetch('SELECT * FROM `user_mdt_ems` WHERE `char_id` = @id', {
['@id'] = id
}, function(result)
if result[1] then
exports.oxmysql:execute('UPDATE `user_mdt_ems` SET `notes` = @notes, `mugshot_url` = @mugshot_url, `fingerprint` = @fingerprint WHERE `char_id` = @id', {
['@id'] = id,
['@notes'] = notes,
['@mugshot_url'] = mugshot,
['@fingerprint'] = fingerprint
})
else
exports.oxmysql:insert('INSERT INTO `user_mdt_ems` (`char_id`, `notes`, `mugshot_url`, `fingerprint`) VALUES (@id, @notes, @mugshot_url, @fingerprint)', {
['@id'] = id,
['@notes'] = notes,
['@mugshot_url'] = mugshot,
['@fingerprint'] = fingerprint
})
end
if conviction ~= nil then
for conviction, amount in pairs(convictions) do
exports.oxmysql:execute('UPDATE `user_convictions_ems` SET `count` = @count WHERE `char_id` = @id AND `offense` = @offense', {
['@id'] = id,
['@count'] = amount,
['@offense'] = conviction
})
end
end
for i = 1, #convictions_removed do
exports.oxmysql:execute('DELETE FROM `user_convictions_ems` WHERE `char_id` = @id AND `offense` = @offense', {
['@id'] = id,
['@offense'] = convictions_removed[i]
})
end
end)
end)
The Error I am getting is this:
SCRIPT ERROR: @qb-emsmdt/sv_mdt.lua:185: attempt to get length of a nil value (upvalue ‘convictions_removed’)