Generate a DataStore "charge" when a player leaves

From my understanding, DataStores gain a certain amount of “charges” per minute depending on how many players are ingame. One of the biggest fears developers have, though, is that players might lose their data if they leave at an inopportune time. With OnClose, we’re close to having it perfect, but there’s still the danger of players losing data when the server is shut down.

Perhaps there could be a temporary charge added when a player leaves. This would let us save data 100% reliably when a player has left the game.

[quote] From my understanding, DataStores gain a certain amount of “charges” per minute depending on how many players are ingame. One of the biggest fears developers have, though, is that players might lose their data if they leave at an inopportune time. With OnClose, we’re close to having it perfect, but there’s still the danger of players losing data when the server is shut down.

Perhaps there could be a temporary charge added when a player leaves. This would let us save data 100% reliably when a player has left the game. [/quote]

Couldn’t you just use the PlayerRemoving event to save datastore stuff when the player leaves via that event?

Quoting Stravant here: If you ever worry about reaching the limit you’re doing something very wrong.

To elaborate on what Whimzee is saying:

Pool what you want to save together, and save it in bulk every minute. Even after a player leaves, you can save his/her data. If it’s the last player that left, you can take care of that with OnClose. Requests are generated 1 every second – not 60 every minute, so you should be good.

Hmm… I wonder what I am doing wrong because, as far as I am concerned, a player spamming the global chat I made and thus reaching the limit is a possibility.

"as far as I am concerned, a player spamming the global chat I made and thus reaching the limit is a possibility. "

You are doing it wrong, because you implemented a global chat directly on top of a relational database, which is something that no real-world program would do. You can’t complain that the system needs extra features if you’re abusing it in such a way.

You have to understand: The new DataStoreServices is giving you direct access to a real relational database. And you have to deal with all the implications that come with that. No normal real world relational database would support you real-time writing to it every time a user chatted a message into a global chat, and there’s no reason that you should expect the DataStoreService to either.

I would store what everyone says in a temporary table, then push the entire table to the DataStore once per second, and also get the updates at the same time (That does just use one “charge” to do, right? :? )

[quote] "as far as I am concerned, a player spamming the global chat I made and thus reaching the limit is a possibility. "

You are doing it wrong, because you implemented a global chat directly on top of a relational database, which is something that no real-world program would do. You can’t complain that the system needs extra features if you’re abusing it in such a way. [/quote]
Obviously this could be avoided by putting limits on how fast they can message. Which is ? one line of code I guess. I am not saying it needs extra features, I never even said I supported the idea. Also I would say the abuser would be the person spamming, because obviously said person is doing something that would lead to unintended consequences.

“Also I would say the abuser would be the person spamming, because obviously said person is doing something that would lead to unintended consequences.”

This isn’t really an acceptable argument. The user has no expectation that spamming the chat should cause them to lose gameplay data.

[quote] “Also I would say the abuser would be the person spamming, because obviously said person is doing something that would lead to unintended consequences.”

This isn’t really an acceptable argument. The user has no expectation that spamming the chat should cause them to lose gameplay data. [/quote]

They also shouldn’t expect spamming the chat to have no repercussions either. An intelligent user would know that spamming can overload the DataStore Limit and thus should avoid doing so. I really can not see from my stand point how one would think that they can abuse a system that’s in balance delicately and expect there to be 0 issues from trying to destroy the system.

[quote] “Also I would say the abuser would be the person spamming, because obviously said person is doing something that would lead to unintended consequences.”

This isn’t really an acceptable argument. The user has no expectation that spamming the chat should cause them to lose gameplay data. [/quote]

They also shouldn’t expect spamming the chat to have no repercussions either. An intelligent user would know that spamming can overload the DataStore Limit and thus should avoid doing so. I really can not see from my stand point how one would think that they can abuse a system that’s in balance delicately and expect there to be 0 issues from trying to destroy the system.[/quote]

If you put everything in a table and just send the contents of the table once per second, then spam will not be an issue :confused:

[quote] [quote=“Stravant” post=84304]“Also I would say the abuser would be the person spamming, because obviously said person is doing something that would lead to unintended consequences.”

This isn’t really an acceptable argument. The user has no expectation that spamming the chat should cause them to lose gameplay data. [/quote]

They also shouldn’t expect spamming the chat to have no repercussions either. An intelligent user would know that spamming can overload the DataStore Limit and thus should avoid doing so. I really can not see from my stand point how one would think that they can abuse a system that’s in balance delicately and expect there to be 0 issues from trying to destroy the system.[/quote]

If you put everything in a table and just send the contents of the table once per second, then spam will not be an issue :/[/quote]

I know this. And I also know on the server-side I should redo it. I just haven’t because it isn’t an issue at the moment and I need to finish other things. It is on my to do list of things to finish.

I lost all of my own data in my game once.

Note I have only scanned through the first couple of messages here

To prevent worrying about reaching the limit or not being able to test out data stores, I’ve made a ModuleScript to generate a “fake data store” - the only difference is you can call the methods as much as you want, test it in Play Solo / Test Play, see if the data store is “real” or “fake” whatsoever.

:wink: No one here need that fancypanty stuff, do ya’? (if so, ask me!)

Hrm, though my only question left on the matter of data stores is then whether :GetDataStore “makes” a persistent data store or not. Which brings up one of the possible few downsides with the “fake data stores”.

Though I haven’t had problems with losing data since then, as it fits my needs. cache w0t

“:GetDataStore “makes” a persistent data store or not.”

That’s an implementation detail, I don’t see how it would be relevant to whether your Module would work correctly. Also, you should check out my “PlayerDataStore” module:

You may find it interesting to read and see how I chose to implement the same API that you’re describing. I also used some cool techniques such as Weak-tables that aren’t used very often in code on Roblox.