dxura / darkrp

Dark RP for the modern times
MIT License
12 stars 10 forks source link

Sandbank For Storing Data #9

Closed Bozcx closed 2 months ago

Bozcx commented 2 months ago

The Following is a Issue from the Original DarkRP Github Repo. https://github.com/sousou63/DarkRP/issues/186

Hi! Hope you are well!

I have to apologise in advance because this is basically just going to be me shamelessly plugging my own library...

So I noticed that it looks like the plan currently is to store game data in a traditional database: https://github.com/sousou63/DarkRP/blob/main/code/Persistence/Database.cs

I was wondering if you had considered using my database library? (https://github.com/anthonysharpy/sandbank)

I think the advantages of this would be:

    It's faster
    It's a lot simpler for people to implement (currently for the traditional database approach to work you'd need to host an API and a database, which is probably a headache for most people)
    It's cheaper (no need to pay for database/API hosting)
    You can start implementing it now (rather than waiting for a feature that Facepunch might never add)
    It would simplify your code

If you think it sounds like a good idea then I can even make a PR implementing this for you.

If you have any questions please ask 😄

Using this would be much more beneficial in the long run then simply relying on a homemade solution or simply using .json files.

ghost commented 2 months ago

@anthonysharpy I have noticed your sqlite-like storage layer previously before your issue.

We would be interested in your contribution to implementing your solution for dxura/darkrp which is based of HC1/Nicked.

While the previous version had a pseudo json system, this version has no persistence yet.

There's a few requirements

Additionally it would be nice if it was somewhat encrypted, at least so it's more effort than it's worth to manipulate. This is not required.

The basic data we want persisted at the moment would be the player balance, then maybe roles/playtime later on.

Let me know if you're interested in working on this, should be straight forward I believe.

anthonysharpy commented 2 months ago

@dimmerly Thanks for the reply!

For now, we want each user to store their own data, but in future we want a dedicated server holding this information - there must be a clear way to switch in future.

Sounds doable. My library supports saving on the client and server. Saving on the client is disabled by default but this can be enabled with a boolean in the config file.

Additionally it would be nice if it was somewhat encrypted, at least so it's more effort than it's worth to manipulate. This is not required.

Yeah, there's no way to make it 100% uneditable if it's being stored on the client. But I can obfuscate it as you suggest such that 99% people won't bother trying. I probably wouldn't do this for the initial implementation, but would probably add it as a new feature to the library soon after, and then you can enable it when it suits you.

The persistence has to be implemented in a way that it depends on an interface rather than directly on your package. Darkrp code -> Interface -> Your persistence package

I see where you are coming from with this. However some things to bear in mind:

But let me go and make an example implementation and then you can decide if it's too tightly coupled or not.

The basic data we want persisted at the moment would be the player balance, then maybe roles/playtime later on.

Easy peasy.

anthonysharpy commented 2 months ago

Just implemented the obfuscation thing :-)

image

Will try and get a PR ready

anthonysharpy commented 2 months ago

PR https://github.com/dxura/darkrp/pull/12

anthonysharpy commented 2 months ago

Seems this is merged so feel free to close

If you have any questions feel free to let me know, or you can raise an issue on my repo 😄