Estevam2d Posted October 6, 2014 Share Posted October 6, 2014 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
crismar Posted October 6, 2014 Share Posted October 6, 2014 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
Estevam2d Posted October 6, 2014 Author Share Posted October 6, 2014 thank you, that helped me a lot haha cool sorry bad english Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now