Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • E S C O B A R: Anyone able to help me, i'm trying to find a decent source/client to start from , I haven't been near a laptop in over two years . Does much people still play RSPS's also?
      Today at 04:52:38 PM
    • dan v jad: Great osrsps experience - check us out - join on discord! dxp, dpoints [link]
      Today at 09:50:00 AM
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      August 18, 2019, 07:14:43 AM
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      August 18, 2019, 07:14:35 AM
    • puppajohn: Come and join us today for amazing content !
      August 16, 2019, 10:26:16 PM
    • puppajohn:[link] come and join us now! you have donator on your server? no problem we restore your donator credits and symbol ! free M box on loggins
      August 16, 2019, 10:26:02 PM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW || EP GETS YOU OSRS GP TOKENS
      August 15, 2019, 05:13:07 PM
    • hodford: autoscape,0rg is actually fudgein lit as come check it out
      August 13, 2019, 02:59:58 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:49 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:46 AM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW
      August 08, 2019, 07:29:43 PM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:53 AM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:46 AM
    • asshole_rule: bernie sanders
      August 06, 2019, 07:54:02 PM
    • PavSwag: #AS 100M OSRS GP GIVEAWAY!! [link] 317 Oldschool RuneScape Private Server emulating core factors of the game with a strong economy and balance of experience to bossing and prestiging -Receive DONATOR Perks by maxing to 99s- Lumbridge remade - Login with a starter set of armour and items - PK District - Preloading sets - Activity points for training - All Skills Working, Skilling Island, Skilling Pets, Skilling Rewards - All Working Max Capes - 25+ Bosses with Pets - Superior Slayer Encounters - Player Owned Shops - Minigames, Construction, Sawmill, Warriors Guild, Pest Control, Barrows (with pets), Fight Caves, Inferno Caves, Chambers of Xeric, Custom Raids - NPC Drop Table, Kills Tracker, Points Tracker, Extra settings. - Doubled Xp & Points Weekends - Vote System - Vote4Donor - Competitive Highscores - Tons of Content - Join us today for bonus giveaways and free ultra mystery box upon login!   Official YouTube Media: [youtube]P5D0eXEmjA4[/youtube] Join NOW Ill personally give you Ultra Mystery Boxes (Twisted Bow??) Im the Developer :smiley: Heres the Discord:  [link] BTW 100m OSRS GP Giveaways WEEKLY!
      August 05, 2019, 01:05:53 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:52 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:47 PM
    • suelo: does the search not work on here?
      August 05, 2019, 02:12:08 AM
    • PavSwag: #AS 100M OSRS GP GIVEAWAY!! [link] 317 Oldschool RuneScape Private Server emulating core factors of the game with a strong economy and balance of experience to bossing and prestiging -Receive DONATOR Perks by maxing to 99s- Lumbridge remade - Login with a starter set of armour and items - PK District - Preloading sets - Activity points for training - All Skills Working, Skilling Island, Skilling Pets, Skilling Rewards - All Working Max Capes - 25+ Bosses with Pets - Superior Slayer Encounters - Player Owned Shops - Minigames, Construction, Sawmill, Warriors Guild, Pest Control, Barrows (with pets), Fight Caves, Inferno Caves, Chambers of Xeric, Custom Raids - NPC Drop Table, Kills Tracker, Points Tracker, Extra settings. - Doubled Xp & Points Weekends - Vote System - Vote4Donor - Competitive Highscores - Tons of Content - Join us today for bonus giveaways and free ultra mystery box upon login!   Official YouTube Media: [youtube]P5D0eXEmjA4[/youtube] Join NOW Ill personally give you Ultra Mystery Boxes (Twisted Bow??) Im the Developer :smiley: Heres the Discord:  [link] BTW 100m OSRS GP Giveaways WEEKLY!
      August 04, 2019, 11:48:39 PM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW?
      August 04, 2019, 11:21:52 PM

    Author Topic: ShopRestock  (Read 310 times)

    0 Members and 1 Guest 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.
    Runescape Gambling

     

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