Jump to content

sqlite - help


xXMADEXx

Recommended Posts

Im trying to make my housing system on sqlite, so that my server dosn't lag, but for some reason i keep on getting this error:

[2013-03-09 11:14:09] WARNING: test\server.lua:25: dbExec failed; SQL logic error or missing database 

Here is my script:

connectToDb = dbConnect( "sqlite", "housing.db" ) 
  
addEventHandler('onResourceStart',getResourceRootElement(), 
    function () 
        if (not connectToDb) then 
            outputChatBox("ERROR: Housing.db has failed to load!",255,0,0) 
        else 
            --dbExec ( connectToDb, "CREATE TABLE IF NOT EXISTS 'houses' ( city TEXT PRIMARY KEY, zone INT, x INT, y INT, z INT, int INT, dim INT )" ) 
            dbExec ( connectToDb, "CREATE TABLE IF NOT EXISTS 'houses' ( rowid INT PRIMARY KEY, city TEXT, zone TEXT, x INT, y INT, z INT, int INT, dim INT )" ) 
        end 
    end 
) 
  
addCommandHandler("house", 
    function (player) 
        local x,y,z = getElementPosition(player) 
        local city = getZoneName(x,y,z,true) 
        local zone = getZoneName(x,y,z) 
        -- x,y,z,int,dim 
        createHouse(city,zone,x,y,z,math.random(1,10),math.random(0,5000)) 
    end 
) 
  
function createHouse(city,zone,x,y,z,int,dim) 
    local insertTheNewHouse = dbExec ( connectToDb, "INSERT INTO houses VALUES (?,?,?,?,?,?,?,?)","NULL",city,zone,x,y,z,int,dim) 
    newHousePickup = createPickup(x,y,z,3,1272,500) 
end 
  
  

Link to comment
connectToDb = dbConnect( "sqlite", "housing.db" ) 
  
addEventHandler('onResourceStart',getResourceRootElement(), 
    function () 
        if (not connectToDb) then 
            outputChatBox("ERROR: Housing.db has failed to load!",255,0,0) 
        else 
            --dbExec ( connectToDb, "CREATE TABLE IF NOT EXISTS 'houses' ( city TEXT PRIMARY KEY, zone INT, x INT, y INT, z INT, int INT, dim INT )" ) 
            dbExec ( connectToDb, "CREATE TABLE IF NOT EXISTS 'houses' ( rowID INT PRIMARY KEY, city TEXT, zone TEXT, x INT, y INT, z INT, int INT, dim INT )" ) 
        end 
    end 
) 
  
addCommandHandler("house", 
    function (player) 
        local x,y,z = getElementPosition(player) 
        local city = getZoneName(x,y,z,true) 
        local zone = getZoneName(x,y,z) 
        -- x,y,z,int,dim 
        createHouse(city,zone,x,y,z,math.random(1,10),math.random(0,5000)) 
    end 
) 
  
function createHouse(city,zone,x,y,z,int,dim) 
    dbExec ( handler, "INSERT INTO houses ( city, zone, x, y, z, int, dim ) VALUES ( ?, ?, ?, ?, ?, ?, ? )", city, zone, x, y, z, int, dim ) 
    newHousePickup = createPickup(x,y,z,3,1272,500) 
end 

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...