Author Topic: decrease stacksize help  (Read 313 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
decrease stacksize help
« on: November 22, 2014, 02:36:29 am »


               

I hope someone can help me. Basicly I need help with a stacksize decrease script.


Its supposed to decrease the stack by one every time upon use of the item. But right now it does not do anything.


 


Here is the script.



object oItemToTake;
oItemToTake = GetItemPossessedBy(oTarget, "lamp_oil");
if(GetIsObjectValid(oItemToTake)) { if (GetItemStackSize(oItemToTake)==1) { DestroyObject(oItemToTake);
SetItemStackSize(oItemToTake, GetItemStackSize(oItemToTake)-1);


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
decrease stacksize help
« Reply #1 on: November 22, 2014, 02:58:16 am »


               this should work 

    object oItem = GetFirstItemInInventory(oTarget);
    while(GetIsObjectValid(oItem))
    {
        if(GetTag(oItem) == "lamp_oil")
        {
            int iCount = GetItemStackSize(oItem);
            if(iCount == 1) DestroyObject(oItem);
            else
            {
                int iNewStack = iCount - 1;
                SetItemStackSize(oItem, iNewStack);
            }
            break;
        }
        oItem = GetNextItemInInventory(oTarget);
    }

               
               

               
            

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
decrease stacksize help
« Reply #2 on: November 22, 2014, 03:28:57 am »


               

Thank you for the quick reply, It works like a charm. thank you.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
decrease stacksize help
« Reply #3 on: November 22, 2014, 04:02:02 am »


               

Not at all  '<img'>