Jump to content

Canidae

Members
  • Posts

    38
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Canidae

  1. On 2/4/2021 at 2:57 AM, Nbacon said:

    Our loops do the same exact thing and will fuck up in the same way..... but mine can do diffent chaining types...

    You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack. 

  2. On 2/1/2021 at 9:05 PM, Nbacon said:

    I think this is would be better...

    
            int chain[] ={0,1,2,3,4,5,6,...,28};
            int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...};
            for (int i = 0; i < 28; i++) {
                Item item =getInventory().getItemInSlot(chain[i]);
                if (item!=null &&(item.getName().contains("pack"))){
                    getInventory().interact(chain[i],"Open");
                  	sleep....
                }
    
            }

     

    This might mess up when trying to pause the script. I would also write it like this:

    for (Item item : getInventory().getItems()) {
                if (item != null && item.getName().equals("Feather pack") && item.interact("Open")) {
                    //sleep
                }
            }

     

  3. 54 minutes ago, Tom said:

    To improve on this, Item#interact returns a boolean if it was successful or not, so you can do

    
    
    if(inventory.getItemm("Feath pack").interact("Open")) {
     // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 
    }

     

    I would say it depends on the situation. In case of feather packs, I can imagine you don't want to wait a tick everytime you open one since opening them as quick as possible is what you essentially want. You would probably need different code to prevent trying to interact with a non-existent item.

    • Like 3
  4. Outside of your question, this is not how you should go on and write this code. What you are trying is to do one method call which results in buying items, without any kind of looping. That's not going to work properly and even if it will, it's unreliable. You can do multiple things. Create an Event class and execute it as an event, let your script loop through it (by using a task system for example) or write a recursive method (not sure if that's a good idea though).

    This is an example with an event. When you want to buy items, you will create a new event, pass through the list of items and execute the buying. If you are done buying, you set the event to finished and the script will start looping again. (Not sure if this code works and if it's 100% correct, long time ago for me).

    public class Main extends Script {
        
        
        @Override
        public int onLoop() throws InterruptedException {
            if (shouldbuyItems()) {
                BuyItemsEvent event = new BuyItemsEvent(buyItemList);
                event.exchangeContext(getBot());
                execute(event);
            }
            return 300;
        }
    }
    
    public class BuyItemsEvent extends Event {
        
        private List<BuyItem> items;
        
        public BuyItemsEvent(List<BuyItem> items) {
            this.items = items;
        }
        
        @Override
        public int execute() throws InterruptedException {
            if (!getGrandExchange().isOpen()) {
                openGE();
            } else if (boughtItems()) {
                setFinished();
            } else {
                buyItems();
            }
            return 300;
        }
        
        public void openGE() {
            RS2Object geBooth = getObjects().closest("Grand Exchange booth");
            NPC exchangeWorker = getNpcs().closest("Grand Exchange Clerk");
            
            int random = new Random().nextInt(2);
            if (geBooth != null && random == 0) {
                if (geBooth.interact("Exchange")) {
                    new ConditionalSleep(2500, 3000) {
                        @Override
                        public boolean condition() {
                            return getGrandExchange().isOpen();
                        }
                    }.sleep();
                }
            } else if (exchangeWorker != null) {
                if (exchangeWorker.interact("Exchange")) {
                    new ConditionalSleep(2500, 3000) {
                        @Override
                        public boolean condition() {
                            return getGrandExchange().isOpen();
                        }
                    }.sleep();
                }
            }
            
        }
    }

     

    I also recommend using this class for conditional sleeps: 

     

     

     

     

     

  5. 1 hour ago, Chuckle said:

    Connectivity is full its ping that's degraded not sure if a repeater will fix the issue as it will still be a long distance from the hub

    yeah cable always better than wifi 

    That's not a repeater, it's a powerline adapter. It will send the connection through the power lines in your house. Your ping won't be affected that much.

     

  6. 5 hours ago, Tom said:

    I had a $200 debt with OVH, but it was due to a flaw on their end (which they didn't seem to understand) so I acted dumb in a ticket and eventually got it resolved without paying. 

    This is exactly like dad's advice, which is useless obviously. :boge: 

  7. 15 hours ago, ProjectPact said:

    Digital Ocean tried to pull the same thing on me. All I did was kindly email them stating what happened, showed I canceled my agreement on PAYPAL, and that I no longer have been using their service. They tried getting $100 out of me. That’s why I stopped using them, and will never use them again.

    If you looking for an alternative, take a look at Vultr. It basically offers the same service as DigitalOcean, but cheaper.

  8. So to make things clear, you fucked up. Shit happens and you probably forgot about it, or even worse did it intentional. Don't try to make things worse by trying to prevent them from finding you. Contact them through e-mail or give them a call and explain what happened. Don't try to run from it, they will eventually find you anyways and you don't want to battle things like this out in court. (Or however that goes in US). Just at least make sure you don't fuck up like this again and learn from it. A company like that is probably to not going to condone $500 just because you are whatever years old. If you need any help, send me a PM. I have (accidentally) fucked up some stuff in the past as well when I was young.

  9. 12 hours ago, aniki432789 said:

    something like:

     

    absorpWidget = getWidgets().get(202, 1, 9);

    ....

    currentAbsorp = Integer.parseInt(absorpWidget.getMessage());

     

     

    Take the time to learn and understand how widgets work and how to use them.

    Since widget IDs tend to change, you should use something different instead. For example text color, position or something else.

  10. 3 minutes ago, d0zza said:

    You can have global variables in a script

    What do you mean with global variables then? They don't exist in Java and you also said your meaning of global variables aren't (public) static variables. What is it then? The only thing you can do in Java is having public classes with a public static variable in it to make it look like it's some sort of global variable.

     

  11. 5 hours ago, d0zza said:

    Have a global boolean called started that you set to be true inside the action-listener body. Then have an if (started) check in your onLoop.

    I recommend you not using this. If the script list is not refreshed, the static fields will keep their values. So as soon as someone stops the script and starts it again without refreshing the list, it will start instantly and probably crash.

  12. 2 hours ago, R3G3N said:

    There are no text widgets and that sleep condition is similar to what I have after I interact with the widget. My problem is that the interaction does not go through and just leaves the option menu hanging. I don't particularly have trouble with widgets in general. It is only this particular one that has a different behavior.

    image.png.245f7db65f7462920824d7f7f4689b1a.png

    These grid boxes are the widgets. They do not have any texts so I based them off their widget ids.

    If you use the Widget debugger, you will find out there are multiple ways on how to detect a widget. You can also use position for example.

  13. Looking at your code, I recommend you not playing with trades since you will need some additional checks to make sure you trade the right player etc. etc. Start with something more easy, like a cow killer or a woodcutter.

    • Like 1
  14. 4 hours ago, Alek said:

    "Convert strings from files to generate different classes", so essentially ClassReader/Loader? That's not really necessary when you could probably use serialization for whatever you are doing instead - or perhaps it can just be solved with simple file management? We would need more context on what you're trying to do.

    Would that also work for scripts on the SDN? 

  15. 3 minutes ago, Blurper said:

    I don't quite like custom handlers because they probably don't cover all error cases and requires passing of account data via arguments.

    I'll look into the break handler suggestion, thanks.

    Still looking for more suggestions!

    You can add all error message checks yourself, there's a list which contains all of them with the according number. It's probably the easiest way to do so.

     

×
×
  • Create New...