liamknight24 Posted November 17, 2009 Share Posted November 17, 2009 can somebody please tell me how to save things like money im not asking anyone to script this for me i just want to know how to do it so i can save other things like the players skin and health i had a look an the mta wiki and found this: ---money 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, "money", playermoney ) end end function onPlayerlogin ( ) -- 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, "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 ) i tried to edit it abit so it would work on login and not join but it dosent seem to work with join or login and im also using the logingui script if that will stop it but thanks anyway and also how will it know where to save it or will it automaticly save it to the accounts.xml??. Link to comment
50p Posted November 17, 2009 Share Posted November 17, 2009 (edited) 1. Please use [lua ][ /lua] (no spaces) tags and paste your code between them so it will look something like this: addEventHandler ( "onPlayerlogin", getRootElement ( ), onPlayerlogin ) 2. Your last line of the script (the one I showed here) is wrong... it's not "onPlayerlogin" it's "onPlayerLogin" Edited November 17, 2009 by Guest Link to comment
liamknight24 Posted November 17, 2009 Author Share Posted November 17, 2009 1. Please use [ /lua] (no spaces) tags and paste your code between them so it will look something like this: [lua]addEventHandler ( "onPlayerlogin", getRootElement ( ), onPlayerlogin ) 2. Your last line of the script (the one I showed here) is wrong... it's not "onPlayerlogin" it's "onPlayerLogin" so you mean change onPlayerlogin to onPlayerLogin i have just changed it but i cannot test if it works becouse now my player just spawns in the air instead of the logingui spawnpoint is this becouse the script is not in the logingui script it is in the gamemode folder and i added it to the meta.xml?? Link to comment
MOH Posted November 17, 2009 Share Posted November 17, 2009 I dont think she means that. She means ---money 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, "money", playermoney ) end end function onPlayerlogin ( ) -- 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, "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
liamknight24 Posted November 17, 2009 Author Share Posted November 17, 2009 ok i have fixed my spawn problem i will test if the money saving works if it dosent my msn is [email protected] if somebody wants to help me step by step and i will give them credit for the help. Link to comment
liamknight24 Posted November 17, 2009 Author Share Posted November 17, 2009 thanks for all the help guys it works will this be the same properties for positions and skins and other stuff???? Link to comment
Luke_Ferrara Posted November 18, 2009 Share Posted November 18, 2009 yeah I would also like to know how it can be applied with other properties such as pos, skin ect. and how to save even when server crashes so when it goes back up it will still save money, skin, ect. 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