Admigo Posted September 19, 2011 Share Posted September 19, 2011 Heey all, How can i save money? Because when i login and i spawn money,the money will be reseted after next map or rejoin server. Thanks Admigo Link to comment
Castillo Posted September 19, 2011 Share Posted September 19, 2011 getPlayerMoney setAccountData getAccountData setPlayerMoney onPlayerQuit onPlayerLogin onPlayerLogout Link to comment
Admigo Posted September 19, 2011 Author Share Posted September 19, 2011 Why this not work? https://wiki.multitheftauto.com/wiki/SetAccountData Link to comment
JR10 Posted September 19, 2011 Share Posted September 19, 2011 This example is wrong, onPlayerJoin will have a guest account. function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money setAccountData ( playeraccount, "piraterpg.money", playermoney ) -- save it in his account end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "piraterpg.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 ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) Link to comment
Admigo Posted September 19, 2011 Author Share Posted September 19, 2011 Thanks dude,works great. Can you help me fix the money collum? When the map changes,the number from money goes to 0,but at admin pannel i see that i have money and on rejoin i have money to. pls help. viewtopic.php?f=91&t=36002 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