• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How can I detect if a player is buying an item from a shop?

Status
Not open for further replies.
Level 5
Joined
Feb 1, 2009
Messages
111
More specifically, is there a way to set a variable to the amount of gold spent when a player buys a shop item ? I am trying to restrict a player from buying something if his level is too low for the item and this would help.

Edit :

I actually would just need to know how to detect if a player has targetted a shop to buy an item. So the event of clicking on a shop ?
 
Last edited by a moderator:
Level 26
Joined
Aug 18, 2009
Messages
4,097
There is the unit event EVENT_UNIT_SELL_ITEM (playerunitevent EVENT_PLAYER_UNIT_SELL_ITEM).

GetSoldItem() returns the sold item, GetBuyingUnit() the buyer.

To get an item's gold cost, you can presave them in a data structure or make a workaround à la "order dummy shop to sell the item and look at the gold count before and after".
 
Do like said above use a item gold cost system to get the gold the item costs. Then use the event to check if unit sells item.
Use an ITE to check if that unit is required lvl to buy the item. If it is not the required lvl remove the item add back gold / lumber and display a message.

I have a item / unit gold / lumber cost system in the spell section that you can use.
http://www.hiveworkshop.com/forums/spells-569/item-unit-cost-system-v1-0-0-3-a-245280/
 
Level 10
Joined
Apr 18, 2009
Messages
601
Edit :

I actually would just need to know how to detect if a player has targetted a shop to buy an item. So the event of clicking on a shop ?

Something like this?

  • Shop Selection
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Goblin Merchant
    • Actions
 
Status
Not open for further replies.
Top