yasin0 Posted November 8, 2017 Share Posted November 8, 2017 السلام عليكم حاولت اسوي بقواعد البيانات انه يحفظ الدم لما يكتب كوماند باف 8 بس يطلع لي خطاء 12/*.lua:11: Database query failed : no such column Health Code : executeSQLQuery( ' CREATE TABLE IF NOT EXISTS `testscript01` (playerSerial, Health) ' ) addCommandHandler( 'savehealth', function(source) local checkData = executeSQLQuery( ' SELECT * FROM `testscript01` WHERE playerSerial = ? ', getPlayerSerial(source) ) local Health = getElementHealth(source) if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) then executeSQLQuery( ' INSERT INTO `testscript01` (playerSerial, Health) VALUES(?, ?) ', getPlayerSerial(source), Health ) outputChatBox('Saved') else executeSQLQuery( ' UPDATE`testscript01` SET playerSerial = ?, Health = ? ', getPlayerSerial(source), Health ) outputChatBox('Updated') end end ) addEventHandler( 'onPlayerJoin', root, function( ) local check = executeSQLQuery( ' SELECT * FROM `testscript01` WHERE playerSerial = ? ', getPlayerSerial(source) ) if ( type ( check ) == 'table' and #check == 0 or not check ) then return end local Health = check[1]['Health'] setElementHealth( source,Health ) end ) Link to comment
iMr.WiFi..! Posted November 8, 2017 Share Posted November 8, 2017 (edited) وعليكم السلام ._. عندك سطر 10 لاصق "UPDATE" + "`testscript01`" وناسي تسوي WHERE playerSerial = ? + تأكد انك حاط المود بقروب الأدمن ! Edited November 8, 2017 by iMr.WiFi..! 1 Link to comment
yasin0 Posted November 8, 2017 Author Share Posted November 8, 2017 24 minutes ago, iMr.WiFi..! said: وعليكم السلام ._. عندك سطر 10 لاصق "UPDATE" + "`testscript01`" وناسي تسوي WHERE playerSerial = ? + تأكد انك حاط المود بقروب الأدمن ! جاني خطاء اخر يقولي السينتاكس غلط سطر 10 executeSQLQuery( ' CREATE TABLE IF NOT EXISTS `testscript01` (playerSerial, Health) ' ) addCommandHandler( 'savehealth', function(source) local checkData = executeSQLQuery( ' SELECT * FROM `testscript01` WHERE playerSerial = ? ', getPlayerSerial(source) ) local Health = getElementHealth(source) if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) then executeSQLQuery( ' INSERT INTO `testscript01` (playerSerial, Health) VALUES(?, ?) ', getPlayerSerial(source), Health ) outputChatBox('Saved') else executeSQLQuery( ' UPDATE` `testscript01` SET playerSerial = ?, Health = ? ', getPlayerSerial(source), Health ) outputChatBox('Updated') end end ) addEventHandler( 'onPlayerJoin', root, function( ) local check = executeSQLQuery( ' SELECT * FROM `testscript01` WHERE playerSerial = ? ', getPlayerSerial(source) ) if ( type ( check ) == 'table' and #check == 0 or not check ) then return end local Health = check[1]['Health'] setElementHealth( source,Health ) end ) Link to comment
iMr.WiFi..! Posted November 8, 2017 Share Posted November 8, 2017 خل السطر العاشر زي كذا : executeSQLQuery( ' UPDATE `testscript01` SET Health = ? WHERE playerSerial = ? ', Health, getPlayerSerial(source) ) Link to comment
yasin0 Posted November 8, 2017 Author Share Posted November 8, 2017 1 minute ago, iMr.WiFi..! said: خل السطر العاشر زي كذا : executeSQLQuery( ' UPDATE `testscript01` SET Health = ? WHERE playerSerial = ? ', Health, getPlayerSerial(source) ) صار يقولي مافي كولمن اسمه Health ? Link to comment
iMr.WiFi..! Posted November 8, 2017 Share Posted November 8, 2017 1 hour ago, iMr.WiFi..! said: تأكد انك حاط المود بقروب الأدمن ! Link to comment
Rockyz Posted November 8, 2017 Share Posted November 8, 2017 جرب : addEventHandler ( 'onResourceStart', resourceRoot, function ( ) local createSQL = executeSQLQuery ( 'CREATE TABLE IF NOT EXISTS `getBACK1` (playerSerial, Health)' ) if ( createSQL ) then outputDebugString ( 'Successfully Created Health SQL Table', 3, 0, 255, 0 ) else outputDebugString ( 'Failed to Create Health SQL Table', 1, 0, 255, 0 ) end end ) addEventHandler ( 'onPlayerQuit', root, function ( ) local checkData = executeSQLQuery ( 'SELECT * FROM `getBACK1` WHERE playerSerial = ? ', getPlayerSerial ( source ) ) local Health = getElementHealth (source ) local dataText = { 'UPDATE `getBACK1` SET Health = ? WHERE playerSerial = ?', Health, getPlayerSerial ( source ) }; if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) then dataText = { 'INSERT INTO `getBACK1` (playerSerial, Health) VALUES(?, ?)', getPlayerSerial ( source ), Health }; end executeSQLQuery ( unpack ( dataText ) ); end ); addEventHandler( 'onPlayerJoin', root, function( ) local check = executeSQLQuery ( 'SELECT * FROM `getBACK1` WHERE playerSerial = ?', getPlayerSerial ( source ) ); if ( check and type ( check ) == 'table' and #check > 0 ) then setElementHealth ( source, check[1].Health ) end end ); 1 Link to comment
King12 Posted November 9, 2017 Share Posted November 9, 2017 "onPlayerSpawn" -- بدلاً من "onPlayerJoin" Link to comment
Rockyz Posted November 9, 2017 Share Posted November 9, 2017 (edited) 5 minutes ago, King12 said: "onPlayerSpawn" -- بدلاً من "onPlayerJoin" أ صحيح, انتبهت لهذا الشي و كنت بعدلها لكن انا صححت الأخطاء فقط Edited November 9, 2017 by #,+( _xiRoc[K]; > 1 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