Thread: Using Books Easier

Results 1 to 4 of 4
  1. #1 Using Books Easier 
    Registered Member
    Join Date
    Aug 2017
    Posts
    19
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Made this while working on something. I don't have any need for it what so ever. Its not exactly the best written thing I have ever done was mostly to test out what I could do so I'd suggest you edit it to your liking.

    The big benefit of this is that it allows unlimited pages to be used within the book.

    Firstly make a new class inside the players package. Name it BookCreation and paste this code inside
    Code:
    import java.util.ArrayList;
    
    public class BookCreation {
    	
    	//Page number and max pages
    	private int page = 0;
    	private int page_max = 0;
    	
    	//Client Object
    	private Client c = null;
    	
    	//Page title and more
    	private String[] CONTENT_PAGE_TITLE = {
    			"",//title
    			"Previous",//left corner
    			"Next",//right corner
    	};
    	
    	//Holds the books content
    	ArrayList<String> CONTENT_PAGE = new ArrayList<String>();
    	
    	//Constructor
    	public BookCreation(Client c){
    		this.c = c;
    		//this.CONTENT_PAGE_TITLE[0] = title; //Old idea
    	}
    	
    	
    	
    	/* Sends interface */
    	public void openBook() {
    		page = 1;
    		updatePage();
    		c.getPlayerAssistant().showInterface(837);
    	}
    	
    	/*adds the content to the book */
    	public void addContent(String str){
    		CONTENT_PAGE.add(str);
    		page_max = (int) Math.ceil((double) CONTENT_PAGE.size()/22);
    	}
    	
    	/*adds the content to the book */
    	public void addContent(String[] str){
    		for(int i = 0; i < str.length; i++){
    			CONTENT_PAGE.add(str[i]);
    		}
    		page_max = (int) Math.ceil((double) CONTENT_PAGE.size()/22);
    	}
    	
    	/*Title setter*/
    	public void setTitle(String str){
    			CONTENT_PAGE_TITLE[0] = str;
    	}
    	
    	/*Title setter*/
    	public void setLeft(String str){
    			CONTENT_PAGE_TITLE[1] = str;
    	}
    	
    	/*Title setter*/
    	public void setRight(String str){
    			CONTENT_PAGE_TITLE[2] = str;
    	}
    	
    	/* page forward */
    	public  void increasePage() {
    		if (page == page_max) {
    			//nothing here
    		} else {
    			page++;
    			updatePage();
    		}
    	}
    	
    	/* page back */
    	public void decreasePage() {
    		if (page == 1) {
    			//nothing here
    		} else {
    			page--;
    			updatePage();
    		}
    	}
    	
    	/* Updates the strings on the interface to the correct page text */
    	private void updatePage() {
    		
    		//Clears book before each update
    		for(int i = 0, id = 843;i < 22; i++, id++){
    			c.getPlayerAssistant().sendFrame126("", id);
    		}	
    		
    		//Sets the title etc
    		c.getPlayerAssistant().sendFrame126(CONTENT_PAGE_TITLE[0], 903);	/* Title of the book */
    		c.getPlayerAssistant().sendFrame126(CONTENT_PAGE_TITLE[1], 14165);	/* Bottom left corner */
    		c.getPlayerAssistant().sendFrame126(CONTENT_PAGE_TITLE[2], 14166);	/* Bottom right corner */
    		
    		
    
    		int i = 22 * (page - 1); //Set i to first entry for the page from array. i = 0 on page 1 then 22 page 2, 44 page 3, 66 etc
    
    		for(int id_num = 843;i < (22*page); i++, id_num++){//Simply loop over all items in the array for the page (Each page has 22 items 22 * page)
    			if(i >= CONTENT_PAGE.size()){ //Prevents trying to print non existent lines
    				return;
    			}
    			c.getPlayerAssistant().sendFrame126(CONTENT_PAGE.get(i), id_num); //Send the frame
    		}		
    	}
    }
    Next find your ClickingButtons and at the bottom of all the cases add this
    Code:
    		case 3073:
    			player.getBook().increasePage();
    		break;
    		
    		case 3071:
    			player.getBook().decreasePage();
    		break;
    			
    		case 39178:
    			player.getPlayerAssistant().closeAllWindows();
    		break;
    Finally in client add these in. (Whilst it doesn't matter where you put these I suggest placing them where other similar methods have been placed)
    Code:
    	private BookCreation Book = new BookCreation(this);
    
    	public BookCreation getBook() {
    		return Book;
    	}
    Now to use it you just fill it with content, set a title and open it like so. This can be used from within ClickItem for a specific item, from a command or anything else. My aweful example below from my testing.
    Code:
       		String[] str = {
        				"1",
        				"2",
        				"3",
        				"4",
        				"5",
        				"6",
        				"7",
        				"8",
        				"9",
        				"10",
        				"11",
        				"12",
        				"13",
        				"14",
        				"15",
        				"16",
        				"17",
        				"18",
        				"19",
        				"20",
        				"21",
        				"22",
        				"23",
        				"24",
        				"25",
        				"26",
        				"27",
        				"28",
        				"29",
        				"30",//etc
        		};
        		
        		player.getBook().addContent(str);
        		player.getBook().setTitle("Test Book");
            	
            	player.getBook().openBook();
    Remember made this while testing not the best but is at least functional.
    Reply With Quote  
     

  2. #2  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Use [ code] [/ code] tags instead of spoilers.
    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Reply With Quote  
     

  3. #3  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Use code tags. Other than that messy.
    wtf is this
    String[] str = {
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "10",
    "11",
    "12",
    "13",
    "14",
    "15",
    "16",
    "17",
    "18",
    "19",
    "20",
    "21",
    "22",
    "23",
    "24",
    "25",
    "26",
    "27",
    "28",
    "29",
    "30",//etc
    };

    just make a method that sends strings instead of that clumsy mess.
    Like this
    Code:
    bookInstance.writeWord("Hello",1).writeWord("i see you have opened the book",2);
    Other than that. Ok, i won't use but let the bronze ranks use it. Btw is this made for PI by any chance lol?
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Aug 2017
    Posts
    19
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by S C A P E View Post
    Use code tags. Other than that messy.
    wtf is this
    String[] str = {
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "10",
    "11",
    "12",
    "13",
    "14",
    "15",
    "16",
    "17",
    "18",
    "19",
    "20",
    "21",
    "22",
    "23",
    "24",
    "25",
    "26",
    "27",
    "28",
    "29",
    "30",//etc
    };

    just make a method that sends strings instead of that clumsy mess.
    Like this
    Code:
    bookInstance.writeWord("Hello",1).writeWord("i see you have opened the book",2);
    Other than that. Ok, i won't use but let the bronze ranks use it. Btw is this made for PI by any chance lol?
    Example of inputting data i used from testing. Easy enough to add them line by line but thats gona be mega long. Adding it as either an array or string list is what I chose to do cause of the fact that I can just add them in with a loop as I did. Also obviously messy its something I didn't want to use so never took it to a point where it was alright.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 9
    Last Post: 06-07-2010, 01:50 PM
  2. Replies: 4
    Last Post: 04-20-2010, 07:14 PM
  3. Replies: 20
    Last Post: 03-12-2010, 12:22 AM
  4. Replies: 5
    Last Post: 03-04-2010, 10:11 PM
  5. Othey way of using ckey! "Random book"
    By WolvesSoulZ in forum Tutorials
    Replies: 13
    Last Post: 12-13-2007, 06:29 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •