Jump to content

Help * SQL add ElementData


Cocodrilo

Recommended Posts

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

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

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