Jump to content

[HELP] I can't make the SCORE from CTF to be saved


kalyn

Recommended Posts

Hi guys!

I have tryied again and again to make the player Score saveable on player quit but I had no luck, can anyone give me a little script that makes that thing?! I must add that I have Login Panel so every player have an account, or can play as a guest (the score must not be saved for guests only for registered players)

Thanks!

Link to comment
You forgot to show us what you tried - the code. Without the code, the only thing I can tell you is use setAccountData to save data.

After this code that is working:

function onPlayerQuit() 
      local playerAccount = getPlayerAccount(source) 
      if (playerAccount) then 
            local playerMoney = getPlayerMoney(source) 
            setAccountData(playerAccount, "player.money", playerMoney) 
      end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) 
  
function onPlayerLogin() 
      local playerAccount = getPlayerAccount(source) 
      if (playerAccount) then 
            local playerMoney = getAccountData(playerAccount, "player.money") 
            if (playerMoney) then 
                  setPlayerMoney(source, playerMoney) 
            end 
      end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) 

I've tryed this:

function onPlayerQuit() 
      local playerAccount = getPlayerAccount(source) 
      if (playerAccount) then 
            local Score = getScore(source) 
            setAccountData(playerAccount, "player.score", Score) 
      end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) 
  
function onPlayerLogin() 
      local playerAccount = getPlayerAccount(source) 
      if (playerAccount) then 
            local Score = getAccountData(playerAccount, "player.score") 
            if (playerMoney) then 
                  setScore(source, Score) 
            end 
      end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin)) 

I have also tryed whyt PlayerScore instead of just score but none worked, the problem is that I don't get where is the problem or what I've done wrong....

The codes were written in the gamemode.lua and not as a resource.

Link to comment
I see (I meant bracket before btw), but I'm curious too, what is getScore and setScore?

Sincerely I don't know either but in the server functions on MTA wiki I would't been able to find something related to score so I just changet getPlayerMoney into getScore (I used getPlayerScore first but did't worked)

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