Cocodrilo Posted March 20, 2016 Share Posted March 20, 2016 What is wrong here? addEventHandler("onResourceStart", resourceRoot, function () connection = dbConnect("sqlite", "data.db") dbExec(connection, "CREATE TABLE IF NOT EXISTS data (ID INT, cuenta TEXT, deaths INT)") end) function player_Wasted ( ammo, attacker, weapon, bodypart ) local deathss = getElementData(source, "deaths") dbExec(connection,"UPDATE data SET deaths = ? WHERE cuenta = ?", tostring(deathss)+1, source) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) Link to comment
1LoL1 Posted March 20, 2016 Share Posted March 20, 2016 What do you want? When player dead he will add +1 deaths or When anyone dead in database will +1 deaths? Link to comment
Cocodrilo Posted March 20, 2016 Author Share Posted March 20, 2016 the first one option, i just try to understand this (sql) with a easy example like this Link to comment
KariiiM Posted March 20, 2016 Share Posted March 20, 2016 You can not update the table if its empty Link to comment
Noki Posted March 21, 2016 Share Posted March 21, 2016 SQL works off rows (also called records). For you to update a record/row, you first need to have one in there. When you want to add data, use INSERT INTO. If you want to update data for a row that already exists, use UPDATE. Also, userdata won't work with SQL. So when you try and pass source into the account field, it won't work. Get the account name instead using getAccountName(getPlayerAccount(source)). Link to comment
Cocodrilo Posted March 23, 2016 Author Share Posted March 23, 2016 got it, thanks everyone! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now