Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


[TUT] News System

6 posts in this topic


Have you tried any of my scripts with the news system? DChickens & DClay are both using it. It loads text from a .txt document, and shows them to you. And you - can update this at any point!

Place this somewhere in your script:

public ArrayList<String> getNews()	
	ArrayList<String> toReturn = new ArrayList<String>();		
  		URL url = new URL("mywebsite.com/document.txt");		    
  		BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));		    
  		String str;		    
		while ((str = in.readLine()) != null) 
  		catch (MalformedURLException e) 
  			System.out.println("Your firewall blocked the news loader.");		
  		catch (IOException e) 
  			System.out.println("Unable to connect to the news loader.");		
  		}	return toReturn;	

please make sure you change mywebsite.com/document.txt to the location where your news file is.

This code will return the contents of the targeted document.txt in the form of an ArrayList.


than add this on top of your script, together with your other variables

private ArrayList<String> latestNews = new ArrayList<String>();
private long startNewsTime = System.currentTimeMillis();

Now we are going to save the text we just downloaded from the internet - in a new arraylist. To do so, we place the following in your Run() before the script loop.

latestNews = getNews();


After that we put this somewhere above your onPaint function:

int newsToShow = 0;

private void getnewsdata()	
	int newsTimer = (int) (System.currentTimeMillis() - startNewsTime) / 1000;		
	if(newsTimer > 8)		
		startNewsTime = System.currentTimeMillis();			
		if(newsToShow == (latestNews.size() -1)) 
			newsToShow = 0;			
		else if(newsToShow < (latestNews.size())) 

now inside your onPaint function, add the following to actually display your news :)

if(newsToShow < (latestNews.size())) 
g.drawString("NEWS: "+ latestNews.get(newsToShow), 40,40);

Happy scripting & Happy botting

Feel free to ask me any questions, I will answer them as soon as I have the time to do so.

1 person likes this

Share this post

Link to post
Share on other sites

Limited replies here, so I just wanted to say, thanks for the getNews() snippet. I've used it.


Thank you.

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.