Taalasmaa Posted October 31, 2009 Share Posted October 31, 2009 Hi, I'm finally doing a car shop.. I have basic GUI Window and now I need to test a save. I also maked spawner for it. It's working now, you can spawn car which you boughht before, but now I need to make save for it. I'm not really good with saves. setElementData ( thePlayer, "boughtcar",1) If players buy banshee it sets element data to "banshee" and of course spawner is working like: if (getElementData ( source, "boughtcar" ) == 1) then --- Create vehicle next to player.. This is already done. ----- -- And of course if it's other car elseif (getElementData ( source, "boughtcar" ) == 2) then --- Create vehicle infernus How can I store setElementData ( thePlayer, "boughtcar", 1 ) this to players account??? Or save it?? I'm not good with saves is it going like this: local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local data = getElementData ( source, "boughtcar" ) setAccountData ( playeraccount, "car", data) and when player login: local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local carData = getAccountData ( playeraccount, "car" ) if ( carData ) then setElementData ( thePlayer, "boughtcar") So Like I said i'm not good with saves AT ALL. Help would be awesome! EDIT: Is it better way to save to XML or SQL, If it's give me ideas how to do it. Link to comment
Taalasmaa Posted October 31, 2009 Author Share Posted October 31, 2009 It saves now, but when login, it don't setElementData to banshee... ON BUY: setElementData( thePlayer, "car", "banshee"); ON QUIT: local playerData = getElementData ( source, "car" ) setAccountData ( playeraccount, "car", playerData ) FROM ACCOUNTS: <account name="Taalasmaa" password="****************HIDED" ip="*********HIDED"> <string_data bank.balance="0" teamName="Police" car="banshee" /> <number_data skin="10" weapon="0" ammo="1" /> account> ITS STORED TO ACCOUNT ON LOGIN: local playerData = getAccountData ( playeraccount, "car" ) if ( playerData ) then setElementData( source, "car", playerData ); NO ERRORS I really need help, thanks EDIT: Working if don't reconnect, so script is working, but save isn't Link to comment
Dark Dragon Posted November 1, 2009 Share Posted November 1, 2009 try outputDebugString(tostring(setElementData( source, "car", playerData ))) in your function which is triggered on login and see what it returns Link to comment
Taalasmaa Posted November 1, 2009 Author Share Posted November 1, 2009 try outputDebugString(tostring(setElementData( source, "car", playerData ))) in your function which is triggered on login and see what it returns Yah, I'll test it, thanks for reply Link to comment
Taalasmaa Posted November 2, 2009 Author Share Posted November 2, 2009 try outputDebugString(tostring(setElementData( source, "car", playerData ))) in your function which is triggered on login and see what it returns Nothing. I don't know what's going wrong. 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