Markn1 Posted September 23, 2017 Share Posted September 23, 2017 (edited) مساعدة من فضلك! لا تحفظ مع إذن. debug: 1. :48: Database result uncollected after 5 minutes. [Query: INSERT INTO skillandmaxhp (login, money, explevel, expxp ) 2. :40: Bad argument @ 'getAccountName'[..... 1, got bolean] 3. :41: Bad argument @ 'getPlayerMoney'[..... 1, got bolean] pls عند بدء تشغيل المورد، فإنه يحفظ، ولكن ليس بشكل صحيح P.S. meta.xml : "<oop>true</oop>" UPD: المال يحفظ ( exp no ) createDB = dbConnect( "sqlite", "skillandmaxhp.db" ) if createDB then outputDebugString("LevelS & Skills // +") else outputDebugString("LevelS & Skills // -") end addEventHandler( "onResourceStart", getRootElement(), function() if createDB then local tabela = dbExec( createDB, "CREATE TABLE IF NOT EXISTS skillandmaxhp ( login TEXT, money INT, explevel, expxp )" ) else return end end ) addEventHandler( "onPlayerLogin", getRootElement(), function() local login = getAccountName ( source:getAccount() ) local q = dbQuery( createDB, "SELECT rowid, * FROM skillandmaxhp WHERE login=?", login ) local result = dbPoll( q, -1 ) if result then for _, row in ipairs(result) do source:setData( "ID", row["rowid"] ) source:setMoney( row["money"] ) setElementData ( source, "explevel" ) setElementData ( source, "expxp" ) end end exports.scoreboard:scoreboardAddColumn( "explevel", root, 70, "lvl" ); end ) function onPlayerQuit ( thePlayer ) local lp = source local pl = getPlayerAccount (lp) local login = getAccountName (pl) local money = getPlayerMoney ( lp) local expxp = getElementData ( lp, "expxp" ); local explevel = getElementData ( lp, "explevel" ); local q = dbQuery( createDB, "SELECT * FROM skillandmaxhp WHERE login=?", login ) local result = dbPoll( q, -1 ) dbFree(q) if #result == 0 then dbQuery( createDB, "INSERT INTO skillandmaxhp (login, money, explevel, expxp) VALUES (?,?,?,?)", login, money, explevel, expxp ) elseif #result == 1 then dbExec( createDB, "UPDATE skillandmaxhp SET login=?, money=?, explevel=?, expxp=?", login, money, explevel, expxp ) end end addEventHandler( "onPlayerQuit", getRootElement(), onPlayerQuit ) addEventHandler( "onPlayerWanted", getRootElement(), onPlayerQuit ) addEventHandler ( "onResourceStop", getRootElement(), onPlayerQuit ) Edited September 23, 2017 by Markn1 Link to comment
Ahmed Ly Posted September 23, 2017 Share Posted September 23, 2017 try createDB = dbConnect( "sqlite", "save.db" ) if createDB then outputDebugString("LevelS & Skills // +") else outputDebugString("LevelS & Skills // -") end addEventHandler( "onResourceStart", getRootElement(), function() if createDB then local tabela = dbExec( createDB, "CREATE TABLE IF NOT EXISTS save (login,money, explevel, expxp )" ) else return false end end ) addEventHandler( "onPlayerLogin", getRootElement(), function() local login = getAccountName (getPlayerAccount(source)) local q = dbQuery( createDB, "SELECT * FROM save WHERE login=?", login ) local result = dbPoll( q, -1 ) if result then for _, row in ipairs(result) do -- source:setData( "ID", row["rowid"] ) source:setMoney( row["money"] ) setElementData ( source, "explevel",row["explevel"]) setElementData ( source, "expxp",row["expxp"] ) end end exports.scoreboard:scoreboardAddColumn( "explevel", root, 70, "lvl" ); end ) function onPlayerQuit ( thePlayer ) local lp = source local pl = getPlayerAccount (lp) if isGuestAccount(pl) then return end local login = getAccountName (pl) local money = getPlayerMoney ( lp) local expxp = getElementData ( lp, "expxp" ); local explevel = getElementData ( lp, "explevel" ); local q = dbQuery( createDB, "SELECT * FROM save WHERE login=?", login ) local result = dbPoll( q, -1 ) dbFree(q) if #result == 0 then dbExec( createDB, "INSERT INTO save (login, money, explevel, expxp) VALUES (?,?,?,?)", login, money, explevel, expxp ) else dbExec( createDB, "UPDATE save SET login=?, money=?, explevel=?, expxp=?", login, money, explevel, expxp ) end end addEventHandler( "onPlayerQuit", getRootElement(), onPlayerQuit ) addEventHandler( "onPlayerWanted", getRootElement(), onPlayerQuit ) addEventHandler ( "onResourceStop",resourceRoot, function () for i , v in ipairs (getElementType("player")) do local pl = getPlayerAccount (v) if isGuestAccount(pl) then return end local login = getAccountName (v) local money = getPlayerMoney (v) local expxp = getElementData (v, "expxp" ); local explevel = getElementData (v, "explevel" ); local q = dbQuery( createDB, "SELECT * FROM save WHERE login=?", login ) local result = dbPoll( q, -1 ) dbFree(q) if #result == 0 then dbExec( createDB, "INSERT INTO save (login, money, explevel, expxp) VALUES (?,?,?,?)", login, money, explevel, expxp ) else dbExec( createDB, "UPDATE save SET login=?, money=?, explevel=?, expxp=?", login, money, explevel, expxp ) end end end ) 1 Link to comment
Markn1 Posted September 23, 2017 Author Share Posted September 23, 2017 8 minutes ago, Ahmed Ly said: try Woow! Thanks bro! ♥ Link to comment
Markn1 Posted September 23, 2017 Author Share Posted September 23, 2017 19 minutes ago, Ahmed Ly said: try stop resource and photo (debugscript 3 ) Link to comment
Ahmed Ly Posted September 23, 2017 Share Posted September 23, 2017 addEventHandler ( "onResourceStop",resourceRoot, function () for _,v in ipairs ( getElementsByType ( "player" ) ) do local pl = getPlayerAccount (v) if isGuestAccount(pl) then return end local login = getAccountName (v) local money = getPlayerMoney (v) local expxp = getElementData (v, "expxp" ); local explevel = getElementData (v, "explevel" ); local q = dbQuery( createDB, "SELECT * FROM save WHERE login=?", login ) local result = dbPoll( q, -1 ) dbFree(q) if #result == 0 then dbExec( createDB, "INSERT INTO save (login, money, explevel, expxp) VALUES (?,?,?,?)", login, money, explevel, expxp ) else dbExec( createDB, "UPDATE save SET login=?, money=?, explevel=?, expxp=?", login, money, explevel, expxp ) end end end ) oh sorry I wrote getElementType must be getElementsByType try that Link to comment
!#NssoR_) Posted September 24, 2017 Share Posted September 24, 2017 ENG : Please don't speak any different language than Arabic, you can go to Scripting section or you can find your native language by clicking here. AR : رجاء اخي لايجب عليك مساعدة اي شخص يتحدث لغة غير العربية حتي لو كان اجنبي لأن لديهم قسم يختص بلغتهم او يمكنه الذهاب لقسم البرمجة الانجليزية 2 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