Msypon Posted February 16, 2013 Share Posted February 16, 2013 Line 21: attempt to index field '?' addEventHandler ( 'onResourceStart', resourceRoot, function ( ) executeSQLCreateTable ( 'SQLData', 'money INT, serial STRING' ) end ) addCommandHandler ( 'savesql', function ( player ) local serial = getPlayerSerial ( player ) local money = getPlayerMoney ( player ) executeSQLQuery ( 'UPDATE SQLData SET money = ? WHERE serial = ?', money, serial ) end ) addCommandHandler ( 'loadsql', function ( player ) local serial = getPlayerSerial ( player ) local result = executeSQLQuery ( 'SELECT money FROM SQLData WHERE serial = ?', serial ) if ( type ( result ) == "table" and #result == 0 ) or not result then return setPlayerMoney ( player, result[1].money ) end end ) Link to comment
DNL291 Posted February 16, 2013 Share Posted February 16, 2013 addCommandHandler ( 'loadsql', function ( player ) local serial = getPlayerSerial ( player ) local result = executeSQLQuery ( 'SELECT money FROM SQLData WHERE serial = ?', serial ) if ( type ( result ) == "table" and #result == 0 ) or not result then return end setPlayerMoney ( player, result[1].money ) end ) Link to comment
DNL291 Posted February 16, 2013 Share Posted February 16, 2013 (edited) Where is the 'result' ? Edited February 16, 2013 by Guest Link to comment
Msypon Posted February 16, 2013 Author Share Posted February 16, 2013 im learning sqllite men, which result table are you talking? Link to comment
Castillo Posted February 16, 2013 Share Posted February 16, 2013 You are on the database? because the "savesql" command will only update it, it won't insert the row. 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