ايهاب Posted April 6, 2021 Share Posted April 6, 2021 (edited) سلام عليكم مود حفظ الفلوس دة شغال لكن اما اعمل شيدون للسيرفر واشغلة الفلوس تتصفر هناك حل ؟ حد يصححة او يضيف دالة حفظ الفلوس عند اغلاق السيرفر ماتتصفر وجزاكم ولله خير function playerQuit() local playerAcc = getPlayerAccount(source) if ( playerAcc ) then -- You we're checking if (playeraccount == true) then, but your variable name is "playeracc". local playerCash = getPlayerMoney(source) setAccountData(playerAcc, "cash", playerCash) setPlayerMoney(source, 0) end end addEventHandler("onPlayerQuit", getRootElement(), playerQuit) addEventHandler("onPlayerLogout", getRootElement(), playerQuit) function playerLogin() local playerAcc = getPlayerAccount(source) if (playerAcc) then local playerBank = getAccountData(playerAcc, "cash") if (playerBank) then setPlayerMoney(source, tonumber(playerBank)) else outputChatBox("You are broke.", source, 255, 0, 0) end end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin) Edited April 6, 2021 by ايهاب Link to comment
AL-MR3B Posted April 6, 2021 Share Posted April 6, 2021 لانك حفظت الفلوس على حساب اللاعب لازم تحفظها على قاعدة البيانات اذا تبيها ما تنمسح 1 Link to comment
ايهاب Posted April 6, 2021 Author Share Posted April 6, 2021 l مش هعرف اعملها هى صعبة .. Link to comment
Scripting Moderators xLive Posted April 6, 2021 Scripting Moderators Share Posted April 6, 2021 (edited) 5 hours ago, AL-MR3B said: لانك حفظت الفلوس على حساب اللاعب لازم تحفظها على قاعدة البيانات اذا تبيها ما تنمسح registry.db كلامك خطأ الاكونت داتا تنحفظ بقاعدة السيرفر الالتمت داتا هي يلي ماتنحفظ في حال الخروج @ايهاب لازم تستخدم حدث إذا المود إنغلق حسب ماتذكر إنه يشتغل في حال السيرفر صار له شت داون/ريستارت onResourceStop تسوي لوب لجميع الاعبين باستخدام getElementsByType وتسوي اكواد الحفظ نفسها فيه حل أخر بديهي انك تطرد الاعبين قبل ماترستت او تسوي شت داون مستقبلاً لو بتفتح موضوع يخص البرمجة افتحه بالقسم الخاص بالبرمجة Edited April 6, 2021 by xLive 1 Link to comment
TAPL Posted April 6, 2021 Share Posted April 6, 2021 ممكن يتوقف السيرفر عن العمل بشكل مفاجئ لأي سبب كان مثل تعطل الخادم الذي يستضيف السيرفر ولذلك يجب حفظ الفلوس في الأكاونت داتا او اي كانت طريقة الحفظ المستخدمة في جميع الأوقات عند حدوث اي زيادة او نقصان في الفلوس 1 Link to comment
ايهاب Posted April 7, 2021 Author Share Posted April 7, 2021 16 hours ago, TAPL said: ممكن يتوقف السيرفر عن العمل بشكل مفاجئ لأي سبب كان مثل تعطل الخادم الذي يستضيف السيرفر ولذلك يجب حفظ الفلوس في الأكاونت داتا او اي كانت طريقة الحفظ المستخدمة في جميع الأوقات عند حدوث اي زيادة او نقصان في الفلوس طب مفيش اى مود تعرفة يحل المشكلة دى ولا لازم تدخل برمجى لان صاحبى المبرمج مشغول فى الوقت االحالى وانا عايز احل المشكلة دى عشا افتح السيررفر Link to comment
ايهاب Posted April 7, 2021 Author Share Posted April 7, 2021 (edited) ضفت الكود دة سرقتة من كود بس عدلت فية ضفتك جيت بلاير مونى وكلمة مونر فى الاخير لو اللاعب دخل وجمع فلوس والسيرفر رستار لكن قبل مايستر خرج من السيرفر الفلوس مش تتصفر لكن لو اللاعب دخل السيرفر وجمع فلوس وحصل رستارت قبل ما يخرج من السيرفر الفلوس تتصفر لكن هو نظام القيم مود معايا كدة الفلوس بس كانت بتتصفر فى مود سرقة المحلات عشان خارج الباك اب بتاع صاحبى يعنى حاليا يمشى الحال كدة addEventHandler("onPlayerQuit", root, function() setPlayerTeam(source, nil) local playeraccount = getPlayerAccount(source) if playeraccount and not isGuestAccount(playeraccount) then setAccountData(playeraccount, "s.weap0", getPedWeapon(source, 0)) setAccountData(playeraccount, "s.weap1", getPedWeapon(source, 1)) setAccountData(playeraccount, "s.weap2", getPedWeapon(source, 2)) setAccountData(playeraccount, "s.ammo2", getPedTotalAmmo(source, 2)) setAccountData(playeraccount, "s.weap3", getPedWeapon(source, 3)) setAccountData(playeraccount, "s.ammo3", getPedTotalAmmo(source, 3)) setAccountData(playeraccount, "s.weap4", getPedWeapon(source, 4)) setAccountData(playeraccount, "s.ammo4", getPedTotalAmmo(source, 4)) setAccountData(playeraccount, "s.weap5", getPedWeapon(source, 5)) setAccountData(playeraccount, "s.ammo5", getPedTotalAmmo(source, 5)) setAccountData(playeraccount, "s.weap6", getPedWeapon(source, 6)) setAccountData(playeraccount, "s.ammo6", getPedTotalAmmo(source, 6)) setAccountData(playeraccount, "s.weap7", getPedWeapon(source, 7)) setAccountData(playeraccount, "s.ammo7", getPedTotalAmmo(source, 7)) setAccountData(playeraccount, "s.weap8", getPedWeapon(source, 8)) setAccountData(playeraccount, "s.ammo8", getPedTotalAmmo(source, 8)) setAccountData(playeraccount, "s.weap9", getPedWeapon(source, 9)) setAccountData(playeraccount, "s.ammo9", getPedTotalAmmo(source, 9)) setAccountData(playeraccount, "s.weap10", getPedWeapon(source, 10)) setAccountData(playeraccount, "s.weap11", getPedWeapon(source, 11)) setAccountData(playeraccount, "Money", getPlayerMoney(source, 12)) setAccountData(playeraccount, "WantedLevel", getPlayerWantedLevel(source)) end end) Edited April 7, 2021 by ايهاب Link to comment
Ahmed Ly Posted April 7, 2021 Share Posted April 7, 2021 (edited) function playerQuit() local playerAcc = getPlayerAccount(source) if ( playerAcc ) then local playerCash = getPlayerMoney(source) setAccountData(playerAcc, "cash", playerCash) setPlayerMoney(source, 0) end end addEventHandler("onPlayerQuit", getRootElement(), playerQuit) addEventHandler("onPlayerLogout", getRootElement(), playerQuit) function playerLogin() local playerAcc = getPlayerAccount(source) if (playerAcc) then local playerBank = getAccountData(playerAcc, "cash") if (playerBank) then setPlayerMoney(source, tonumber(playerBank)) else outputChatBox("You are broke.", source, 255, 0, 0) end end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin) addEventHandler("onResourceStop",resourceRoot, function () for k,player in ipairs(getElementsByType("player")) do local account = getPlayerAccount(player) if (account) then local moeny = getPlayerMoney(player) setAccountData(account, "cash", moeny) setPlayerMoney(player, 0) end end end ) addEventHandler("onResourceStart",resourceRoot, function () for k,player in ipairs(getElementsByType("player")) do local datamoney = getAccountData(player,"cash") if (datamoney) then setPlayerMoney(player, tonumber(datamoney)) end end end ) Edited April 7, 2021 by Ahmed Ly Link to comment
ايهاب Posted April 8, 2021 Author Share Posted April 8, 2021 (edited) 10 hours ago, Ahmed Ly said: function playerQuit() local playerAcc = getPlayerAccount(source) if ( playerAcc ) then local playerCash = getPlayerMoney(source) setAccountData(playerAcc, "cash", playerCash) setPlayerMoney(source, 0) end end addEventHandler("onPlayerQuit", getRootElement(), playerQuit) addEventHandler("onPlayerLogout", getRootElement(), playerQuit) function playerLogin() local playerAcc = getPlayerAccount(source) if (playerAcc) then local playerBank = getAccountData(playerAcc, "cash") if (playerBank) then setPlayerMoney(source, tonumber(playerBank)) else outputChatBox("You are broke.", source, 255, 0, 0) end end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin) addEventHandler("onResourceStop",resourceRoot, function () for k,player in ipairs(getElementsByType("player")) do local account = getPlayerAccount(player) if (account) then local moeny = getPlayerMoney(player) setAccountData(account, "cash", moeny) setPlayerMoney(player, 0) end end end ) addEventHandler("onResourceStart",resourceRoot, function () for k,player in ipairs(getElementsByType("player")) do local datamoney = getAccountData(player,"cash") if (datamoney) then setPlayerMoney(player, tonumber(datamoney)) end end end ) شكرا لتقديك المساعدة بس لما بيحصل رستارت للمود الى محطوط فية كود الفلوس الفلوس بتتصفر ,kt ونفس المشكلة Edited April 8, 2021 by ايهاب Link to comment
ايهاب Posted April 9, 2021 Author Share Posted April 9, 2021 (edited) شباب دة ملف الداتا بتاعت الحفظ فى الباك اب الى معايا @ Ahmed Ly @xlive هل فى شى من هنا السبب Datas, Query = { 'Money', 'Jewelers', 'Level', 'Exp', 'Hours', 'Bank', 'Gang-P', 'Police-P' }, executeSQLQuery function getJSON( Player ) local Save = { } for _, v in ipairs( Datas ) do table.insert( Save, getElementData( Player, v ) or 0 ) end return toJSON( Save ) end Query( 'CREATE TABLE IF NOT EXISTS SaveSystem ( Serial, Data )' ) for _, Player in ipairs( getElementsByType( 'player' ) ) do setTimer( setPedWalkingStyle, 50, 1, Player, 0 ) local Serial, JSON = getPlayerSerial( Player ), getJSON( Player ) if ( #Query( 'SELECT * FROM SaveSystem WHERE Serial = ?', Serial ) == 0 ) then Query ( 'INSERT INTO SaveSystem VALUES ( ? , ? ) ', Serial, JSON ) end end addEventHandler( 'onElementDataChange', root, function( aData, Old, New ) if ( getElementType( source ) == 'player' ) then for _, Value in ipairs( Datas ) do if ( aData == Value ) then setAccountData( getPlayerAccount( source ), aData, New ) end end end end ) addEventHandler( 'onPlayerLogin', root, function( _, Account ) setTimer( function( source ) if ( not isElement( source ) ) then return end for _, Data in ipairs( Datas ) do local AccountData = getAccountData( Account, Data ) if ( AccountData ) then setElementData( source, Data, AccountData ) end end exports['guimessages']:outputServer( source, '#00FF00Your data has been retrieved' ) end , 1000, 1, source, Account ) end ) addEventHandler( 'onPlayerSpawn', root, function( ) for _, v in ipairs( Weapons ) do takeWeapon( source, v ) end setTimer( setPedWalkingStyle, 50, 1, source, 0 ) end ) addEventHandler( 'onPlayerQuit', root, function( ) local Account = getPlayerAccount( source ) if ( Account ) then for _, Data in ipairs( Datas ) do setAccountData( Account, Data, getElementData( source, Data ) ) end end end ) kill = { } addCommandHandler( 'kill', function( Player ) if ( isTimer( kill[Player] ) ) then killTimer( kill[Player] ) exports['guimessages']:outputServer( Player, '#FF0101The suicide process has been completed' ) setElementFrozen( Player, false ) return end exports['guimessages']:outputServer( Player, '#FCFF01You will die after : 10 Seconds' ) exports['guimessages']:outputServer( Player, '#FCFF01To cancel /kill' ) setElementFrozen( Player, true ) kill[Player] = setTimer ( function( Player ) if ( isElement( Player ) and not isPedDead( Player ) ) then killPed( Player ) setElementFrozen( Player, false ) end end , 1000 * 10, 1, Player ) end ) Weapons = { 4,36,38,35,37,42,5,6,7,8,9,10,11,12,13,15,14,18,41} addEventHandler( 'onPlayerWasted', root, function( _, Killer ) if ( isTimer( kill[source] ) ) then killTimer( kill[source] ) setElementFrozen( source, false ) kill[source] = nil end if ( Killer and getElementType( Killer ) == 'player' and getElementData( Killer, 'Mission' ) ) then if ( Killer and getElementType( Killer ) == 'player' ) then local Data = ( ( ( getTeamName( getPlayerTeam( Killer ) ) == 'Police' ) and 'Police-P' ) or 'Gang-P' ) setElementData( Killer, Data , ( getElementData( Killer, Data ) or 0 ) + 1 ) end end end ) addCommandHandler( '77', function( Player ) local Account = getElementData( Player, 'Account' ) if ( Account and hasObjectPermissionTo( 'user.' .. Account , 'general.adminpanel', true ) ) then for Index = 1, 35 do outputChatBox( ' ', root ) end exports['guimessages']:outputServer( root, '#FF0000Chats were cleaned By :#00FF00 ' .. getPlayerName( Player ) ) end end ) addEvent( 'VehicleFIX', true ) addEventHandler( 'VehicleFIX', root, function( ) local Money = getElementData( source, 'Money' ) or 0 if ( Money >= 5000 ) then local Vehicle = getPedOccupiedVehicle( source ) if ( Vehicle ) then fixVehicle( Vehicle ) setElementData( source, 'Money', Money - 5000 ) exports['guimessages']:outputServer( source, '#00FF00Your car has been repaired' ) else exports['guimessages']:outputServer( source, '#FF0000You do not have enough money' ) end end end ) createPed( 0, 2036.15, 1535.68, 10.82 ) Edited April 9, 2021 by ايهاب 1 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