Jump to content

Help Save score.


Estevam2d

Recommended Posts

Guys, when I leave the game my points gains disappear

This script is the community and I'm not very good at DATE

How can I solve?

Help Save score

exports.scoreboard:addScoreboardColumn('Score') 
addEventHandler ( 'onPlayerWasted', root, 
function ( attacker ) 
    if ( attacker ) and ( attacker ~= source ) then 
    local sScore = getElementData(source, 'Score') or 0 
    local aScore = getElementData(attacker, 'Score') or 0 
    setElementData(source, 'Score', sScore -1) 
    setElementData(attacker, 'Score', aScore +1) 
 end 
end 
) 
  
function myscore(player) 
    local MyScore = getElementData(player, "Score") or 0 
    outputChatBox("Your score is "..tostring(MyScore), player, 0, 255, 0) 
end 
addCommandHandler("myscore", myscore) 

Link to comment
  
function saveLogoutStats(theAccount) 
local currentScore = getElementData(source, "Score") 
setAccountData(theAccount, "account_score", currentScore) 
setElementData(source, "Score", 0) 
end 
addEventHandler("onPlayerLogout", root, saveLogoutStats) 
  
function saveStatsOnQuit() 
local currentScore = getElementData(source, "Score") 
setAccountData(getPlayerAccount(source), "account_score", currentScore) 
end 
addEventHandler("onPlayerQuit", root, saveStatsOnQuit) 
  
function loadStats(oldAccount, newAccount) 
if not isGuestAccount(newAccount) then 
setElementData(source, "Score", getAccountData(newAccount, "account_score") 
end 
end 
addEventHandler("onPlayerLogin", root, loadStats) 
  

This should work.

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