Help with datastore

I am working on a game that is inspired by starscape. I am trying to make an ore spawner. Sure ive made it it spawn surely but i dont want the ores spawn differently every time i rejoin. The way i did is that when the server starts there are parts that represent the position for ores to spawn. Also there is a stringValue that indicates wich ore is it for example: If its iron or aluminium but if the value is basicaly nil then the ore has been mined. Also i wanna make so the ores change every day. So how could i do this and how could i make this work?

1 Like

Try doing os.time, and a global randomizer script.

Os.Time is a measurement system that can trigger events using realworld time.

And for datastore, im not so sure what you want, but i have a good datastore module you could use.

Gotta learn more about os.time while for datastore module, i already have one but its for stuff that are stored in a player. I would need one that is stored outside a player and that the data is saved before the server shuts down or save the data every 2 minutes for example

I suggest making your own serversided datastore module, or searching serversided devforum for one that remembers for the server, They are complicated.
And for something like that, you can just call in the save function, in the module every two minutes.

To beat lag though, its gonna be hard to prevent combat logging, pvp, etc. I suggest every 5-10 minutes if you have a game like starscape.

In conclusion, do the research and find a serversided datastore module, or make one.

So maybe do you know how starscape does it?

Starscape probally has special technology thats not within roblox lua.
Such as detecting if a server is gonna shutdown or so, Don’t get me wrong they probally still use autosave for emergency-scenarios.

Your best bet is just autosaving and flooding your api, unfortunately.

could this cause a memory leak?

Possibly, depends on how you do it.

I’ve seen many games use it though, and its likely not possible, you do need failsafes though, that is important.

and how could i add failsafe? Like Repeat save until its saved or something?

Yeah, and if it doesnt work, (after 3 tries, with a delay time of 30 seconds ) you automatically shutdown the server, to prevent people progressing, just to recieve dataloss.

nonono this isnt about losing player’s data. its about like generating ores and saving ore’s placement

Same thing that i said earlier i guess?
Minus the player kicking part.

Theres not much failsafes to add, but its nice to have them

If you cant generate ores at all (datastore is down)

Shut down the game, cause probally all datastore is down.
or, in a case where somehow your serversided datastore just doesnt work
Random ore placement until its fixed, (keep inventory of mined ores inside ship, but revert to old position before datasave was down.)

Besides that, theres really no other failsafes.

you have played starscape right?

Haven’t played, games super expensive, i watch its devlogs and gameplay sometimes though.

so basically the code will be similar to self updating shop. Like it updates every day and has different stuff?

Yeah. Mhm, I guess, Sure.
(character limit.)

i kinda am stuck and dont know how to make the code.:skull:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.