I have a scenario where when a player plays a turn, an Event script reads the Challenge script data and checks what the other has player played and determines who is the winner of that round depending on the data available and writes the outcome to the script data of the challenge.
If the script finds no data from the other player then it is deemed that the other player has not played and no winner is determined.
If the players play their turn simultaneously the data processed by each script shows that the other player has not played and no winner is determined.
I have tried both Spark.lock and Spark.lockkey.
But in both cases the script being called by the second player is able to access the script data and the change in data by the first player is not being shown in the script data.
Hi Arcadia Games,
Changes made to the challenge are persisted to the database once the script making the change finishes. Because of this, if a second player accesses the challenge while the first player's script is still running, the change will not yet have been applied to the database and so the challenge they receive will not reflect the changes made by the first player.
This is due to the fact that challenges are cached which can result in a tiny delay in the syncing of data. To avoid this issue you can utilize a Runtime collection to store challenge data that is not static in nature.