Jump to content

Saving datas to account.


Taalasmaa

Recommended Posts

Posted

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.

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted

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

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted

Any help?

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted
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

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted
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.

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

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...