Jump to content

acceptTrade not working


Roflobster

Recommended Posts

Hello, I am extremely new to this community and was hoping someone could help me out! I am writing my first script and when trading I seem to have a weird problem. When I call the acceptTrade method in the Trade class it only works when the client is loaded fresh. It will work one single time and after that will no longer function until the client (not my script) is completely re started. I know it is not an error in my code because I have debug so I know the accept method is being called. When this happens the mouse just hovers over the decline button and does nothing. I have searched and found a few others with this exact problem but none of the threads had a solution only the typical 'I figured it out thanks!'.

 

If anyone has any info on the problem that would be fantastic! Thanks a bunch :)

Link to comment
Share on other sites

42 minutes ago, whipz said:

Sorry but it has to be an error in your code, if you would like to post it up, we could have a better look, or you can add my skype whipzman@gmail.com or whipz osbot and you can send it to me there or in a private message, and i can have a look into it for you

To add onto this, if the button were actually broken then others would have complained by now.

Link to comment
Share on other sites

5 minutes ago, IDontEB said:

To add onto this, if the button were actually broken then others would have complained by now.

They have. I stated that in the OP :)

 

Sorry but it has to be an error in your code, if you would like to post it up, we could have a better look, or you can add my skype whipzman@gmail.com or whipz osbot and you can send it to me there or in a private message, and i can have a look into it for you

I will post it a bit later :)

Edited by Roflobster
Link to comment
Share on other sites

59 minutes ago, whipz said:

Sorry but it has to be an error in your code, if you would like to post it up, we could have a better look, or you can add my skype whipzman@gmail.com or whipz osbot and you can send it to me there or in a private message, and i can have a look into it for you

    private void handleTrading() {
        if(!isCurrentlyTrading) {
            whenTradeOpened = System.currentTimeMillis();
        }

        log("Is trade offer empty?   " + getTrade().getTheirOffers().isEmpty());
        log("Did he accept?   " + getTrade().didOtherAcceptTrade());
        isCurrentlyTrading = true;
        if(System.currentTimeMillis() - whenTradeOpened >= 60000) {
            log("Trade condition 1");
            putPlayerOnCooldown(getTrade().getOtherPlayer());
            getTrade().declineTrade();
            handleTradeClosed();
        } else if(getTrade().isSecondInterfaceOpen() && getTrade().didOtherAcceptTrade()) {
            log("Trade condition 2");
            long amount = RsBuddy.getPrice(getTrade().getTheirOffers().getItems());
            putPlayerOnCooldown(getTrade().getOtherPlayer(), 10000);
            getTrade().acceptTrade();
            handleTradeComplete(amount);
        } else if(getTrade().getTheirOffers().isEmpty() && getTrade().didOtherAcceptTrade()) {
            log("Trade condition 3");
            getTrade().declineTrade();
            putPlayerOnCooldown(getTrade().getOtherPlayer());
            handleTradeClosed();
        } else if(!getTrade().getTheirOffers().isEmpty() && getTrade().didOtherAcceptTrade() && (System.currentTimeMillis() - lastAcceptAttempt >= 1000)) {
            log("Trade condition 4");
            getTrade().acceptTrade();
            lastAcceptAttempt = System.currentTimeMillis();
        }
    }

make your own method

Yeah I could but that would not solve the problem that lies within the API.

Edited by Roflobster
Link to comment
Share on other sites

3 hours ago, Roflobster said:

    private void handleTrading() {
        if(!isCurrentlyTrading) {
            whenTradeOpened = System.currentTimeMillis();
        }

        log("Is trade offer empty?   " + getTrade().getTheirOffers().isEmpty());
        log("Did he accept?   " + getTrade().didOtherAcceptTrade());
        isCurrentlyTrading = true;
        if(System.currentTimeMillis() - whenTradeOpened >= 60000) {
            log("Trade condition 1");
            putPlayerOnCooldown(getTrade().getOtherPlayer());
            getTrade().declineTrade();
            handleTradeClosed();
        } else if(getTrade().isSecondInterfaceOpen() && getTrade().didOtherAcceptTrade()) {
            log("Trade condition 2");
            long amount = RsBuddy.getPrice(getTrade().getTheirOffers().getItems());
            putPlayerOnCooldown(getTrade().getOtherPlayer(), 10000);
            getTrade().acceptTrade();
            handleTradeComplete(amount);
        } else if(getTrade().getTheirOffers().isEmpty() && getTrade().didOtherAcceptTrade()) {
            log("Trade condition 3");
            getTrade().declineTrade();
            putPlayerOnCooldown(getTrade().getOtherPlayer());
            handleTradeClosed();
        } else if(!getTrade().getTheirOffers().isEmpty() && getTrade().didOtherAcceptTrade() && (System.currentTimeMillis() - lastAcceptAttempt >= 1000)) {
            log("Trade condition 4");
            getTrade().acceptTrade();
            lastAcceptAttempt = System.currentTimeMillis();
        }
    }

Yeah I could but that would not solve the problem that lies within the API.

How does this get called ?

	if (trade.isFirstInterfaceOpen() && trade.didOtherAcceptTrade()) {
                log("Accepting first trade");
                trade.acceptTrade();
                new ConditionalSleep(10000) {
	                    @Override
                    public boolean condition() throws InterruptedException {
                        return trade.isSecondInterfaceOpen();
                    }
                }.sleep();
            } else if (trade.isSecondInterfaceOpen()) {
                log("Accepting second trade");
                if (trade.getTheirOffers().contains(527)) {
                    bones = bones + trade.getTheirOffers().getItem(527).getAmount();
                }
                if (trade.getTheirOffers().contains(2133)) {
                    meat = meat + trade.getTheirOffers().getItem(2133).getAmount();
                }
	                trade.acceptTrade();
                new ConditionalSleep(10000) {
	                    @Override
                    public boolean condition() throws InterruptedException {
                        return !trade.isCurrentlyTrading();
                    }
                }.sleep();
            }
	

This is from one of my older scripts so no hate, however i just tested and this still works I can show you how it was getting called if needed, but this works fine

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...