Sasu Posted June 1, 2013 Share Posted June 1, 2013 It's return me "Nil". addEventHandler("onResourceStart", resourceRoot, function() local createTable = executeSQLQuery("CREATE TABLE IF NOT EXISTS level_system(account TEXT, exp INT, level INT, kills INT, dies INT)") end ) addEventHandler("onPlayerLogin", root, function(_, account) local accName = getAccountName(account) local statsTable = executeSQLQuery("SELECT kills,dies FROM level_system WHERE account=?", accName ) if ( #statsTable ~= 0 ) then setElementData(source, "Kills", statsTable["kills"]) setElementData(source, "Dies", statsTable["dies"]) outputChatBox(tostring(statsTable["dies"])) else executeSQLQuery("INSERT INTO level_system(account,kills,dies) VALUES(?,?,?)", accName, 0, 0 ) setElementData(source, "Kills", 0) setElementData(source, "Dies", 0) end end ) Link to comment
Castillo Posted June 1, 2013 Share Posted June 1, 2013 That's because you forgot to add the row index, like this: statsTable [ 1 ] [ "kills" ] statsTable [ 1 ] [ "dies" ] Link to comment
Sasu Posted June 1, 2013 Author Share Posted June 1, 2013 That's because you forgot to add the row index, like this: statsTable [ 1 ] [ "kills" ] statsTable [ 1 ] [ "dies" ] Works. Thanks solid. 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