Jump to content
  • 0

Auto Vote Reward ->Network


Question

Posted (edited)

l2jfrozen ,Rev:1004, interlude .

 

So hopzone and topzone work ok, network doesnt . I tried to fix it but I cant . What I used for core are these lines

No Console errors.

Just logger that says network is offline.

First try:


	protected int getL2NetworkVotes()
	{
	       int votes = -1;
		
		try
		{
					{
							final URL obj = new URL(PowerPakConfig.VOTES_SITE_L2NETWORK_URL);
							final HttpURLConnection con = (HttpURLConnection) obj.openConnection();
							
							con.addRequestProperty("User-Agent", "L2Network");
							con.setConnectTimeout(5000);
							
							final int responseCode = con.getResponseCode();
							if (responseCode == 200)
							{
								try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))
								{
									String inputLine;
									while ((inputLine = in.readLine()) != null)
									{
										if (inputLine.contains("color:#e7ebf2"))
										{
											votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", ""));
											break;
										}
									}
								}
							}
						}
		}
		catch (final Exception e)
		{
		_log.info("[NETWORK] offline!!!!!!!");
		Broadcast.toAllOnlinePlayers(new CreatureSay(2, Say2.HERO_VOICE,"[Network]", "Offline!"));
			// e.printStackTrace();
		}
		return votes;
	}

Second try:

 


	
	protected int getL2NetworkVotes()
	{
		int votes = -1;
		URL url = null;
		URLConnection con = null;
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		
		try
		{
			url = new URL(PowerPakConfig.VOTES_SITE_L2NETWORK_URL);
			con = url.openConnection();
			con.addRequestProperty("User-Agent", "L2Network");
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("color:#e7ebf2"))
				{
					votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", ""));
					break;
				}
			}
		}
		catch (final Exception e)
		{
		_log.info("[NETWORK] offline!!!!!!!");
		Broadcast.toAllOnlinePlayers(new CreatureSay(2, Say2.HERO_VOICE,"[Network]", "Offline!"));
		Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.HERO_VOICE,"[Server Site]", PowerPakConfig.SERVER_WEB_SITE));
			// e.printStackTrace();
		}
		finally
		{
			if (in != null)
				try
				{
					in.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (isr != null)
				try
				{
					isr.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (is != null)
				try
				{
					is.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
		}
		return votes;
	}

HTML ,powerpack

 

# Do you want enable powerpack?
PowerPakEnabled  = True


# Automatic Vote Reward System
VoteRewardSystem= True
VotesRequiredForReward = 1
VotesSystemInitialDelay= 60000
VotesSystemStepDelay= 5000
VotesRewards= 1851,20;

 

What is wrong?

Searched everywhere for many hours .. cant figure it out.

 

Edited by sotid

Recommended Posts

  • 0
Posted

this line:

votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", ""));

change to:

votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", "").replaceAll(",",""));

 

  • Thanks 1
  • 0
Posted (edited)

about l2network you wont loose much if you dont have it... i have clients that they get in one week 100 visits from this topsite while from others 700+

Edited by DenArt Designs
  • 0
Posted

We have discovered clone, quantum teleportation for individual atoms how to cure 70% of illnesses but sure let's use the topzone website to get the votes when they provide us API. :keepo:

  • 0
Posted (edited)

as kara said, you should use API instead of all those crap connections...

 

@Kara` How old do you think are the above codes? :D

 

Ontopic:

try this one:

protected int getL2NetworkVotes()
{
	try
	{
		final URL obj = new URL(PowerPakConfig.VOTES_SITE_L2NETWORK_URL);
		final HttpURLConnection con = (HttpURLConnection) obj.openConnection();

		con.addRequestProperty("User-Agent", "L2Network");
		con.setConnectTimeout(5000);
		String inputLine;
		try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))
		{
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("color:#e7ebf2"))
					return Integer.valueOf(inputLine.split(">")[2].split("<")[0].replace(",", ""));
			}
		}
	} 
	catch (Exception e)
	{
		Broadcast.toAllOnlinePlayers(new CreatureSay(2, Say2.HERO_VOICE,"[Network]", "Offline!"));
		Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.HERO_VOICE,"[Server Site]", PowerPakConfig.SERVER_WEB_SITE));
	}
	return -1;
}

 

Edited by melron
  • 0
Posted
2 minutes ago, melron said:

as kara said, you should use API instead of all those crap connections...

 

@Kara` How old do you think are the codes above? :D

 

 

 

So old that you weren't inside maxcheaters yet. (2009+)

 

Instead of catch use the respondeCode for the message

  • 0
Posted (edited)
5 minutes ago, Kara` said:

 

So old that you weren't inside maxcheaters yet. (2009+)

Im from 2k7 kiddo

Edited by melron
  • Haha 1
  • 0
Posted (edited)
2 hours ago, melron said:

Im from 2k7 kiddo

Still young. But who i am to speaking with a 2017 account.

 

Edited by Kara`
  • 0
Posted (edited)
32 minutes ago, Kara` said:

But who i am to speaking with a 2017 account.

AccessDenied (the scammer), AKA 

Arrays.asList(109,97,103,110,101,116,111,51,48).forEach(val -> System.out.print(((char)val.intValue())));

:angel:

 

@Kara` malaka vrika ena topic pou eixes anoiksei ton sep tou 2012 kai exw katourithei

Edited by melron
  • 0
Posted (edited)
34 minutes ago, melron said:

AccessDenied (the scammer), AKA 


Arrays.asList(109,97,103,110,101,116,111,51,48).forEach(val -> System.out.print(((char)val.intValue())));

:angel:

 

@Kara` malaka vrika ena topic pou eixes anoiksei ton sep tou 2012 kai exw katourithei

Παλι καλα που βρισκετε του 2012 και του 2011 και οχι του 2008 που ειχα και gracia server :'(

Επισης μην μιλησω για κωδικες σου πριν 1 χρονο θα κατουρηθουμε στα γελια :keepo:

Edited by Kara`
  • 0
Posted
1 minute ago, Kara` said:

Παλι καλα που βρισκετε του 2012 και του 2011 και οχι του 2008 που ειχα και gracia server :'(

Επισης μην μιλησω για κωδικες σου πριν 1 χρονο θα κατουρηθουμε στα γελια :keepo:

eides na kritikarw kwdhka palio sou? egw eipa topic den eixe kan kwdhka mesa

  • 0
Posted
41 minutes ago, melron said:

eides na kritikarw kwdhka palio sou? egw eipa topic den eixe kan kwdhka mesa

Ξεκινα να κριτικαρεις θα πεθανεις στο κλαμα, ειδικα οταν ρωταγα τι ειναι το null

  • 0
Posted
1 minute ago, Kara` said:

Ξεκινα να κριτικαρεις θα πεθανεις στο κλαμα, ειδικα οταν ρωταγα τι ειναι το null

psisou gia topic offsection gia na ta ksethapsoume 

  • 0
Posted
28 minutes ago, melron said:

psisou gia topic offsection gia na ta ksethapsoume 

Οχι ρε μαλακα, δεν με λυπασαι, να βγαλω στη φορα κωδικες που εγραφα πριν 8-9 χρονια?

Guest
This topic is now closed to further replies.
×
×
  • Create New...