WeCan Posted October 4, 2018 Posted October 4, 2018 (edited) 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 ? Edited October 4, 2018 by WeCan
MIKI785 Posted October 4, 2018 Posted October 4, 2018 The wiki says that it may return nil if there aren't any more rows to return. Are you sure that the result set isn't empty?
WeCan Posted October 4, 2018 Author Posted October 4, 2018 2 hours ago, MIKI785 said: The wiki says that it may return nil if there aren't any more rows to return. Are you sure that the result set isn't empty? yes i just changed script name not more ... how i can write code to that if value nil then break function ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now