This "bug" happens because you save it into one variable only. So you always overwrite the previous one.
You should do same as weapons save, something like that:
local playerSkins = {} -- save player's skin in the table, when player dies
addEventHandler ( "onPlayerWasted", root,
function ( )
playerSkins[source] = tonumber(getElementModel(source))
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
if (weapon == 37) then
ammo = ammo/10
end
playerWeapons [ source ] [ weapon ] = ammo
end
end
end
end
)
addEventHandler ( "onPlayerSpawn", root,
function ( )
if ( playerWeapons [ source ] ) then
if getElementData(source, "selecting") == nil then
setElementModel(source, playerSkins[source] or 0)
for weapon, ammo in pairs ( playerWeapons [ source ] ) do
giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) )
end
end
end
playerWeapons [ source ] = nil
end
)