Jump to content

Money and health are not saved when you log out of your account


Egor_Varaksa

Recommended Posts

function save ()
  if not (isGuestAccount (getPlayerAccount (source))) then
    account = getPlayerAccount (source)
    if (account) then

      setAccountData (account, "money", tostring (getPlayerMoney (source)))
      setAccountData (account, "health", tostring (getElementHealth (source)))
    end
  end
end
addEventHandler ("onPlayerLogout", getRootElement(), save)

 

Edited by Egor_Varaksa
Link to comment
function save (account)
    setAccountData (account, "money", tostring (getPlayerMoney (source)))
    setAccountData (account, "health", tostring (getElementHealth (source)))
end
addEventHandler ("onPlayerLogout", getRootElement(), save)

Parameters

account thePreviousAccount, account theCurrentAccount
  • thePreviousAccount: the account the client was logged in as.
  • theCurrentAccount: the account the client is a part of now (usually a guest account).
Link to comment

I want the player to be able to change their account without leaving the server and all their data will be saved.

On some servers, when you enter the /logout command, the login panel appears, and you can log in to another account, and the data of the account you logged out of is saved

Edited by Egor_Varaksa
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...