Building a robust trading system

When it comes to trading, theres many pitfalls and I dont trust myself to gracefully handle every fail state.

There are 3 identified fail states that I’m aware of

  • Either player leaves the game during a trade (usually not an issue, because you SHOULD use userids, not players)
  • The server unexpectedly closes (shutdown, server crash)
  • DataStores are failing in a way that cant be solved with a simple retry

I can theory craft a solution for servers closing (since we have an API to gracefully handle that) the issue is mainly with DataStores. I get datastores are usually fine, but its those 1% of bad times I need to factor in.

Are there any other pitfalls I need to be aware of, and how can I factor in DataStores failing?.

1 Like

This shouldn’t be a problem, just remove the items from the players inventory at the end and ad it to the inventory of the other person. That are only a few milliseconds.


I made a diagram to account for some common issues. I’m using draw.io.

here is the diagram file if you want to expand it

1 Like