bartje01 Posted November 8, 2010 Share Posted November 8, 2010 Hey guys. I searched on wiki already on how to save money. I found something like ACL save but that is not what I need. I want to know how to save player's money when they relog. Can someone give me an example or wiki page that I need?| Thanks Link to comment
Discord Moderators Zango Posted November 8, 2010 Discord Moderators Share Posted November 8, 2010 I don't think there's a wiki page with this exact purpose, however if you want this to work for dudes with an account only, use setAccountData. Else use databases to store money amount along with player serial Link to comment
bartje01 Posted November 8, 2010 Author Share Posted November 8, 2010 Can anyone give me a little explain/example about how I can save money to accounts with setAccountDate? Zango thanks for reply btw. Link to comment
dzek (varez) Posted November 8, 2010 Share Posted November 8, 2010 wiki isn't containing all ready scripts (or solutions) how to solve your every idea.. events: onPlayerQuit onPlayerLogout (remember to set player money to zero after logout to avoid bug using!) onPlayerLogin functions: getPlayerMoney getPlayerAccount isGuestAccount getAccountData setAccountData setPlayerMoney btw: isn't such script on community? i can remember several of them.. Link to comment
bartje01 Posted November 8, 2010 Author Share Posted November 8, 2010 (edited) alright. I'm going to try. I don't think I will succeed. I hope one of you can script it for me but I don't want to ask a to big question edit": found this somewhere. Doesn't work though function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "savemoney.money", playermoney ) end end function onPlayerJoin ( ) -- when a player joins, retrieve his money amount from his account data and set it local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "savemoney.money" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) Edited November 8, 2010 by Guest Link to comment
dzek (varez) Posted November 8, 2010 Share Posted November 8, 2010 we are not fullfilling requests, but after you try and get stuck - post here, we will explain you your errors and suggest how to fix them Link to comment
bartje01 Posted November 8, 2010 Author Share Posted November 8, 2010 ye I understand. As in my edit; I've got this: function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "savemoney.money", playermoney ) end end function onPlayerJoin ( ) -- when a player joins, retrieve his money amount from his account data and set it local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "savemoney.money" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) just doesn't work. Link to comment
dzek (varez) Posted November 8, 2010 Share Posted November 8, 2010 when players joins - they aren't logged yet (it's logical ) use onPlayerLogin (check wiki page for arguments and more info) Link to comment
bartje01 Posted November 9, 2010 Author Share Posted November 9, 2010 Lol yea I failed I chagned it to Login and now it works fine. Thankyou really much Link to comment
dzek (varez) Posted November 9, 2010 Share Posted November 9, 2010 remember to add onPlayerLogout event (and set money to zero) - as players can login - get they money, logout, (money will stay), spend money, login again to have money back.. 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