function savePlayerWeapons()
ammoPlayer = {}
playerWeapons = {}
for i=1,12 do
local amo=getPedAmmoInClip (source, i)
if amo and amo ~= 0 then
ammoPlayer[i] = amo
end
end
for i=1,12 do
local wep = getPedWeapon(source,i)
if wep and wep ~= 0 then
playerWeapons[i] = wep
end
end
setAccountData(getPlayerAccount ( source ), "ammo", ammoPlayer)
setAccountData(getPlayerAccount ( source ), "weapons", playerWeapons)
end
addEventHandler("onPlayerQuit", root, savePlayerWeapons)
addEventHandler("onPlayerWasted", root, savePlayerWeapons)
function poi()
if not isGuestAccount(getPlayerAccount(source)) then
wapon = getAccountData(getPlayerAccount(source), "weapons")
aimo = getAccountData(getPlayerAccount(source), "ammo")
for i,wapon in ipairs(playerWeapons) do
giveWeapon (source, wapon, aimo[i])
end
end
end
addEventHandler("onPlayerSpawn", root, poi)
Much cleaner code. The changes I made are a lot and I advise you to read this and this.
And after those two, read this.