A player drops out in the middle of a trade and the item is in both bags
Swapping items between two players looks like one action but is several, and a lost connection or a quick last-second change can leave things duplicated or missing. Here is the order of steps that keeps every item in exactly one place.
Why this works
A trade is safe only if it either happens fully or not at all. By leaving everything with its owner until one final step that changes both bags together, a crash at any earlier moment loses nothing, and there is never anything to undo.
When not to use it
Too strict for casual gifts between friends, or a game where items can be dropped on the floor and picked up anyway. There, a one-way handover is simpler, as long as players understand it cannot be taken back.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 43 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "A player drops out in the middle of a trade and the item is in both bags" (read_entry trade-survives-a-disconnect) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP