-
What do you want to achieve?
A better method of sharing data between the server and one client. -
What is the issue?
Currently, my scripts involving my current server-client data system have been very very painful to do. The system is the most painful with items, as all items are custom (each is a table and unfortunately cannot be easily compared to another table) and both the client and server have separate data to prevent any lag (the client is updated when needed and can only read the data). -
What solutions have you tried so far?
Honestly, I didn’t really look too hard for solutions besides trying to think of something (and failing). I don’t really expect many games to handle items the same way they are in my game so in most other games it’s probably a fine method.
Better explanation of my current system:
- The server has a global data module script, containing 1 table for each player, which is further divided into more tables as this is all of the player data in one huge table.
- Each client uses a module script and updates it locally so that no other client can see another client’s data. This means if you have a high ping like 500 ms, you don’t have to wait half a second to receive data unless it’s just been updated.
- The client never modifies their own data other than to update it, all requests are sent to the server which processes it and then sends back an updated piece of the data.
And the current problem with this is:
- As mentioned earlier, it is incredibly painful to work with.
- This is because everything has to be passed through a bunch of functions for literally everything, and also because you cannot locate an item very easily. An item on the client is not on the server, the server simply has a copy, therefore, attempting to compare “itemA == itemB” where the first is from the client and the second is from the server, will always be false even though both items are the same in content.
- Additionally, setting a value and forgetting to run certain things basically just doesn’t update the client which can lead to undetectable errors when the client is missing something they should have.
- There are many other issues with it too, which is why I have made this post to look for a better method.
The optimal method in my opinion would be a shared module where a singular player and the server can access it (though still server-side so the client can’t modify their data illegally), and each player being able to have a shared module with the server which would mean you could be able to compare “itemA == itemB” without it being false every time.
Of course, the main issue is probably my programming skills, the methods I used probably aren’t the greatest but it would be a huge time saver if there was any better way to solve this.