You forgot much thing try this on wasted and on spawn replace your with this :
addEventHandler ( "onPlayerWasted", root,
function ( )
local account = getPlayerAccount ( source )
if ( account and not isGuestAccount ( account ) ) then
for slot = 1, 12 do
setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) )
setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) )
end
local team = getPlayerTeam ( source )
if ( team ) then
setAccountData ( account, "save-team", getTeamName ( team ) )
local wanted = getPlayerWantedLevel ( source )
if wanted then
setAccountData ( account,"save-wanted",wanted )
end
end
end
end
)
addEventHandler ( "onPlayerSpawn", root,
function ( )
local account = getPlayerAccount ( source )
if ( account and not isGuestAccount ( account ) ) then
local team = getTeamFromName ( getAccountData ( account, "save-team" ) )
if ( team ) then
setPlayerTeam ( source, team )
else
outputChatBox ( "Get a Job NOOB", source )
end
for slot = 1, 12 do
local wep = getAccountData ( account, "save-wep".. slot )
local ammo = getAccountData ( account, "save-ammo".. slot )
giveWeapon ( source, wep, ammo )
if (accountData) then
local playerWanted = getAccountData (account, "save-wanted")
setPlayerWantedLevel ( source,playerWanted or 0 )
end
end
end
)