Egor_Varaksa Posted January 20, 2021 Share Posted January 20, 2021 (edited) 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 January 20, 2021 by Egor_Varaksa Link to comment
NeXuS™ Posted January 20, 2021 Share Posted January 20, 2021 Because onPlayerLogout is called after the logout was successful, at that point the user is in the "guest" account. Check the wiki page for more info, you need to use the first argument of the event which is the previous account the user was in before logging out. Link to comment
Hydra Posted January 20, 2021 Share Posted January 20, 2021 Use this example from wiki: https://wiki.multitheftauto.com/wiki/SetAccountData Link to comment
WASSIm. Posted January 21, 2021 Share Posted January 21, 2021 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
Egor_Varaksa Posted January 21, 2021 Author Share Posted January 21, 2021 (edited) 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 January 21, 2021 by Egor_Varaksa Link to comment
SpecT Posted January 21, 2021 Share Posted January 21, 2021 3 minutes ago, Egor_Varaksa said: I want the player to be able to change their account without leaving the server, and all their data will be saved. Well you already got an answer from @WASSIm.. Link to comment
Egor_Varaksa Posted January 21, 2021 Author Share Posted January 21, 2021 12 hours ago, WASSIm. said: Параметры thePreviousAccount : учетная запись, под которой был выполнен вход клиентом. theCurrentAccount : учетная запись, частью которой сейчас является клиент (обычно гостевая учетная запись). it works, thank you 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