Msypon Posted February 16, 2013 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 )
DNL291 Posted February 16, 2013 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 )
DNL291 Posted February 16, 2013 Posted February 16, 2013 (edited) Where is the 'result' ? Edited February 16, 2013 by Guest
Msypon Posted February 16, 2013 Author Posted February 16, 2013 im learning sqllite men, which result table are you talking?
Castillo Posted February 16, 2013 Posted February 16, 2013 You are on the database? because the "savesql" command will only update it, it won't insert the row.
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