Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • how to check if chat has a trade option?


    pokemonhuang
     Share

    Recommended Posts

    by implementing the AdvancedMessageListener

     

    class main implements AdvancedMessageListener

    @Override
        public void onTradeMessage(Message paramMessage) {
      

        }
     

    Edited by None
    Link to comment
    Share on other sites

    13 minutes ago, pokemonhuang said:

    @None can u give me a code example of how to do that? i'm not sure how to implement a listener

    package test;
    
    import java.awt.Graphics;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.AdvancedMessageListener;
    import org.dreambot.api.wrappers.widgets.message.Message;
    
    @ScriptManifest(author = "None", category = Category.MISC, description = "Message Test", name = "Message Test", version = 1.0)
    public class test extends AbstractScript implements AdvancedMessageListener {
    
    	@Override
    	public void onAutoMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onClanMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onGameMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onPlayerMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onPrivateInMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onPrivateInfoMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onPrivateOutMessage(Message arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	@Override
    	public void onTradeMessage(Message arg0) {
    		String personToTrade = "JimmonySmicket";
    				if (arg0.getMessage().toLowerCase().contains("wants to trade") && arg0.getMessage().toLowerCase().contains(personToTrade)) {
    					if (getPlayers().closest(personToTrade) !=null)
    						getTrade().tradeWithPlayer(personToTrade);
    				}
    
    	}
    
    	@Override
    	public int onLoop() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    }

     

    Edited by None
    Link to comment
    Share on other sites

    23 minutes ago, pokemonhuang said:

    @none where would i get the argument for onTradeMessage method?

    not sure what you mean, after implementing the listener the different void messages types  are required, i posted a full class though so you could just copy them all from  what i posted

    Link to comment
    Share on other sites

    i don't use event Listener often. the time i used it, was when i had to detect mouse click or move, you know stuff like that. From my understanding, in this case i have to call "OnTradeMessage" and constantly provide a message. right? How to i extract the message from the chat box? im not sure if my understanding of using event listener is correct. 😅

    But right now im trying to different approach. im using the widgetChild class to extract the message.

    Link to comment
    Share on other sites

    3 minutes ago, pokemonhuang said:

    i don't use event Listener often. the time i used it, was when i had to detect mouse click or move, you know stuff like that. From my understanding, in this case i have to call "OnTradeMessage" and constantly provide a message. right? How to i extract the message from the chat box? im not sure if my understanding of using event listener is correct. 😅

    But right now im trying to different approach. im using the widgetChild class to extract the message.

    Listeners ...listen.. they would flag every time they detect the type of message its supposed to find.

     

    so onTradeMessage would alert the class everytime there was any kind of trade message. so if you review the code i posted, every time theres a trade message on the chat box if it contains the pharase wants to trade and also contains the name of the player you want to trade with it will execute.

     

    Edited by None
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.