Jump to content

Saving account data


Redox

Recommended Posts

Hi, I have question. Can I do array like 'xxx = { }' and save this when player has left server? I try to do like this:

xxx = { }
addEventHandler ( "onPlayerLogin", getRootElement(), function ()
local konto = getPlayerAccount(source)
if ( konto ) then
	xxx[source] = getAccountData ( konto, "xxx" )
end
end
)
 
addEventHandler ( "onPlayerQuit", getRootElement(), function ()
local konto = getPlayerAccount(source)
if ( konto ) then
setAccountData (konto,"xxx",xxx[source])
end
end
)

But the above code doesn't work. In data base, 'xxx' has value 'nil'. And it 'xxx[source] doesn't load.

Link to comment

Ok ;> I have another question. I have in script code like this:

Load data

setElementData ( source, "skin", getAccountData ( konto, "skin" ))

Save data:

setAccountData (konto,"skin",getElementData(source,"skin"))

And this doesn't work. I don't have idea what can I do.

Link to comment

should work.. Maybe your event handlers are wrong?

Again: Debug. Put outputDebugString with useful informations every important line in your script, after each if, function, inside loops and after any function use. I´ve already given a lot of examples of this to other people.. Search. And please.. Read that wiki page about debugging..

Link to comment

If you want to get data from an account you better make sure the data has been stored before, that is, make sure getAccountData returns the data that you expect it to return.. If it'll return false then your setElementData will set player's "skin" data to false... After that you use setAccountData to set player's account data "skin" to false. You have to think in advance. What will happen if player joins your server for the first time and you try to get his account data and set it as element data?

If you save player's skin, then why don't you use getElementModel instead? It saves memory because you don't have to store his skin ID in as element data.

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