Forum Discussion
8 Replies
- SeeingBlueMHCP Mentor
You're talking about this right?
What does the Item settings in the property panel to the right look like for this item?
- TiitouaanMHCP Member
Yes that's what I'm talking about. Here is my property panel.
Flouz are the in-game tokens; the first item can be purchased with meta credits, but the second and third cannot.
- SeeingBlueMHCP Mentor
Okay, looks correct. I would expect this to work. What are you seeing instead? Player tries to purchase and nothing happens? What event are you listening for?
- TiitouaanMHCP Member
Here my script attached to the shop guizmo :
class ShopScript extends hz.Component<typeof ShopScript> { static propsDefinition = {}; start() { this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnItemConsumeComplete, (player, item, success) => { if (success) { console.log(`${player.name.get()} successfully consumed the item: ${item}`); if(item === "+1_knockback_multiplier_2dfd2123") { // Ajouter +1 knockback multiplier const knockbackMultiplier = this.world.persistentStorage.getPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.knockbackMultiplier); this.world.persistentStorage.setPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.knockbackMultiplier, knockbackMultiplier + 1); console.log(`Increased knockback multiplier for ${player.name.get()} to ${knockbackMultiplier + 1}`); }else if(item === "+1_recoil_multiplier_0ec76b29") { // Ajouter +1 recoil multiplier const recoilMultiplier = this.world.persistentStorage.getPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.recoilMultiplier); this.world.persistentStorage.setPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.recoilMultiplier, recoilMultiplier + 1); console.log(`Increased recoil multiplier for ${player.name.get()} to ${recoilMultiplier + 1}`); }else if(item === "+1_resistance_multiplier_6517be99"){ // Ajouter +1 resistance multiplier const resistanceMultiplier = this.world.persistentStorage.getPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.resistanceMultiplier); this.world.persistentStorage.setPlayerVariable(player, PersistentVariables_Data.playerPersistentVariables.number.resistanceMultiplier, resistanceMultiplier + 1); console.log(`Increased resistance multiplier for ${player.name.get()} to ${resistanceMultiplier + 1}`); } } }); } }All items are set to auto-consume. It seems to work fine when purchasing with meta-credits, as the console output and PPV are updated. However, when purchasing with Flouz, there is no console output and the PPV does not update.
- SeeingBlueMHCP Mentor
You might try listening to the code block onConsumptionStarted, if it fires then use the consumeItemForPlayer(player, sku, quantity)
- TiitouaanMHCP Member
I assume you meant onItemConsumeStart, unfortunately the OnItemConsumeStart Event doesn't fire when I purchase an item with in-game tokens... Neither the OnItemConsumeStart, the OnItemPurchaseStart nor the OnItemPurchaseComplete events fires, wether I purchase item with meta-credits or Flouz
- SeeingBlueMHCP Mentor
Then it might be this special networkevent.
https://developers.meta.com/horizon-worlds/reference/2.0.0/core_inworldshophelpers
- TiitouaanMHCP Member
It is! Thank you for your help :)