Jump to content

x [ Help ] x في SQL


Recommended Posts



addEventHandler('onResourceStart', resourceRoot,
function ()
    executeSQLQuery('CREATE TABLE IF NOT EXISTS `SaveLeveLSystem` (Account, Data1, Data2)')
end 
)
 


addEventHandler('onPlayerQuit', root,
function (  )
    local account = getPlayerAccount(source)
    if account and not isGuestAccount(account) then
        local accname = getAccountName(account)
        local LeveL = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?", getPlayerAccount(accname))
        if LeveL and #LeveL > 0 then
            executeSQLQuery('UPDATE `SaveLeveLSystem` SET Data1 = ?, Data2 = ? WHERE Account = ?', (getElementData(Kill, "KillS") or 0), (getElementData(Kill, "LeVeL") or 0), accname)
        else
            executeSQLQuery("INSERT INTO `SaveLeveLSystem` ( Account, Data1, Data2 ) VALUES( ?, ?, ? )", accname, getElementData(Kill, "KillS") or 0, getElementData(Kill, "LeVeL") or 0)
        end
    end
end )
 
addEventHandler('onPlayerLogin',root,
function ( _, account )
    local accname = getAccountName(account)
    local LeveL = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?", getPlayerAccount(accname))
    if LeveL and #LeveL > 0 then
        setElementData(source, "KillS", LeveL[1]["Data1"])
        setElementData(source, "LeVeL", LeveL[1]["Data2"])
    else
        executeSQLQuery("INSERT INTO `SaveLeveLSystem` ( Account, Data1, Data2 ) VALUES( ?, ?, ? )", accname, 0, 0)
        setElementData(source, "KillS", 0)
        setElementData(source, "LeVeL", 0)
    end
end )


---- انا مسوي مود لفل و شغال تمام لكن مايحفظ
----- انا طرحت بس اكواد   الحفظ
----- الاكواد الباقيه مافيه شيء
----- و الدي بق مايبين عندي شيء فيه
-------- الرجاء وش المشكله في الكود ؟

 

Link to comment
addEventHandler('onResourceStart',resourceRoot, 
    function (      ) 
             executeSQLQuery ('CREATE TABLE IF NOT EXISTS  `SaveLeveLSystem` ( Account,Data1,Data2 ) ')  
    end 
) 

addEventHandler('onPlayerQuit',root, 
    function (  ) 
    local account = getPlayerAccount ( source )
    local accname = getAccountName ( account ) 
    local LeVeL = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?",accname ) 
     if ( type ( LeVeL ) == "table" and #LeVeL == 0 or not LeVeL ) then 
        executeSQLQuery ( "INSERT INTO `SaveLeveLSystem` (  Account,Data1,Data2 ) VALUES(?,?,?)",accname,getElementData ( source,'KillS' or 0 ),getElementData ( source,'LeVeL' or 0 ) )  
    else 
        executeSQLQuery('UPDATE `SaveLeveLSystem` SET Data1 =?,Data2 =? WHERE Account =?',getElementData ( source,'KillS' or 0 ),getElementData ( source,'LeVeL' or 0 ),accname ) 
    end 
end 
) 


 addEventHandler('onPlayerLogin',root, 
    function ( _,account ) 
        local Results = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?",getAccountName ( account ) ) 
        if ( type ( Results ) == "table" and #Results == 0 or not Results ) then return end 
            setElementData(source, 'KillS', Results[1]["Data1"])
            setElementData(source, 'LeVeL', Results[1]["Data2"])
    end 
) 

 

  • Like 1
Link to comment
Just now, N3xT said:

سطر 14 جرب تخليه كذا 

 


if ( account ) and ( not isGuestAccount(account) ) then

 

مشكور اخوي نكست

 

Just now, said:

local accname = getAccountName(account)

local LeveL = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?", getPlayerAccount(accname))

الغلط في الجزية هذي

مفروض العكس تجيب اكوانت الاعب بعدين تحط اسمه بالاستعلام

مشكور اخوي تنطيل

 

Just now, iFaHaD said:

addEventHandler('onResourceStart',resourceRoot, 
    function (      ) 
             executeSQLQuery ('CREATE TABLE IF NOT EXISTS  `SaveLeveLSystem` ( Account,Data1,Data2 ) ')  
    end 
) 

addEventHandler('onPlayerQuit',root, 
    function (  ) 
    local account = getPlayerAccount ( source )
    local accname = getAccountName ( account ) 
    local LeVeL = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?",accname ) 
     if ( type ( LeVeL ) == "table" and #LeVeL == 0 or not LeVeL ) then 
        executeSQLQuery ( "INSERT INTO `SaveLeveLSystem` (  Account,Data1,Data2 ) VALUES(?,?,?)",accname,getElementData ( source,'KillS' or 0 ),getElementData ( source,'LeVeL' or 0 ) )  
    else 
        executeSQLQuery('UPDATE `SaveLeveLSystem` SET Data1 =?,Data2 =? WHERE Account =?',getElementData ( source,'KillS' or 0 ),getElementData ( source,'LeVeL' or 0 ),accname ) 
    end 
end 
) 


 addEventHandler('onPlayerLogin',root, 
    function ( _,account ) 
        local Results = executeSQLQuery("SELECT * FROM `SaveLeveLSystem` WHERE Account=?",getAccountName ( account ) ) 
        if ( type ( Results ) == "table" and #Results == 0 or not Results ) then return end 
            setElementData(source, 'KillS', Results[1]["Data1"])
            setElementData(source, 'LeVeL', Results[1]["Data2"])
    end 
) 

 

مشكور اخوي برستيج اشتغل يعطيك العافيه

Edited by iMr ~ MnHmAr
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...