| 08-17-2011, 11:17 PM | #1 |
i currently put this Thread in the wong place, please forgive me. Any ways if u have not seen the other thread in the genral forums, i am trying to make a marketplace be able to have all the items that you sell to it so that other players may buy the item that u sold to the same marketplace Exsample:i sell a light healing pot to the marketplace, then it shows up in the marketplace, then anther player comes up and buys it from the same marketplace. Any help will be usefull thanks c(^.^c) |
| 08-18-2011, 12:19 AM | #2 |
JASS:library Marketplace initializer Init globals private constant integer MARKETPLACE_UNIT_ID = 'nmrk' endglobals private function Conditions takes nothing returns boolean return GetUnitTypeId(GetBuyingUnit()) == MARKETPLACE_UNIT_ID endfunction private function Actions takes nothing returns nothing local integer id = GetItemTypeId(GetSoldItem()) call AddItemToStock(GetBuyingUnit(), id, 1, 1) endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_PAWN_ITEM) call TriggerAddCondition(trig, Condition(function Conditions)) call TriggerAddAction(trig, function Actions) endfunction endlibrary You need to change the constant to the id of your marketplace unit type. Currently it wont increase an items max stock if you sell the same item type to it more than once. I can change that if you want it, it's not too much more work but will have to use a hashtable (or table if you only want 1 marketplace) since there's no native to see if a unit has an item in stock (or how much stock of it it has). Also if the marketplace gets more than 11 items, the first item added will be removed. That seems to be a wc3 limitation. I could probably build a work around but I can't be bothered. I'll attach the map so you can see if this is how you wanted it. EDIT: Oh yeah, the Marketplace unit needs to have the "Sell Items" ability. |
| 08-19-2011, 01:32 AM | #3 |
Well, i c that u use scripts, i am not very good at scripts, Mind puting it in trigger form, cause i can t under stand any of of that scripting u put down. ![]() |
| 08-19-2011, 03:00 AM | #4 |
| 08-19-2011, 08:12 PM | #5 |
Rep+ thank you very much Fledermaus. im just more good with triggers that all c(^^c) |
