Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'Economy' started by DasMaffin, Mar 4, 2022.

  1. DasMaffin

    DasMaffin

    Joined:
    Apr 3, 2018
    Posts:
    4
    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<PlayerBalance> 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?
     
  2. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    220
    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.
     
  3. vaudevillian8

    vaudevillian8

    Joined:
    Mar 28, 2016
    Posts:
    1