I have a problem with lua tables.
I don't understand how I can get info from tables. For example. I have a db with zones and when resource starting I put all info in lua table
turfElement = {}
function onGangzonesLoad()
dbQuery(
function(qh)
local result = dbPoll(qh, -1)
if result then
for idZone,v in ipairs(result) do
local turfCol = createColRectangle(v['gX'], v['gY'], v['gSizeX'], v['gSizeY'])
local turfArea = createRadarArea(v['gX'], v['gY'], v['gtSizeX'], v['gtSizeY'], v['r'], v['g'], v['b'], 90)
turfElement[idZone] = {turfCol, turfArea, idZone}
end
end
end
, db, "SELECT * FROM gangzones")
end
addEventHandler("onResourceStart", resourceRoot, onGangzonesLoad)
But when I want to get info, I have error
for idZone,v in pairs(turfElement) do
outputChatBox("" .. v.turfArea["gX"] .. "", player, 255, 255, 255)
end
attempt to index field 'turfArea' <a nil value>
What's wrong?