thund3rbird23 Posted September 15, 2019 Share Posted September 15, 2019 I used this code about 2 months ago and works fine, now I get error: attempt to compare number with table (on line 7) why? function loadAllGate() gates = {} local queryHandler = dbQuery(connection, "SELECT * FROM gates") local result, num, errorMsg = dbPoll(queryHandler, 10) if result > 0 then for key, row in ipairs(result) do local gateId = tonumber(row["id"]) gates[key] = {} gates[key]["sqlId"] = gateId gates[key]["modelId"] = tonumber(row["modelId"]) gates[key]["lockState"] = true gates[key]["defaultState"] = fromJSON(row["defaultState"]) gates[key]["changeState"] = fromJSON(row["changeState"]) gates[key]["createRotation"] = fromJSON(row["createRotation"]) gates[key]["IndDim"] = fromJSON(row["IndDim"]) gates[key]["gate"] = createObject(gates[key]["modelId"], gates[key]["defaultState"][1], gates[key]["defaultState"][2], gates[key]["defaultState"][3], gates[key]["defaultState"][4], gates[key]["defaultState"][5], gates[key]["defaultState"][6]) setElementRotation(gates[key]["gate"], gates[key]["createRotation"][1], gates[key]["createRotation"][2], gates[key]["createRotation"][3]) setElementInterior(gates[key]["gate"], gates[key]["IndDim"][1]) setElementDimension(gates[key]["gate"], gates[key]["IndDim"][2]) end end outputDebugString(#gates .. " gate(s) loaded") end addEventHandler("onResourceStart", resourceRoot, loadAllGate) Link to comment
Moderators IIYAMA Posted September 15, 2019 Moderators Share Posted September 15, 2019 41 minutes ago, thund3rbird23 said: attempt to compare number with table (on line 7) why? That is line 5 for us. If table is higher than 0? OR If table item count is higher than 0? if #result > 0 then 1 Link to comment
thund3rbird23 Posted September 15, 2019 Author Share Posted September 15, 2019 31 minutes ago, IIYAMA said: That is line 5 for us. If table is higher than 0? OR If table item count is higher than 0? if #result > 0 then Thanks. 1 Link to comment
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