function cctvDB(action, id, data) if action == \"create\" then local checkT = executeSQLSelect(\"cctvterminals\", \"name, loc, interior, restricted, access, options\") if not checkT then local alter = executeSQLSelect(\"cctvterminals\", \"name\", \"\", 1) if not alter then executeSQLCreateTable(\"cctvterminals\", \"name TEXT, loc TEXT, interior INTEGER, restricted INTEGER, access TEXT, options TEXT\") outputChatBox(\"CCTV: DB: Created terminal table\", getRootElement(), 0, 222, 222, true) else executeSQLQuery(\"ALTER TABLE cctvterminals ADD COLUMN options TEXT DEFAULT \'0\'\") outputChatBox(\"CCTV: DB: Updated terminal table structure\", getRootElement(), 0, 222, 222, true) end end local checkC = executeSQLSelect(\"cctvcameras\", \"name, type, terminal, loc, interior, target, color, scan, zoom, motor, options\") if not checkC then local alter = executeSQLSelect(\"cctvcameras\", \"name\", \"\", 1) if not alter then executeSQLCreateTable(\"cctvcameras\", \"name TEXT, type INTEGER, terminal TEXT, loc TEXT, interior INTEGER, target TEXT, color TEXT, scan TEXT, zoom BOOL, motor BOOL, options TEXT\") outputChatBox(\"CCTV: DB: Created camera table\", getRootElement(), 0, 222, 222, true) else executeSQLQuery(\"ALTER TABLE cctvcameras ADD COLUMN options TEXT DEFAULT \'0\'\") outputChatBox(\"CCTV: DB: Updated camera table structure\", getRootElement(), 0, 222, 222, true) end end
for id,terminal in ipairs(term) do
elseif action == \"load\" then cctvT = nil cctvC = nil cctvT = {} cctvC = {} local term = executeSQLSelect(\"cctvterminals\", \"name, loc, interior, restricted, access, options\") if #term > 0 then for id,terminal in ipairs(term) do cctvT[terminal.name] = {} cctvT[terminal.name].name = terminal.name cctvT[terminal.name].x = tonumber(gettok(terminal.loc,1,32)) cctvT[terminal.name].y = tonumber(gettok(terminal.loc,2,32)) cctvT[terminal.name].z = tonumber(gettok(terminal.loc,3,32)) cctvT[terminal.name].rz = tonumber(gettok(terminal.loc,4,32)) cctvT[terminal.name].mr = tonumber(gettok(terminal.loc,5,32)) or 1 cctvT[terminal.name].mg = tonumber(gettok(terminal.loc,6,32)) or 200 cctvT[terminal.name].mb = tonumber(gettok(terminal.loc,7,32)) or 200 cctvT[terminal.name].ma = tonumber(gettok(terminal.loc,8,32)) or 127 cctvT[terminal.name].dimension = tonumber(gettok(terminal.loc,9,32)) or 0 cctvT[terminal.name].interior = tonumber(terminal.interior) cctvT[terminal.name].restricted = tonumber(terminal.restricted) cctvT[terminal.name].access = tostring(terminal.access) cctvT[terminal.name].onlymarker = tonumber(gettok(terminal.options,1,32)) or 0 cctvT[terminal.name].markersize = tonumber(gettok(terminal.options,2,32)) or 2 cctvT[terminal.name].camcount = 0 end end