kalyn Posted August 20, 2012 Share Posted August 20, 2012 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
Guest Guest4401 Posted August 20, 2012 Share Posted August 20, 2012 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. Link to comment
kalyn Posted August 20, 2012 Author Share Posted August 20, 2012 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
sockz Posted August 20, 2012 Share Posted August 20, 2012 An extra end on line 19 might cause some problems to you. Link to comment
kalyn Posted August 20, 2012 Author Share Posted August 20, 2012 An extra end on line 19 might cause some problems to you. The extra end was put by me from mistake but in the original code that I made it was no extra end Link to comment
kalyn Posted August 20, 2012 Author Share Posted August 20, 2012 and on server comand window it says: "attempt to call global 'getScore' " Link to comment
sockz Posted August 20, 2012 Share Posted August 20, 2012 I see (I meant bracket before btw), but I'm curious too, what is getScore and setScore? Link to comment
kalyn Posted August 21, 2012 Author Share Posted August 21, 2012 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
Castillo Posted August 21, 2012 Share Posted August 21, 2012 Because these functions does not exist. Link to comment
kalyn Posted August 21, 2012 Author Share Posted August 21, 2012 Because these functions does not exist. Yes but must be a way that makes the score to be saved, it exactly the same like Level in RolePlay Link to comment
Castillo Posted August 22, 2012 Share Posted August 22, 2012 For temporal data you can use: setElementData and getElementData. 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