Store player info help

Store player info help

Postby ismellike » 26 May 2013, 16:06

Is there anyway I could store player info from a command?

I've been trying this ->
Code: Select all
if(!p.ExtraData.ContainsKey("info"))
{
p.ExtraData.Add("info",0);
}

<- but when I log out and then back in it clears itself.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: Store player info help

Postby Ultima » 26 May 2013, 16:07

ismellike wrote:Is there anyway I could store player info from a command?

I've been trying this ->
Code: Select all
if(!p.ExtraData.ContainsKey("info"))
{
p.ExtraData.Add("info",0);
}

<- but when I log out and then back in it clears itself.


You need to save it in the DB or a textfile.
I didn't see any serialized data field or a custom table for this in de DB so i am certain you need to make your own.
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Store player info help

Postby dzienny » 26 May 2013, 21:50

What Ultima said. There's no API for saving a player's variable to persistent storage. Unless it's a boolean then there's a simple trick available.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Store player info help

Postby Conor » 06 Jun 2013, 14:42

dzienny wrote:What Ultima said. There's no API for saving a player's variable to persistent storage. Unless it's a boolean then there's a simple trick available.


I'm intrigued - what is the simple trick?
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: Store player info help

Postby dzienny » 06 Jun 2013, 20:23

Conor wrote:
dzienny wrote:What Ultima said. There's no API for saving a player's variable to persistent storage. Unless it's a boolean then there's a simple trick available.


I'm intrigued - what is the simple trick?


There's a 32bit integer value saved into Flags column of Players table. I can spare a few bits for booleans or even for a short number(up to 8bits). Or even more if it's necessary. So, if you need it just ask me. I will add masks for these variables.

I originally planned to use flags for achievements, but there are better ways to do it anyway. Also, I don't plan to add achievements anytime soon, because there are other things I'm focused on.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Store player info help

Postby Conor » 06 Jun 2013, 21:42

dzienny wrote:
Conor wrote:
dzienny wrote:What Ultima said. There's no API for saving a player's variable to persistent storage. Unless it's a boolean then there's a simple trick available.


I'm intrigued - what is the simple trick?


There's a 32bit integer value saved into Flags column of Players table. I can spare a few bits for booleans or even for a short number(up to 8bits). Or even more if it's necessary. So, if you need it just ask me. I will add masks for these variables.

I originally planned to use flags for achievements, but there are better ways to do it anyway. Also, I don't plan to add achievements anytime soon, because there are other things I'm focused on.


Oh, cool :)
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 5 guests

cron