Results 1 to 11 of 11

Thread: help with StockShopItem

  1. #1
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default help with StockShopItem

    hello im trying to create a shop buying script and i need to add failsafes to confirm if the shop has an stock left.

    i see in the buysell include there is: StockShopItem function

    but i cant seem to get it to work.

    Code:
    if Shop_Screen then
          writeln('Shop screen Open');
          if StockShopItem(8) > 10 then {
          writeln('Buy 10 items');
          BuyCoords(93,130,10);
          Close_Shop;
          }
    but it does not seem to work, could anyone help me with this?

    HTYA

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Because you commented out the part where it buys it, in lape/pascalscript we use begin/end instead of {}

    Simba Code:
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      if StockShopItem(8) > 10 then
      begin
        writeln('Buy 10 items');
        BuyCoords(93,130,10);
        Close_Shop;
      end;
    end;

    {} is considered a comment in lape/pascalscript



    Or maybe something in the OSR include is broken, because besides anti-randoms hasn't been updated in 7 months

  3. #3
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default

    oh i didnt realise that! i will give it a try now thanks.

    is it possible to writeln the result of StockShopItem(8)?

    i have tried
    Code:
    writeln('stock' + StockShopItem(8));
    but it didnt work

  4. #4
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Quote Originally Posted by hello to you all View Post
    oh i didnt realise that! i will give it a try now thanks.

    is it possible to writeln the result of StockShopItem(8)?

    i have tried
    Code:
    writeln('stock' + StockShopItem(8));
    but it didnt work
    Use:
    Simba Code:
    writeln('stock' + intToStr(StockShopItem(8)));

    EDIT: I've never used that include so i'm not sure what StockShopItem returns, if it returns an integer than what I wrote above will work. If not, you can try:
    Simba Code:
    writeln('stock' + toStr(StockShopItem(8)));
    Last edited by Kyle; 09-23-2014 at 02:18 PM.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  5. #5
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    Use:
    Simba Code:
    writeln('stock' + intToStr(StockShopItem(8)));

    EDIT: I've never used that include so i'm not sure what StockShopItem returns, if it returns an integer than what I wrote above will work. If not, you can try:
    Simba Code:
    writeln('stock' + toStr(StockShopItem(8)));
    Yes that worked perfectly! Thank you!!

    i am trying to run it so when 1 item in the shop is low it will try and buy the next item but the way i ave scripted it, it tries the next item straight away.

    Simba Code:
    begin
    if Shop_Screen then
        begin
    writeln('Shop screen Open');
    repeat
    if StockShopItem(8) > 5 then
        writeln('stock' + intToStr(StockShopItem(8)));
    begin
    writeln('Bought Item 1');
    BuyCoords(93,130,10);
    end;
    if StockShopItem(8) < 5 then
        writeln('stock' + intToStr(StockShopItem(8)));
    begin
    if StockShopItem(9) > 5 then
        writeln('stock' + intToStr(StockShopItem(9)));
    writeln('Bought Item 2');
    BuyCoords(140,130,10);
    end;
    until(InvFull);
    writeln('Inventory Full Closing Shop');
    Close_Shop;
    writeln('Closed Shop');
    end;
    end;

    also is there a way to say if (condition) & (condition) then?
    and also is there a way to write while ((condition) is false) do
    Last edited by seany; 09-23-2014 at 03:10 PM.

  6. #6
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default

    i think im getting closer but its still not working:

    Simba Code:
    procedure Buy;
    begin
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      repeat
        writeln('Inventory Still not full');
        if (StockShopItem(8) > 20) then
        begin
          writeln('Bought Item 1');
          BuyCoords(90,130,10);
        end;
        if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then
        begin
          writeln('Bought Item 2');
          BuyCoords(90,130,10);
        end;
        writeln('Item 1 ' + intToStr(StockShopItem(8)));
        writeln('Item 2 ' + intToStr(StockShopItem(9)));
      until(InvFull);
      writeln('Inventory Full Closing Shop');
      Close_Shop;
      writeln('Closed Shop');
    end;
    end;

    i have tried this code:
    Simba Code:
    if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then

    in these different ways

    Simba Code:
    if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then

    if (StockShopItem(8) < 20) and (StockShopItem(9) < 20) then

    while ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) do

    while (StockShopItem(8) < 20) and (StockShopItem(9) < 20) do

  7. #7
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    I don't see anything popping out at me that would cause it to not buy the first item. You could try:

    Simba Code:
    procedure Buy;
    begin
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      repeat
        writeln('Inventory Still not full');
        if (StockShopItem(8) > 20) then
        begin
          writeln('Bought Item 1');
          BuyCoords(90,130,10);
        end else //So it will only try buying the second item if there is not >20 items in the shop
        if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then
        begin
          writeln('Bought Item 2');
          BuyCoords(90,130,10);
        end;
        writeln('Item 1 ' + intToStr(StockShopItem(8)));
        writeln('Item 2 ' + intToStr(StockShopItem(9)));
      until(InvFull);
      writeln('Inventory Full Closing Shop');
      Close_Shop;
      writeln('Closed Shop');
    end;
    end;

    I've never used StockShopItem but I assume it's supposed to return the amount of whatever is in the slot you're specifying? I'd check to be sure that the slot is correct and that there is indeed more than 20 items in it. I know sometimes SRL amount getters break when there's a huge amount of items somewhere but I don't think that would be a problem in a shop.

    You could try using something like

    Simba Code:
    procedure Buy;
    begin
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      repeat
        writeln('Inventory Still not full');
        writeln('Stock of Item 8: ' + intToStr(StockShopItem(8)));
        if (StockShopItem(8) > 20) then
        begin
          writeln('Bought Item 1');
          BuyCoords(90,130,10);
        end else //So it will only try buying the second item if there is not >20 items in the shop
        if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then
        begin
          writeln('Bought Item 2');
          BuyCoords(90,130,10);
        end;
        writeln('Item 1 ' + intToStr(StockShopItem(8)));
        writeln('Item 2 ' + intToStr(StockShopItem(9)));
      until(InvFull);
      writeln('Inventory Full Closing Shop');
      Close_Shop;
      writeln('Closed Shop');
    end;
    end;

    That will write in the debug what the result of StockShopItem is. If that doesn't match the amount that's there, you can assume the function is broken because as mentioned the OSRS include hasn't been updated officially in a long time.

    For the record, all of the ways you tried using the If X and Y then should work the same I think.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  8. #8
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    I don't see anything popping out at me that would cause it to not buy the first item. You could try:

    Simba Code:
    procedure Buy;
    begin
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      repeat
        writeln('Inventory Still not full');
        if (StockShopItem(8) > 20) then
        begin
          writeln('Bought Item 1');
          BuyCoords(90,130,10);
        end else //So it will only try buying the second item if there is not >20 items in the shop
        if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then
        begin
          writeln('Bought Item 2');
          BuyCoords(90,130,10);
        end;
        writeln('Item 1 ' + intToStr(StockShopItem(8)));
        writeln('Item 2 ' + intToStr(StockShopItem(9)));
      until(InvFull);
      writeln('Inventory Full Closing Shop');
      Close_Shop;
      writeln('Closed Shop');
    end;
    end;

    I've never used StockShopItem but I assume it's supposed to return the amount of whatever is in the slot you're specifying? I'd check to be sure that the slot is correct and that there is indeed more than 20 items in it. I know sometimes SRL amount getters break when there's a huge amount of items somewhere but I don't think that would be a problem in a shop.

    You could try using something like

    Simba Code:
    procedure Buy;
    begin
    if Shop_Screen then
    begin
      writeln('Shop screen Open');
      repeat
        writeln('Inventory Still not full');
        writeln('Stock of Item 8: ' + intToStr(StockShopItem(8)));
        if (StockShopItem(8) > 20) then
        begin
          writeln('Bought Item 1');
          BuyCoords(90,130,10);
        end else //So it will only try buying the second item if there is not >20 items in the shop
        if ((StockShopItem(8) < 20) and (StockShopItem(9) < 20)) then
        begin
          writeln('Bought Item 2');
          BuyCoords(90,130,10);
        end;
        writeln('Item 1 ' + intToStr(StockShopItem(8)));
        writeln('Item 2 ' + intToStr(StockShopItem(9)));
      until(InvFull);
      writeln('Inventory Full Closing Shop');
      Close_Shop;
      writeln('Closed Shop');
    end;
    end;

    That will write in the debug what the result of StockShopItem is. If that doesn't match the amount that's there, you can assume the function is broken because as mentioned the OSRS include hasn't been updated officially in a long time.

    For the record, all of the ways you tried using the If X and Y then should work the same I think.
    sorry i should explain better it does buy item 1 but wont buy item 2, instead it just keeps looping until item 1 has X amount of stock again. ill give your suggestions a try and see if i can get it working.

    also i cant just use an else because there are 4 different items which i want the script to purchase.

    im using the writeln code to confirm that the script is getting the correct amount stock the shop and its correct.

    thanks
    Last edited by seany; 09-23-2014 at 04:51 PM.

  9. #9
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by hello to you all View Post
    sorry i should explain better it does buy item 1 but wont buy item 2, instead it just keeps looping until item 1 has X amount of stock again. ill give your suggestions a try and see if i can get it working.

    thanks
    Is Item 2 the slot 9? It's possible that you want your if statement to say:

    if ((StockShopItem(8) < 20) and (StockShopItem(9) > 20)) then

    Because you had it set to only but the second item when 8 and 9 were less than 20, but if you want it to buy 9 then you probably want more than 20 I assume?

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  10. #10
    Join Date
    Jul 2006
    Posts
    189
    Mentioned
    1 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Is Item 2 the slot 9? It's possible that you want your if statement to say:

    if ((StockShopItem(8) < 20) and (StockShopItem(9) > 20)) then

    Because you had it set to only but the second item when 8 and 9 were less than 20, but if you want it to buy 9 then you probably want more than 20 I assume?
    YES! omg such a simple little error!

    thankyou!

  11. #11
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    You're welcome! I hope everything works well for you now. Feel free to ask away if you run into other problems

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •