WASSIm. Posted November 4, 2013 Share Posted November 4, 2013 EDIT مرحبا .انا بحاجة الى مساعدة debugscript: 112: dbExec failed; (1) no such table: moneys addEventHandler ( "onResourceStart", resourceRoot, function ( ) connection = dbConnect( "sqlite", ":server/databases/moneys.db" ) exports [ "scoreboard" ]:addScoreboardColumn ( "Money", root, 7, "Money", 6 ) if ( connection )then dbExec ( connection, "CREATE TABLE IF NOT EXISTS moneys (ID INTEGER PRIMARY KEY NOT NULL, account TEXT, Money INT)" ) outputDebugString ( "Successfully connected to moneys.db" ) else outputDebugString ( "Failed to connect to moneys.db", 3 ) end end ) addEventHandler("onResourceStart",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do local account = getPlayerAccount(player) if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) local money = getAccountMoney ( accountName ) if (account) then if not ( money ) then addMoneyToDatabase ( accountName ) setPlayerMoney(player, 0) else setPlayerMoney(player, tonumber(money)) end end end end) addEventHandler("onResourceStop",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do local money = getPlayerMoney(player) local account = getPlayerAccount(player) if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) if (account) then setAccountMoney(accountName, tonumber(money)) setPlayerMoney(player, 0) end end end) addEventHandler("onPlayerLogout",root, function (_,account) local money = getPlayerMoney(source) local accountName = getAccountName(account) setAccountMoney(accountName, money) setPlayerMoney(source, 0) end ) addEventHandler("onPlayerQuit",root, function ( ) local money = getPlayerMoney(source) local account = getPlayerAccount(source) if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) if (account) then setAccountMoney(accountName, money) setPlayerMoney(source, 0) end end ) addEventHandler("onPlayerLogin",root, function (_,account) local accountName = getAccountName(account) local handler = connection local money = getAccountMoney ( accountName ) if not ( money ) then addMoneyToDatabase ( accountName ) setPlayerMoney(source, 0) else local money = money setPlayerMoney(source, money) end end) function addMoneyToDatabase ( account ) local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end return dbExec( handler, "INSERT INTO moneys (ID, account, Money) VALUES (NULL, '".. tostring ( account ) .."', '0')" ) end function getAccountMoney ( account ) local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end local query = dbQuery ( handler, "SELECT * FROM moneys WHERE account = ?", tostring ( account ) ) local result, numrows, errmsg = dbPoll ( query, -1 ) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return tostring ( result[ 1 ][ "Money" ] ) end end function setAccountMoney ( account, theMoney ) local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end return dbExec( handler, "UPDATE moneys SET Money = '".. tostring ( theMoney ) .."' WHERE account = '" .. tostring ( account ) .."'" ) end Link to comment
TAPL Posted November 4, 2013 Share Posted November 4, 2013 ؟server متأكد ان عندك مود اسمه connection = dbConnect( "sqlite", ":server/databases/moneys.db" ) ؟global databases أو انت تبي تحط ملف الداتا بيس في مسار / إذا كذا لازم تحط server او لازم يكون عندك مود اسمه connection = dbConnect( "sqlite", ":/server/databases/moneys.db" ) عندك خطأ هنا addEventHandler("onPlayerLogout",root, function (_,account) البارتمار الثاني هو الحساب الي اللاعب حالياً داخل فيه بعد ما سجل خروج guest في الغالب بيكون حساب https://wiki.multitheftauto.com/wiki/OnPlayerLogout thePreviousAccount: The account the client was logged in astheCurrentAccount: The account the client is a part of now (usually a guest account) التعديل: addEventHandler("onPlayerLogout",root, function (account) ------------------ ينقل إلى قسم البرمجة ------------------ Link to comment
WASSIm. Posted November 4, 2013 Author Share Posted November 4, 2013 resource مثبت والمشكلة تظهر لي إذا توقف dbConnect Link to comment
WASSIm. Posted November 4, 2013 Author Share Posted November 4, 2013 dbConnect المشكلة ليست في :بل في function setAccountMoney ( account, theMoney ) local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end return dbExec( handler, "UPDATE moneys SET Money = '".. tostring ( theMoney ) .."' WHERE account = '" .. tostring ( account ) .."'" ) end Link to comment
TAPL Posted November 4, 2013 Share Posted November 4, 2013 جربت الكود و لم يظهر لي اي خطأ و الفلوس تنحفظ و كل شي شغال ممكن يكون عندك مشكلة في ملف قاعدة البيانات بسبب انك كنت تعدل بالكود جرب احذف ملف قاعدة البيانات و شغل المود من جديد عشان ينعمل ملف قاعدة بيانات جديد Link to comment
WASSIm. Posted November 4, 2013 Author Share Posted November 4, 2013 debugscript: 112: dbExec failed; (1) no such table: moneys Link to comment
TAPL Posted November 4, 2013 Share Posted November 4, 2013 تأكد ملف قاعدة البيانات موجود؟ Link to comment
WASSIm. Posted November 4, 2013 Author Share Posted November 4, 2013 تأكد ملف قاعدة البيانات موجود؟ أجل Link to comment
TAPL Posted November 4, 2013 Share Posted November 4, 2013 ارفعه على موقع و عطني الرابط Link to comment
WASSIm. Posted November 4, 2013 Author Share Posted November 4, 2013 http://www.mediafire.com/download/z08cz ... /moneys.db Link to comment
TAPL Posted November 4, 2013 Share Posted November 4, 2013 ._. لايوجد اي خطأ بملف قاعدة البيانات و الكود شغال عندي و مافيه أخطاء كيف انت يجي عندك خطأ! عطني الآي بي و البورت لسيرفرك 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