How to change economy data of a player that is not "me"?

So I have been trying to implement economy, and so far have goten it all implemented fine.
However I have hit a roadblock:
I am having people connect to event servers, once thos shut down they are supposed to give rewards in form of economy, now I dont want the player to have to connect to the server (since I want it to be shut down) to collect their rewards, therefore Id like to be able to tell the server something along the lines of “Please update economy value x to 10,000 for the user with the ID y”
I have tried changing the Economy method “public async Task SetBalanceAsync(string currencyId, long balance, SetBalanceOptions options = null)” to take a string as well what would be the player ID, and then replace the line “m_EconomyAuthentication.GetPlayerId(),” with th Id, however I then found out that there is a key which sadly keeps changing, so I cant just save that key to the server along with the ID.
I havent found an implementation yet so is this even possible? Is this planned?

Hi DasMaffin,

Thanks for sharing your usecase and the limitation that you have run into.

All the Economy functionality is focused around managing the currently authenticated player, it isn’t possible to modify other player’s data from the source player’s perspective or from a central game-level perspective.

We can definitely see scenarios where this would be a useful feature, but at the same time it is something that would need to be implemented very carefully to avoid potentially gamebreaking exploitation.

One idea that came to mind from your description though… If the reward is only given when the server shuts down, you could use Cloud Code and Economy together to implement a server authoritative mechanic that rewards the player as they disonnect or exit from a server. Cloud Code could be used to ensure that this only occured once for each player/server instance to prevent exploitation. I know that isn’t the same as a delayed reward when the server closes, but it is the closest thing that comes to mind.

I’ve logged your interest in this use case and we will be sure to post any information on the forums if we extend the functionality to enable cross player functionality within Economy or other UGS services.

@DasMaffin I think it’s now possible to do what you want: you have to use economy-2.4 and not use the access token, but the context. At least with that combination I was able to write a cloud code script that expects a playerId as param and internally changes the resource of that very playerId.

Some more details of other users that helped my solve my case you can read here: Grabbing item from the inventory - Unity Services - Unity Discussions