question

lu.zhang@sectionstudios.com avatar image
lu.zhang@sectionstudios.com asked

Is there anyway to trigger a CloudScript when the purchase function is called on the client?

I wanted to change the player's data when he buy some special goods. I don't know whether the CloudScript can run client function. If it can't, can I trigger a CloudScript when the client runs a purchase API Call?

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

Yes, you could set an Action in PlayStream to call into your script whenever the player_vc_item_purchased event occurs (or the player_inventory_item_added on, if you also want to catch any case where it is granted to the player, whether by a server call or via the game manager).

2 comments
10 |1200

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

Dylan Hunt avatar image Dylan Hunt commented ·

Is there a way to access the client api from cloudscript? I was looking at something similar, but instead of updating data, I wanted to return data. I can just make separate calls, but was trying to be efficient -- I wanted to return both the GetCharacterInventoryResult and purchasedItem in one call (after the item is purchased, return a new inventory list)~

Also, since PurchaseItem requires a session, it's considered "safe/good practice" to purchase an item client-side, right?

Just making sure!

0 Likes 0 ·
brendan avatar image brendan Dylan Hunt commented ·

That's correct - purchases should be made client-side (in part because that should always be directly due to a player action). The Client API is not available to Cloud Script, but if there's a specific API call that's needed in the Server API, that'd be good to add to the Feature Requests forum.

0 Likes 0 ·

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.