Jump to content

Race Stats


proracer

Recommended Posts

Hello everyone!

I have been working hard on sql based race stats.But unfornunately always when I start resource it says:

"no such column: account"

Here's a piece of code:

function createDB ( ) 
    executeSQLCreateTable ( 'Points', 'account STRING, points INT' ) 
    executeSQLCreateTable ( 'Cash', 'account STRING, cash INT' ) 
    executeSQLCreateTable ( 'Rank', 'account STRING, rank TEXT' ) 
    executeSQLCreateTable ( 'Wins', 'account STRING, wins INT' ) 
    executeSQLCreateTable ( 'Played', 'account STRING, played INT' ) 
    outputChatBox ( 'Successfully created tables.' ) -- Debug String 
end 
addEventHandler ( 'onResourceStart', resourceRoot, createDB ) 
  
function clientReady ( prev, acc, autologin ) 
    local account = getAccountName ( acc ) 
    local playerName = getPlayerName ( source ) 
     
    -- CHECK TABLES -- 
    resultTable1 = executeSQLSelect ( 'Points', 'account', "account = '" .. account .. "'"  ) 
    resultTable2 = executeSQLSelect ( 'Cash', 'account', "account = '" .. account .. "'"  ) 
    resultTable3 = executeSQLSelect ( 'Rank', 'account', "account = '" .. account .. "'"  ) 
    resultTable4 = executeSQLSelect ( 'Wins', 'account', "account = '" .. account .. "'"  ) 
    resultTable5 = executeSQLSelect ( 'Played', 'account', "account = '" .. account .. "'"  ) 
     
    if (type(resultTable1) == 'table' and #resultTable1 == 0 ) or not resultTable1 then 
        executeSQLInsert ( 'Points', "'" .. account .. "', '0'" ) 
    end 
    if (type(resultTable2) == 'table' and #resultTable2 == 0 ) or not resultTable2 then 
        executeSQLInsert ( 'Cash', "'" .. account .. "', '0'" ) 
    end 
    if (type(resultTable3) == 'table' and #resultTable3 == 0 ) or not resultTable3 then 
        executeSQLInsert ( 'Rank', "'" .. account .. "', 'None'" ) 
    end 
    if (type(resultTable4) == 'table' and #resultTable4 == 0 ) or not resultTable4 then 
        executeSQLInsert ( 'Wins', "'" .. account .. "', '0'" ) 
    end 
    if (type(resultTable5) == 'table' and #resultTable5 == 0 ) or not resultTable5 then 
        executeSQLInsert ( 'Played', "'" .. account .. "', '0'" ) 
    end 
    outputChatBox ( " I'm ready! " ) -- Debug String 
end 
addEventHandler ( 'onPlayerLogin', root, clientReady ) 

Line 16 error: Database query failed: no such column: account

But surprisingly it only says that it can't find column 'account' for table: 'Points'.So there is a little hint and I hope you can help me.. :P

But it still outputs to chatbox the last string for debug.

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