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
  • Queue List


    Astrate
     Share

    Recommended Posts

    	public void onPlayerMessage(Message message) {
    		if(PlayerMessage.equalsIgnoreCase("!play") & !PlayerPlaying) {
    			PlayerName = message.getUsername();
    			PlayerPlaying = true;

    Okay, So I'm fairly new to java and programming, But I'm trying to have a queue system after someone says !play in Clan Chat.. But I'm completely stuck, I'm trying to allow it add players usernames into a list and only use the 1st player and once it's done it goes down the list, But blocks out any other input from any other plays unless their Username is in 0 Element... Like I said, I'm extremely new, This is a huge learning curve and I'm trying to understand arrays but I don't think they can update every time a Variable is called EX: PlayerName returns the players name but I'd like to try to extend that towards a list like I was saying.

    Steps:
    1. Get's username
    2. Checks the current it as currently playing

    3. Ignores all other players typing in certain phrases EX: !Play !Flip, Etc

    4. Adds players name into a list 0 - CurrentPlayerPlaying 1 - PlayerInWaiting 3 - PlayingInwaiting

    This is what I use to detect whether the player has said !flip in the script
     

    if(PlayerMessage.equalsIgnoreCase("!flip)) {

    When I run it, I tested it with 2 players, (OnePlaying, OneNotPlaying) OneNotPlaying was able to type in !Flip when OnePlaying was currently in a game with the bot, I want it to completely ignore the player not playing... Idk if it's clear what I'm trying to say but that's the best way I can explain what I'm trying to accomplish


    If anyone could help point me into the correct direction, I've been trying to work around this for a while and decided I needed help.

     

     

    Edited by Astrate
    Link to comment
    Share on other sites

    I think the interface you're looking for is called Queue

    A practical example:

    Queue<Integer> queue = new LinkedList<>();
    for (int i = 0; i < 5; i++) { //adding { 0,1,2,3,4 }
       queue.add(i); 
    }
    int firstNum = queue.pop(); //returns 0
    int secondNum = queue.pop(); //returns 1
    int thirdNum = queue.pop(); //returns 2
    

     

    Link to comment
    Share on other sites

    33 minutes ago, Articron said:

    I think the interface you're looking for is called Queue

    A practical example:

    Queue<Integer> queue = new LinkedList<>();
    for (int i = 0; i < 5; i++) { //adding { 0,1,2,3,4 }
       queue.add(i); 
    }
    int firstNum = queue.pop(); //returns 0
    int secondNum = queue.pop(); //returns 1
    int thirdNum = queue.pop(); //returns 2
    

     

    Awesome, Thank you!

    Link to comment
    Share on other sites

    44 minutes ago, Astrate said:

    I'm still confused on how to use arrays and how to stop the bot from allowing other players to say !flip 😕 anyone help ?

    I'd suggest going through a couple java tutorials on lists and queues. You'll learn contains, get, add, put, pop, etc.

    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.