- Joined
- Nov 30, 2007
- Messages
- 1,202
For some reason it doesn't recognize when WARDROBE01 sells SHOES_ITEM and therefor SHOES_SHOP is never selected. Don't get it.
JASS:
scope ShopSystem initializer Init
globals
private constant unit WARDROBE01 = gg_unit_n00B_0032
private constant integer SHOES_ITEM = 'I027'
private constant integer SHOES_SHOP = 'n00C'
private hashtable hash = InitHashtable()
endglobals
private function AddShopToMain takes unit mainshop, integer dummyitem, integer newshopid returns nothing
local unit newshop = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), newshopid, GetUnitX(mainshop), GetUnitY(mainshop), 0)
call SaveUnitHandle(hash, GetHandleId(mainshop), dummyitem, newshop)
set newshop = null
endfunction
private function OnEvent takes nothing returns nothing
local unit mainshop = GetTriggerUnit()
local unit newshop = LoadUnitHandle(hash, GetHandleId(mainshop), GetHandleId(GetSoldItem()))
if not (newshop == null) then
// its always null..?
if GetLocalPlayer() == GetOwningPlayer(GetBuyingUnit()) then
call ClearSelection()
call SelectUnit(newshop, true)
endif
else
call BJDebugMsg("Null!")
endif
set mainshop = null
set newshop = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SELL_ITEM, function OnEvent)
call AddShopToMain(WARDROBE01, SHOES_ITEM, SHOES_SHOP)
endfunction
endscope