اسلام عليكم ورحمه الله وبركاته
سويت كود حفظ الفلوس بالداتا باس
الكود اشتغل بس
مثلا عندي حساب بالسيرفر فيه 100
وحساب ثاني فيه 200
لما اطلع من السيرفر وانا بالحساب الاول وادخل بالثاني الاقي الفلوس 100
اتمني فهمتو
الكود
addEventHandler('onResourceStart',resourceRoot,
function ( )
db = dbConnect("sqlite", "saveacc.db")
dbExec(db,"CREATE TABLE IF NOT EXISTS MoneySaveE (account_name,account_money)")
end)
addEventHandler("onPlayerQuit",root,
function ()
local account = dbPoll(dbQuery(db, "SELECT * FROM MoneySaveE WHERE account_name=?"), -1)
if ( type ( account ) == "table"and #account == 0 or not account ) then
dbExec(db, "INSERT INTO `MoneySaveE` (account_name,account_money ) VALUES(?,?)", getPlayerAccount(source),getPlayerMoney(source))
else
dbExec(db, "UPDATE MoneySaveE SET account_money = ? WHERE account_name = ?",getPlayerMoney(source),getPlayerAccount ( source ))
end
end)
addEventHandler("onPlayerLogin",root,
function ()
local p = dbQuery(db, "SELECT * FROM MoneySaveE WHERE account_name=?", getPlayerAccount(source))
local account = dbPoll(p, -1)
if ( type ( account ) == "table"and #account == 0 or not account ) then return end
setPlayerMoney(source,account[1]['account_money'])
end)
والسلام عليكم