Jump to content

SQLite issue (mabye a bug, not with query)


GioSerpo

Recommended Posts

ok, im having a SQLite issue. here goes... i downloaded 50P's simple bank system resource, which uses SQLite to save money in the bank. so, i ran it with my own server. it returned an error saying that the database was not found or was encrypted, when i tried to put money in the bank. well, i downloaded the SQLite database browser, and looked inside the database. the tables ha not been created. i crated them manually, using the way they would have been in the first place. table was "bank_accounts" with username and balance in it. i tried again. same error, "ERROR: Database Query Failed: file is encrypted or not a database (UPDATE bank_accounts SET balance = 10000 WHERE username = Jamar_Lewis)" (Jamar_Lewis is the name i use ingame, and 10000 is how much i tried to put in the bank).

Well, i made me a really simple databse script, that got the players money on hand and their name, and saved it to the database. i scripted it just a bit different than the bank scirpt, as it saved that stuff on player logout and added it on login, and after working out all the other errors, i got the same error that i got for 50P's, even after manually adding the table.

So, i talked to 50P about it in IRC, and he said it might be an MTA bug, because he said i was the only one who said anything about it. so, im just wondering, is this a bug, if so, why am i the only one who has it... any help is greatly appericated!

EDIT: Heres what i wrote:

function createDBOnStart() 
    local created = executeSQLCreateTable("player", "Money INT, Username TEXT") 
    if (created) then 
        print("Database creaton successful") 
    else 
        print("Database creation unsuccessful") 
    end 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createDBOnStart) 
  
function leaveHandler() 
    local Money = getPlayerMoney(source) 
    local Username = getClientName(source) 
    executeSQLUpdate("player", "Money = '" ..Money.."'", "Username = '" ..Username.. "'") 
end 
addEventHandler("onPlayerQuit", getRootElement(), leaveHandler) 
  
function spawnHandler() 
    local Username = getClientName(source) 
    result = executeSQLSelect("player", "Money, Username", "Username = '" ..Username.. "'") 
    setPlayerMoney(source, result[1][1]) 
end 

and heres the link to the bank script

https://community.multitheftauto.com/index.php?p= ... ails&id=54

im using th e latest version...

Link to comment
  • Recently Browsing   0 members

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