Jump to content

Saving datas to account.


Taalasmaa

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...