taha201100 Posted March 31, 2016 Share Posted March 31, 2016 السلام عليكم لي 4 ايام اشتغل على متجر اسلحة وخلصته باقي ابيه لما يموت يحفظ الاسلحة يلي اشتراها ولو قفل ورجع تبقى بالحساب وش احتاج فنكشنات واكتبوا كل فنكشن وش حقه يسوي Link to comment
YourMind Posted March 31, 2016 Share Posted March 31, 2016 'onPlayerQuit' 'onPlayerWasted' setAccountData or executeSQLQuery بس الاحسن ليك طبعاً استخدم الاكونت داتا Link to comment
taha201100 Posted March 31, 2016 Author Share Posted March 31, 2016 وش اخر فنكشنين ما فهمت وش يسوون بالضبط Link to comment
iMr.WiFi..! Posted March 31, 2016 Share Posted March 31, 2016 (edited) 'onClientPlayerWasted' -- حدث لو اللاعب مات executeSQLQuery -- احفظ الاسلحة 'onPlayerQuit' -- حدث اذا لاعب خرج executeSQLQuery -- احفظ الاسلحة 'onPlayerLogin' --حدث اذا لاعب سجل executeSQLQuery -- احفظ الاسلحة Edited March 31, 2016 by Guest Link to comment
SycroX Posted March 31, 2016 Share Posted March 31, 2016 اخر 2 للحفظ + اضيف لهم getAccountData 'onPlayerLogin' -- عشان لما يسجل يرجع له اسلحتو Link to comment
taha201100 Posted March 31, 2016 Author Share Posted March 31, 2016 ةاي فاي ليه يعطيه سلاح كيف اخليه يعطيه اسلحتة السابقة يعني يتحقق Link to comment
YourMind Posted March 31, 2016 Share Posted March 31, 2016 لو تدوور بس في قسم دروس في البرمجة في ناس الله يباركلهم عاملين شروحات كتيرة هاتستفاد منها ElementData https://forum.multitheftauto.com/viewtopic.php?f=164&t=62041&hilit=data&sid=226c39d8dc682e81d37a34a0b1898c74 AccountData https://forum.multitheftauto.com/viewtopic.php?f=164&t=62247&p=592815&hilit=data+account&sid=226c39d8dc682e81d37a34a0b1898c74#p592815 هاتحتاج في طريقك فنكشن يجيبلك اسلحة الاعب كلها https://wiki.multitheftauto.com/wiki/GetPedWeapons الحفظ بالأكونت داتا و الالمنت داتا سهل ماتصعبهاش علي نفسك Link to comment
SycroX Posted March 31, 2016 Share Posted March 31, 2016 'onClientPlayerWasted' -- حدث لو اللاعب مات executeSQLQuery -- احفظ الاسلحة triggerServerEvent -- سوي تريقر لل سيرفر giveWeapon -- نعطيه السلاح 'onClientPlayerQuit' -- حدث اذا لاعب خرج executeSQLQuery -- احفظ الاسلحة 'onClientPlayerJoin' --حدث اذا لاعب دخل triggerServerEvent -- سوي تريقر لل سيرفر giveWeapon -- نعطيه السلاح ليه كلنت للسيرفر مو لازم يقدر يسويه كلو سيرفر مثال بسيط يحفظ لك السلاح الي الأيدي حقو 2 function saveAccount(source) account = getPlayerAccount(source) if account then setAccountData(account, "WeaponID2", getPedWeapon(source, 2)) setAccountData(account, "Ammo2", getPedTotalAmmo(source, 2)) else setAccountData(account, "WeaponID2", getPedWeapon(source, 2)) setAccountData(account, "Ammo2", 100) end end addEventHandler ( "onPlayerQuit", root, function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then for slot = 1, 12 do setAccountData(account, "WeaponID"..slot, getPedWeapon(source, slot)) setAccountData(account, "Ammo"..slot, getPedTotalAmmo(source, slot)) end end if not isGuestAccount(getPlayerAccount(source)) then saveAccount(source) end end) addEventHandler ( "onPlayerLogout", root, function () local account = getPlayerAccount(source) if account and not isGuestAccount(account) then for slot = 1, 12 do setAccountData(account, "WeaponID"..slot, getPedWeapon(source, slot)) setAccountData(account, "Ammo"..slot, getPedTotalAmmo(source, slot)) end end if not isGuestAccount(getPlayerAccount(source)) then saveAccount(source) end end) addEventHandler("onPlayerLogin", root, function(_, account) for slot = 1, 12 do local wep = getAccountData(account, "WeaponID"..slot) local ammo = getAccountData(account, "Ammo"..slot) if wep and ammo then giveWeapon(source, wep, ammo) end end end) addEventHandler ( "onPlayerWasted", root, function () local account = getPlayerAccount(source) if account and not isGuestAccount(account) then for slot = 1, 12 do setAccountData(account, "WeaponID"..slot, getPedWeapon(source, slot)) setAccountData(account, "Ammo"..slot, getPedTotalAmmo(source, slot)) end end end) addEventHandler("onPlayerSpawn", root, function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then for slot = 1, 12 do local wep = getAccountData(account, "WeaponID"..slot) local ammo = getAccountData(account, "Ammo"..slot) if wep and ammo then giveWeapon(source, wep, ammo) end end end end) Link to comment
taha201100 Posted April 1, 2016 Author Share Posted April 1, 2016 ليه ما يحفظ السلاح addEventHandler('onPlayerQuit',root, function() get = getPlayerAccount(source) if not get or isGuestAccount(get) then return end setAccountData(get,'sss',getPedWeapons ( source )) end ) addEventHandler('onPlayerLogin',root, function(aa) data = getAccountData(aa,'sss') if ( data ) then giveWeapon(source, data ) end end ) Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 ليه ما يحفظ السلاح addEventHandler('onPlayerQuit',root, function() get = getPlayerAccount(source) if not get or isGuestAccount(get) then return end setAccountData(get,'sss',getPedWeapons ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if not get1 and isGuestAccount(get) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function(aa) data = getAccountData(aa,'sss') if ( data ) then giveWeapon(source, data ) end end ) Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 (edited) فيه مشكلة انه مايتعدل جرب ذذ لو ماشتغل الي فوق addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if not get1 and isGuestAccount(get1) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) Edited April 1, 2016 by Guest Link to comment
Ahmed Ly Posted April 1, 2016 Share Posted April 1, 2016 ليه ما يحفظ السلاح addEventHandler('onPlayerQuit',root, function() get = getPlayerAccount(source) if not get or isGuestAccount(get) then return end setAccountData(get,'sss',getPedWeapons ( source )) end ) addEventHandler('onPlayerLogin',root, function(aa) data = getAccountData(aa,'sss') if ( data ) then giveWeapon(source, data ) end end ) addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if not get1 and isGuestAccount(get1) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 ليه ما يحفظ السلاح addEventHandler('onPlayerQuit',root, function() get = getPlayerAccount(source) if not get or isGuestAccount(get) then return end setAccountData(get,'sss',getPedWeapons ( source )) end ) addEventHandler('onPlayerLogin',root, function(aa) data = getAccountData(aa,'sss') if ( data ) then giveWeapon(source, data ) end end ) addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if not get1 and isGuestAccount(get1) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) شوف حقي مافي فرق Link to comment
Ahmed Ly Posted April 1, 2016 Share Posted April 1, 2016 ليه ما يحفظ السلاح addEventHandler('onPlayerQuit',root, function() get = getPlayerAccount(source) if not get or isGuestAccount(get) then return end setAccountData(get,'sss',getPedWeapons ( source )) end ) addEventHandler('onPlayerLogin',root, function(aa) data = getAccountData(aa,'sss') if ( data ) then giveWeapon(source, data ) end end ) addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if not get1 and isGuestAccount(get1) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) شوف حقي مافي فرق isGuestAccount(get) شوف كودك Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 شكراً عتصحيح الحين صار مافي فرق فرق .. Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 addEventHandler('onPlayerQuit',root, function() get1 = getPlayerAccount(source) if get1 and not isGuestAccount(get1) then return end setAccountData(get1,'sss',getPedWeapon ( source )) end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(source,'sss') if ( data ) then giveWeapon(source, data ) end end ) جرب ,, Link to comment
iMr.WiFi..! Posted April 1, 2016 Share Posted April 1, 2016 or gc = {} function getPedWeapons(ped) local playerWeapons = {} if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep ~= 0 then table.insert(playerWeapons,wep) end end else return false end return playerWeapons end addEventHandler('onPlayerQuit',root, function() gc = getPedWeapons(player) for i,k in ipairs(gc) do setAccountData(player,'sss',gc) end end ) addEventHandler('onPlayerLogin',root, function() data = getAccountData(player,'sss') if ( data ) then giveWeapon(player, data ) end end ) Link to comment
#CroSs Posted April 1, 2016 Share Posted April 1, 2016 (edited) function GetPlayerWeapons( Player ) local Weapons = {} for WeaponSlot = 1, 12 do local Weapon = getPedWeapon( Player, WeaponSlot ) if ( Weapon ~= 0 ) then Weapons[WeaponSlot] = { ID = Weapon, Ammo = getPedTotalAmmo( Player, WeaponSlot ) } end end return Weapons end function GivePlayerWeapons( Player, WeaponsTable ) for WeaponSlot = 1, 12 do local Weapon = WeaponsTable[WeaponSlot] or WeaponsTable[tostring( WeaponSlot )] if ( Weapon ) then giveWeapon( Player, Weapon["ID"], Weapon["Ammo"], true ) end end end local Players = getElementsByType( "player" ) for Index = 1, #Players do local Player = Players[Index] local PlayerAccount = getPlayerAccount( Player ) takeAllWeapons( Player ) if ( not isGuestAccount( PlayerAccount ) ) then local Weapons = getAccountData( PlayerAccount, "Weapons" ) if ( Weapons ) then GivePlayerWeapons( Player, fromJSON( Weapons ) ) end end end addEventHandler( "onPlayerLogin", root, function( _, Account ) takeAllWeapons( source ) local Weapons = getAccountData( Account, "Weapons" ) if ( Weapons ) then GivePlayerWeapons( source, fromJSON( Weapons ) ) end end ) function SavePlayerWeapons( Account, _, _, Player ) local Boolean, Player = eventName == "onPlayerLogout", Player or source Account = Boolean and Account or getPlayerAccount( Player ) if ( Boolean or not isGuestAccount( Account ) ) then setAccountData( Account, "Weapons", toJSON( GetPlayerWeapons( Player ) ) ) if ( Boolean ) then takeAllWeapons( Player ) end end end addEventHandler( "onPlayerLogout", root, SavePlayerWeapons ) addEventHandler( "onPlayerQuit", root, SavePlayerWeapons ) addEventHandler( "onResourceStop", resourceRoot, function() local Players = getElementsByType( "player" ) for Index = 1, #Players do SavePlayerWeapons( nil, nil, nil, Players[Index] ) end end ) addEventHandler( "onPlayerWasted", root, function() local Weapons = GetPlayerWeapons( source ) local function GiveWeaponsOnSpawn() GivePlayerWeapons( source, Weapons ) removeEventHandler( "onPlayerSpawn", source, GiveWeaponsOnSpawn ) end addEventHandler( "onPlayerSpawn", source, GiveWeaponsOnSpawn ) end ) Edited April 2, 2016 by Guest Link to comment
taha201100 Posted April 2, 2016 Author Share Posted April 2, 2016 ولا واحد يحفظ لول وش بكم 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