i have error in script : local
ERROR: faction\factionadmin_s.lua:507: attempt to index local 'maxrow' (a nil value)
function adminDutyStart()
local result = mysql:query("SELECT id, name FROM factions WHERE type >= 2 ORDER BY id ASC")
local max = mysql:query("SELECT id FROM duty_allowed ORDER BY id DESC LIMIT 0, 1")
if (result) and max then
dutyAllow = { }
dutyAllowChanges = { }
i = 0
local maxrow = mysql:fetch_assoc(max)
maxIndex = tonumber(maxrow.id) or 0
while true do
local row = mysql:fetch_assoc(result)
if not row then break end
table.insert(dutyAllow, { row.id, row.name, { --[[Duty information]] } })
i = i+1
local result1 = mysql:query("SELECT * FROM duty_allowed WHERE faction="..tonumber(row.id))
if result1 then
while true do
local row1 = mysql:fetch_assoc(result1)
if not row1 then break end
table.insert(dutyAllow[i][3], { row1.id, tonumber(row1.itemID), row1.itemValue })
end
end
end
setElementData(resourceRoot, "maxIndex", maxIndex)
setElementData(resourceRoot, "dutyAllowTable", dutyAllow)
mysql:free_result(result)
mysql:free_result(result1)
mysql:free_result(max)
else
outputDebugString("[Factions] ERROR: Duty allow permissions failed.")
end
end
addEventHandler("onResourceStart", resourceRoot, adminDutyStart)
how i can fix that ?