question

frozenvortexgames avatar image
frozenvortexgames asked

Changing the price of an item using CloudScript?

Hi there,

I soon plan to create a "Stock Market" of sorts for my game, using PlayFab.

I want to do this by creating a catalog, containing 10-15 different stocks for "companies". Each will have their own stock value etc...

The player will be able to buy items from this catalog, effectively buying a stock.

I would like to know if it's possible to change the price of items via cloud script, so that we can have each item in this catalog change price every hour or so.

The value that the stock changed by would be random, using something like Random.Range to determine the exact "Random change" value that the stock will be effected by.

Would a feature like this be plausible?

If not have you any idea how I could achieve this?

Thanks!

CloudScriptIn-Game Economy
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The catalog for a game, like title data, is sharded and cached, so that it can be read by all users. So one issue is that when a change is made to a catalog version, it will take a short period for those changes to propagate to all shards, during which time different users may get different prices. So part of the answer here is to ask how reliable does the pricing need to be across all users? If it has to be precise, your best bet would be to set up an external query server that manages the stock prices, and which you query from the client or Cloud Script. If it's okay for players to get different prices during that "overlap" period when the prices are being changed, then you could drive the prices via Title Data, updating it using a Scheduled Task and making the purchases via Cloud Script. We don't currently provide a way to update the catalog via Cloud Script, though we do plan to expand the scheduled task capabilities with more of the Admin API in a future update.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.