Combatant leader = ORK.Game.ActiveGroup.Leader;
selectedItem = (ShopWrapperShortcut)sender;
...
...
bool successAdded = false;
if(selectedItem.IsCombatant){
Combatant combatant = ORK.Combatants.Create(selectedItem.Shortcut.ID, ORK.Game.ActiveGroup, false, false);
combatant.Init();
CombatantShortcut combatantShortcut = new CombatantShortcut(combatant, 1);
successAdded = leader.Inventory.Add(combatantShortcut, false, false, true);
}else if(selectedItem.IsItem)......
......
if(successAdded){
leader.Inventory.AddMoney(0, -selectedItem.BuyPrice(leader), false, false); //Pay the money
}
}
}
But this causes a problem if the items have Limit Quantity, how can I deduct the purchased quantity from the shop remain quantity? Is there a purchase API that can do the job?It looks like you're new here. If you want to get involved, click one of these buttons!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I use
theShopItem.quantity -= 1;
to reduce the quantity if the purchase is done.But if I re-open the shop, the quantity will be reset.
The setting of World->Shops->BaseSettings->Save Shop is checked.
How can I save the shop in the script? Or is there an API that I should call when purchasing items from the shop?
It's probably best to check this out in the ShopScreen class in ORK's source code. The whole functionality is used in there :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!