Jump to content
  • 0

Auto Vote Reward


Question

Posted

Geia sas , xrisimopoio auto ton kodika

 

exw interlude l2jequal

 

 

alla den mou douleuei sta kokina m bgazi error kai dn exo kapoia lisi :( :( help me

 

player = L2World.getInstance().getPlayers(rset.getInt("charId"));

 

L2DatabaseFactory.close(con);

 

 

 

package lt.equal.gameserver.instancemanager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import lt.equal.L2DatabaseFactory;
import lt.equal.gameserver.Announcements;
import lt.equal.gameserver.ThreadPoolManager;
import lt.equal.gameserver.model.L2ItemInstance;
import lt.equal.gameserver.model.L2World;
import lt.equal.gameserver.model.actor.instance.L2PcInstance;

public class AutoVoteRewardHandler
{
private final String HOPZONE = "http://l2.hopzone.net/lineage2/moreinfo/L2_InSpiRoN/85982.html";
// 60 * 1000(1000milliseconds = 1 second) = 60seconds
private final int initialCheck = 60 * 1000;
// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
private final int delayForCheck = 1800 * 1000;
private final int[] itemId = { 8762 };
private final int[] itemCount = { 1 };
private final int[] maxStack = { 1 };
private final int votesRequiredForReward = 10;
// do not change
private int lastVoteCount = 0;

private AutoVoteRewardHandler()
{
	System.out.println("Vote Reward System Initiated.");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
}

private class AutoReward implements Runnable
{
	public void run()
	{
		int votes = getVotes();
		System.out.println("L2_InSpiRoN Votes: " + votes);
		if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)
		{
			Connection con = null;
			try
			{
				con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement("" +
						"SELECT" +
						"	c.charId," +
						"	c.char_name" +
						"FROM" +
						"	characters AS c" +
						"LEFT JOIN" +
						"	accounts AS a" +
						"ON" +
						"	c.account_name = a.login" +
						"WHERE" +
						"	c.online > 0" +
						"GROUP BY" +
						"	a.lastIP" +
						"ORDER BY" +							
								"c.level" +
						"DESC");
				ResultSet rset = statement.executeQuery();
				L2PcInstance player = null;
				L2ItemInstance item = null;
				while (rset.next())
				{
					player = L2World.getInstance().getPlayers(rset.getInt("charId"));
					if (player != null && !player.getClient().isDetached())
					{
						for (int i = 0; i < itemId.length; i++)
						{
							item = player.getInventory().getItemByItemId(itemId[i]);
							if (item == null || item.getCount() < maxStack[i])
								player.addItem("reward", itemId[i], itemCount[i], player, true);
						}
					}
				}
				statement.close();
			}
		catch (SQLException e)
		{
				e.printStackTrace();
		}
			finally
			{
				L2DatabaseFactory.close(con);
			}

			setLastVoteCount(getLastVoteCount() + votesRequiredForReward);
		}
		Announcements.getInstance().announceToAll("L2_InSpiRoN Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + votesRequiredForReward) + " Votes.");
		if (getLastVoteCount() == 0)
			setLastVoteCount(votes);
	}
}

private int getVotes()
{
	URL url = null;
	InputStreamReader isr = null;
	BufferedReader in = null;
	try
	{
		url = new URL(HOPZONE);
		isr = new InputStreamReader(url.openStream());
		in = new BufferedReader(isr);
		String inputLine;
		while ((inputLine = in.readLine()) != null)
		{
			if (inputLine.contains("moreinfo_total_rank_text"))
				return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
		}
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
	finally
	{
		try
		{
			in.close();
		}
		catch (IOException e)
		{}
		try
		{
			isr.close();
		}
		catch (IOException e)
		{}
	}
	return 0;
}

private void setLastVoteCount(int voteCount)
{
	lastVoteCount = voteCount;
}

private int getLastVoteCount()
{
	return lastVoteCount;
}

public static AutoVoteRewardHandler getInstance()
{
	return SingletonHolder._instance;
}

@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
	protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();
}
}

4 answers to this question

Recommended Posts

  • 0
Posted

vsk fixara to 2o to 1o akoma error m bgazi , dn exi etimes epiloges se auto to error :/

 

tora m bgazi auto to error gt to getPlayers ine gia alo chronicle k to getAllPlayer ine to sosto

ala k pali error ? :/

 

player = L2World.getInstance().getAllPlayers() (rset.getInt("charId"));

 

 

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


  • Posts

    • Add some share links, would be nice for people that still looking for them!
    • Please do not insult anybody and respect other works. Do not have hateful behaviour, last warning.
    • You cant add cloaks on interlude packs, is possible to find ones but will never work correct on character.
    • Hello everyone, want to sell some of my custom features in my server, someone might be interested. Collections: (50euro) - you need ingredients (min/max) - can you choose enchant level  - reward : custom skills Enemy Inventory and stats checker: (25euro) - you can check what is your enemy wearing - how much is it enchanted - you can see his detailed info about stats - pvp/pk/rebirth/pve dmg etc anything can be added Gamble (random craft item) - (50 euro)  - by using command .gamble - windown will pop up  - name of the item / chances / % of your points / maximum you can have shows  - you can buy instantly points / or item can be made for that  - each pack can have different prices/items  - refresh give another 5 random items. Custom Enchant System: (20euro)  - target all grades - one scroll can be used for any grade  - increaseEnchantby / decreaseEnchantBy Custom Rotated Farm Zone: (50euro)  - players will be automaticly flagged when enter / unflagged when leave  - you can make any zone like that  - you can add any restriction you want or dont.  - Rotation will be announced in Global  Chat  - in zone drop will be increased by 30% - or you can modify by config  - maybe you want zone where they need lets say 10x Enter to enter can be done - i can give you code, or i can also implement for you - if you want some other custom code, and im able to do it you can ask me discord:expllo#8222 or just expllo - if you won't find, message me here.  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and 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..