Jump to content

how to save weaon stats onwasted [Help]


slotman

Recommended Posts

function saveWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local stats = "" 
        for stat=69, 81 do 
            local value = getPedStat(player, stat) 
            stats = stats ..",".. stat ..";".. value 
        end 
        setAccountData(account, "weaponStats", stats) 
    end 
end 
  
function loadWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local statsData = getAccountData(account,"weaponStats") 
        local stats = split(statsData, ",") 
        for k, v in ipairs(stats) do 
            local stat = split(v, ";") 
            setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) 
        end 
    end 
end 
  
addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) 
addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) 

onPlayerWasted No saveing

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...