• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Stock shop with item, make it buyable x times, how to do it?

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
Alright I tried this method:

JASS:
function Trig_GainsEclipsingDream_Actions takes nothing returns boolean
    if GetBuyingUnit() == gg_unit_nC84_0658 and GetItemTypeId(GetSoldItem()) == 'moon' then
        call AddItemToStock(gg_unit_nC84_0658, 'moon', 1, 10)
    endif
 return false
endfunction

//===========================================================================
function InitTrig_GainsEclipsingDream takes nothing returns nothing
    set gg_trg_GainsEclipsingDream = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_GainsEclipsingDream, EVENT_PLAYER_UNIT_PAWN_ITEM )
    call TriggerAddCondition( gg_trg_GainsEclipsingDream, function Trig_GainsEclipsingDream_Actions )
endfunction

But no matter what numbers I put in the stockMax or currentStock field, when a unit buys the item the item is gone from stock. So how do I set this up properly? Thanks. I mean, I can do a basic system that counts how many times the item was bought and readds it til it reaches 0, but I wanted to make sure there wasn't a simpler way first.
 
Status
Not open for further replies.
Top