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
)