Jump to content

[Help] Save score in player account


SoulEaterX

Recommended Posts

    exports.scoreboard:scoreboardAddColumn( "score" ) 
    function xcore () 
       zcore = getElementData(source,"score") or 0 
       setElementData(source,"score",zcore+5) 
    end 
    addEvent("onPlayerWasted",true) 
    addEventHandler("onPlayerWasted",getRootElement(),xcore) 

Link to comment
exports.scoreboard:scoreboardAddColumn( "score" ) 
  
function xcore () 
    zcore = getElementData ( source, "score" ) or 0 
    setElementData ( source, "score", zcore + 5 ) 
end 
addEvent("onPlayerWasted",true) 
addEventHandler("onPlayerWasted",getRootElement(),xcore) 
  
addEventHandler ( 'onPlayerQuit', root, 
    function ( ) 
        local account = getPlayerAccount ( source ) 
        local getScore = getElementData ( source, 'score' ) or 0 
        if ( account ) and not ( isGuestAccount ( account ) ) then 
            setAccountData ( account, 'scoreSave', getScore ) 
        end 
    end 
) 
  
addEventHandler ( 'onPlayerLogin', root, 
    function ( _, account ) 
        if ( account ) then 
            local scoreLoad = getAccountData ( account, 'scoreSave' ) 
            if ( scoreLoad ) then 
                setElementData ( source, 'score', scoreLoad )  
            end 
        end 
    end 
) 

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