Jump to content

سكربت حفظ السلحة كل ما امووت يدبل الرصاص ارجو ححل


D7mas

Recommended Posts

السلام عليكم ورحمة الله

 

انا عندي مود حفظ لالسلحة في السيرفر , لما اموت 10 مرات اسلحتي تبطل تنتهي ممكن تصلحو 

 


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
local LauncherAmount = getElementData(source, "Launcher") or 0
setAccountData(account, "Launcher", LauncherAmount)
end

end)

--------------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------------
addEventHandler("onPlayerLogin", root,
function(_, account)
local LauncherAmount = getAccountData(account, "Launcher") or 0
setElementData(source, "Launcher", LauncherAmount)
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

بدل هذا بـ حدث الموت + السباون لكن الخروج والدخول خله زي ماهو

local playerWeapons = { }

addEventHandler ( "onPlayerWasted", root,
	function ( )
		if ( not playerWeapons [ source ] ) then
			playerWeapons [ source ] = { }
		end
		for slot = 0, 12 do
			local weapon = getPedWeapon ( source, slot )
			if ( weapon > 0 ) then
				local ammo = getPedTotalAmmo ( source, slot )
				if ( ammo > 0 ) then
					playerWeapons [ source ] [ weapon ] = ammo
				end
			end
		end
	end
)

addEventHandler ( "onPlayerSpawn", root,
	function ( )
		if ( playerWeapons [ source ] ) then
			for weapon, ammo in pairs ( playerWeapons [ source ] ) do
				giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) )
			end
		end

		playerWeapons [ source ] = nil
	end
)

 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...