Jump to content

x[مشكلة بسيطة]x مايحفظ الدم !


yasin0

Recommended Posts

السلام عليكم حاولت اسوي بقواعد البيانات انه يحفظ الدم لما يكتب كوماند باف 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
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
1 minute ago, iMr.WiFi..! said:

خل السطر العاشر زي كذا :
 


executeSQLQuery( ' UPDATE `testscript01` SET Health = ? WHERE playerSerial = ? ',  Health, getPlayerSerial(source) )

 

صار يقولي مافي كولمن اسمه Health ?

Link to comment

جرب :

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 );

 

  • Like 1
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...