Jump to content

CCTV


kkoldits

Recommended Posts

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", root, 0, 222, 222, true)
      else 
        executeSQLQuery("ALTER TABLE cctvterminals ADD COLUMN options TEXT DEFAULT '0'") 
        outputChatBox("CCTV: DB: Updated terminal table structure", root, 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", root, 0, 222, 222, true)
      else 
        executeSQLQuery("ALTER TABLE cctvcameras ADD COLUMN options TEXT DEFAULT '0'") 
        outputChatBox("CCTV: DB: Updated camera table structure", root, 0, 222, 222, true)
      end
    end
  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

I have problem with CCTV!  Here is pic of errors

Link to comment

Try putting this anywhere in your code:

addEventHandler("onResourceStart", resourceRoot,
  function ()
  	executeSQLCreateTable("cctvterminals", "name TEXT, loc TEXT, interior INTEGER, restricted INTEGER, access TEXT, options TEXT")
    	executeSQLCreateTable("cctvcameras", "name TEXT, type INTEGER, terminal TEXT, loc TEXT, interior INTEGER, target TEXT, color TEXT, scan TEXT, zoom BOOL, motor BOOL, options TEXT")
 end)

executeSQLCreateTable uses CREATE TABLE IF NOT EXISTS so it doesn't matter if it runs every time the resource starts.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...