Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • Thesnowmann: So is this forum just dead or something? What the heck happened to the gloryness that was moparscape?
      Today at 07:23:53 AM
    • AUSGP: G2kWba2
      Today at 02:21:34 AM
    • AUSGP: You can use the code just like an invite, click join servers under your server list
      Today at 02:21:22 AM
    • AUSGP: If you haven't already, go enter AUS-GP's 100M 07 launch giveaway! It's all on Discord, and requires no personal details so there is 100% no way you can get scammed.  The discord code is: G2kWba2
      Today at 02:20:58 AM
    • AUSGP: If you haven't already, go enter AUS-GP's 100M 07 launch giveaway! It's all on Discord, and requires no personal details so there is 100% no way you can get scammed.  The discord invite link is: [link]
      Today at 02:20:48 AM
    • Aydubbs: Apocalypse Whats Your Discord
      April 04, 2020, 05:39:13 PM
    • rooneyscape: apocalypse add me on discord - noxin#8914
      April 04, 2020, 03:50:21 AM
    • apocalypsePK: to code for them
      April 02, 2020, 04:06:46 PM
    • apocalypsePK: 10years since i logged onto this forum anyone got any decent ps that needs a unigrad
      April 02, 2020, 04:06:42 PM
    • ragnoroker: BRAND NEW SERVER 6 HOURS OLD - RELIVE YOUR CHILDHOOD -[link]
      March 30, 2020, 09:17:02 PM
    • ragnoroker: BRAND NEW SERVER 6 HOURS OLD - RELIVE YOUR CHILDHOOD -[link]
      March 30, 2020, 09:16:51 PM
    • Themaxer: I need the starter pack please. Can someone pass me the link?
      March 28, 2020, 12:21:32 PM
    • Themaxer: Hi
      March 28, 2020, 12:19:26 PM
    • drubrkletern: whats happenin forum
      March 26, 2020, 10:14:36 PM
    • Lin: we're all old now
      March 24, 2020, 10:37:19 PM
    • wildskiller: wtf has happened to this forum
      March 24, 2020, 09:13:45 AM
    • rune-list: mistexps.com - #1 rsps with raids 1, raids 2, custom raids, new content, and more!
      March 21, 2020, 12:11:55 PM
    • ranger squad: I also miss u fags
      March 16, 2020, 04:50:33 AM
    • asshole_rule: miss u fags
      March 15, 2020, 10:08:18 AM
    • drubrkletern: damn... i wonder what the #1 CUSTOM RSPS of 2020 is ..
      March 14, 2020, 01:28:41 PM

    Author Topic: ShopRestock  (Read 627 times)

    0 Members and 2 Guests are viewing this topic.

    Offlineimback4more

    • Member
    • ***
    • Posts: 126
    • Thanks: +0/-0
      • View Profile
    ShopRestock
    « on: August 27, 2018, 11:20:02 PM »
    So my ShopRestock works perfectly fine.
    My problem is that, if you buy let's say all 10 of Air runes out of 10.
    Then, the ShopRestock is going to have an endless loop of restocking the Air runes, even though the Air runes aren't restocking.
    Mainly because the Air runes aren't in the shop anymore and it's just a blank space slot since I bought all 10.

    Now, let's say I buy 9 out of 10 Air runes.
    Because there is still 1 left, and the maximum it is suppose to have is 10.
    Then, the ShopRestock is going to start restocking 1 Air rune every 5 seconds and stops once it has the maximum of 10.
    Which is exactly how it's suppose to work.
    How exactly do I tell the server to re-add the Air runes back to its slot in the shop that were all bought so it can start restocking them again?

    Here's my shoprestock.java

    Code: [Select]
    public ShopRestockTask(Shop items) {
            super(5);
            this.shop = items;
            System.out.println("debug restock 1");
        }


        public final Shop shop;


        @Override
        protected void execute() {
            if(shop.fullyRestocked()) {
                System.out.println("debug restock 2");
                stop();
                return;
            }
            if(shop.getId() != Shop.GENERAL_STORE) {
                System.out.println("debug restock 3");
                for(int shopItemLength = 0; shopItemLength < shop.getOriginalStock().length; shopItemLength++) {
                    //System.out.println("debug restock 4");
                    int ogStockAmount = shop.getOriginalStock()[shopItemLength].getAmount();
                    int currentStockAmount = shop.getItems()[shopItemLength].getAmount();
                   
                    if(ogStockAmount > currentStockAmount) {
                        shop.add(shop.getItems()[shopItemLength].getId(), 1);
                        System.out.println("debug restock 5");
                    } else if(ogStockAmount < currentStockAmount) {
                        shop.delete(shop.getItems()[shopItemLength].getId(), 1);
                        System.out.println("debug restock 6");
                    }
                   
                }
            } else {
                for(Item it : shop.getValidItems()) {
                    shop.delete(it.getId(), 1);
                    System.out.println("debug restock 7");
                }
            }
            shop.publicRefresh();
            shop.refreshItems();
            if(shop.fullyRestocked()) {
                stop();
                System.out.println("debug restock 8");
            }
            System.out.println("debug restock 9");
        }


        @Override
        public void stop() {
            setEventRunning(false);
            shop.setRestockingItems(false);
            System.out.println("debug restock 10");
        }

    Here's a video of what I'm talking about.

    The shop perfectly restocks the items back to 10.
    But, if I buy all 10 of them. The shop doesn't restock and it's stuck on an endless loop with debugs 3, 5, and 9.

    [video][/video]
    « Last Edit: August 27, 2018, 11:45:11 PM by imback4more »
    Runescape Gambling

    Offlinematzie

    • Member
    • ****
    • Posts: 1,014
    • Thanks: +0/-0
      • View Profile
    Re: ShopRestock
    « Reply #1 on: September 21, 2018, 03:05:24 PM »
    When you buy an item from the shop that is part of the shops default items, the itemID should not be nulled out, it should keep the itemID and just change the count to 0. The code probably sets itemID to -1, so when you add an item you are just restocking null's.
    smart phones are dumb
    people are smart phones.

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal