Jump to content
  • 0

[REQUEST]New hopzone votereward system.


Question

Posted

hello.

 

since you all notice that hopzone have a new update (template)

the hopzone votereward system doesn't work

if anyone has a fixed vote reward system or any update ffor an available one.

please do a reply with it!

 

 

ps: free only no spamming please.

 

BEST REGARDS!

LordOfDarkness

 

PS2 : here is my vote reward if some one want to rework it.

package net.sf.l2j.gameserver.model.entity.event;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collection;
import java.net.URLConnection;


import net.sf.l2j.gameserver.model.entity.Announcements;
import net.sf.l2j.gameserver.thread.ThreadPoolManager;

import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;



public class vote
{
private int			initialCheck			= 60 * 1000;																																																	// 60 seconds = 1 minutes
private int			delayForCheck			= 600 * 1000;																																																	// 300 seconds = 10 minutes
private String		HOPZONE					= "http://l2.hopzone.net(server link deleted due to protection.";
private int			HopZonereward1Id		= 7570;
private int			HopZonereward1Count		= 5;
private int			HopZonereward2Id		= 8752;
private int			HopZonereward2Count		= 2;
private int			HopZonevotesForReward	= 4;
private int			HopZonemaxRewardStack	= 5000;
private int			HopZonelastVoteCount	= 0;

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

private class AutoReward implements Runnable
{
	public void run()
	{
		System.out.println("Vote Count Check.");
		HopzoneCheck();
	}
	private void HopzoneCheck()
	{
		int hopZone = getHopZoneVotes();
		System.out.println("Hopzone Votes:" + hopZone);
		if (hopZone != 0 && getLastHopzoneVoteCount() != 0 && hopZone >= getLastHopzoneVoteCount() + HopZonevotesForReward)
		{
			Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
			for (L2PcInstance player : pls)
			{
				if (player != null &&!player._fake)
				{
					L2ItemInstance item1 = player.getInventory().getItemByItemId(HopZonereward1Id);
					if (item1 == null || item1.getCount() < HopZonemaxRewardStack)
					{
						player.addItem("reward", HopZonereward1Id, HopZonereward1Count, player, true);
					}
					L2ItemInstance item2 = player.getInventory().getItemByItemId(HopZonereward2Id);
					if (item2 == null || item2.getCount() < HopZonemaxRewardStack)
					{
						player.addItem("reward", HopZonereward2Id, HopZonereward2Count, player, true);
					}

				}
			}	
			setLastHopzoneVoteCount(getLastHopzoneVoteCount() + HopZonevotesForReward);
		}
		Announcements.getInstance().announceToAll("Lineage 2 Senior  current hopzone votes: " + hopZone + ".");
		Announcements.getInstance().announceToAll("Next reward will be given at: " + (getLastHopzoneVoteCount() + HopZonevotesForReward) + " votes.");
		if (getLastHopzoneVoteCount() == 0)
		{
			setLastHopzoneVoteCount(hopZone);
		}
	}
}
private int getHopZoneVotes()
{
	URL url = null;
	InputStreamReader isr = null;
	BufferedReader in = null;
	try
	{
		url = new URL(HOPZONE);
		URLConnection con = url.openConnection();
		con.addRequestProperty("User-Agent", "Mozilla/4.76"); 
		isr = new InputStreamReader(con.getInputStream());
		in = new BufferedReader(isr);
		String inputLine;
		int voteCount = 0;
		while ((inputLine = in.readLine()) != null)
		{
			if (inputLine.contains("moreinfo_total_rank_text"))
			{
				voteCount = Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
				break;
			}
		}
		return voteCount;
	}
	catch (IOException e)
	{
		e.printStackTrace();
		return 0;
	}
	finally
	{
		try
		{
			in.close();
		}
		catch (IOException e)
		{}
		try
		{
			isr.close();
		}
		catch (IOException e)
		{}
	}
}



private void setLastHopzoneVoteCount(int voteCount)
{
	HopZonelastVoteCount = voteCount;
}

private int getLastHopzoneVoteCount()
{
	return HopZonelastVoteCount;
}



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

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

2 answers to this question

Recommended Posts

  • 0
Posted

Here you go :D

 

/*
* This is a script completely developed by Rain^ (?)
* You are not allowed to sell any copies of it.
* Since 2.0 (by Zoey76 for L2J Forums):
* Added logger instead of System.out.println()
* Moved to Datapack.
* Reworked AutoReward class.
* Reworked getVotes() method.
* Time is in minutes instead of milliseconds.
* Uses different a-beep-t for each item.
* Only rewards online players, not offline shops.
* Rewarded players count.
*/
package custom.VoteEngine;

import java.io.*;
import java.net.*;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

/**
* @author Zoey76
* @version 2.0
*/
public class AutoVoteRewardHandler
{
protected static final Logger _log = Logger.getLogger(AutoVoteRewardHandler.class.getName());
//URL from your server site at HopZone.net
//Example: [url=http://l2.hopzone.net/lineage2/moreinfo/YourServer/ID.html]http://l2.hopzone.net/lineage2/moreinfo/YourServer/ID.html[/url]
private final static String _url = "http://l2.hopzone.net/lineage2/moreinfo/L2WorldPvP/74078.html";//Add your URL from HopZone here!
//Reward all online players each '_votesRequiredForReward' votes.
private final int _votesRequiredForReward = 1;//
//Initial check, time in minutes:
//Default: 1 minute
private final int initialCheck = 1;
//Delay interval, time in minutes (do not set it too low):
//Default: 10 minutes
private final int delayForCheck = 1;

//Item Id, A-beep-t.
private final static int[][] ITEMs =
{
	{ 5575, 10 }, //10 Event - Apiga(s)
	{ 57, 1000000 }, //1 million Adena
};

//Do not change
private int _lastVoteCount = 0;

private AutoVoteRewardHandler()
{
	_log.info("[AutoVoteRewardHandler]: Vote Reward System Initiated.");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck * 60000, delayForCheck * 60000);
}

private class AutoReward implements Runnable
{
	public void run()
	{
		int votes = getVotes();
		int rewardedPlayers = 0;
		if (votes > -1)
		{
			if  ((getLastVoteCount() != 0) && (votes >= (getLastVoteCount() + _votesRequiredForReward)))
			{
				Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
				for (L2PcInstance player : pls)
				{
					if ((player != null) && !player.getClient().isDetached())
					{
						for (int[] reward : ITEMs)
						{
							if (player.getInventory().validateCapacityByItemId(reward[0]))
							{
								player.addItem("reward", reward[0], reward[1], player, true);
							}
						}
						rewardedPlayers++;
					}
				}
				setLastVoteCount(getLastVoteCount() + _votesRequiredForReward);
			}
			else if (getLastVoteCount() == 0)
			{
				setLastVoteCount(votes);
			}
			_log.info("[AutoVoteRewardHandler]: Server Votes: " + votes + ", Rewarded players: " + rewardedPlayers);
			Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");
		}
		else
		{
			_log.log(Level.WARNING, "[AutoVoteRewardHandler]: Error retreiving server votes count!");
		}
	}
}

private static int getVotes()
{
       		InputStreamReader isr = null;
	BufferedReader in = null;
	int votes = -1;
	try
	{
	URLConnection conn = new URL(_url).openConnection();
	conn.addRequestProperty("User-Agent", "Mozilla/4.76");
	isr = new InputStreamReader(conn.getInputStream());
         	in = new BufferedReader(isr);
		String inputLine;
		while (((inputLine = in.readLine()) != null) && (votes == -1))
		{
			if (inputLine.contains("Anonymous User Votes"))
			{
				try
				{
					votes = Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
				}
				catch (Exception e)
				{
				}
			}
		}
		in.close();
	}
	catch (Exception e)
	{
		_log.log(Level.WARNING, "[AutoVoteRewardHandler]: " + e.getMessage(), e);
	}
	return votes;
}

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();
}

public static void main(String[] args)
{
	//System.out.println("Server votes: " + getVotes());//Just a test.
	AutoVoteRewardHandler.getInstance();
}
}

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

    • Hello everyone, Lineage II clan MightyTeam is reopening recruitment and looking for ambitious, active players who want to compete seriously and grow together. We are building a disciplined and organized environment focused on teamwork, strategy, and long-term success. What we offer: Strong and experienced leadership, Fair and respectful treatment for every member, Organized clan structure and tactical gameplay, Competitive mentality with clear goals, Stable and drama-free environment, What we expect: Activity and willingness to improve, Teamplay and communication, Respect toward clan members, Motivation to compete and dominate, No politics. No toxicity. Only focused players with the right mentality.   If you are interested in joining MightyTeam, contact on Discord: tzelal.  <-- there is a dot  or Telegram tz3gg. 
    • Lol thanks no l better get Acis /Lucera/Mobius and will squeeze more profit that your crazy ass price files for fucks know what. Even Reborn was smart enough use Acis after Lucera to squeeze shit a lot of money 😁 Fucking hell 15 grants lol 😂 
    • It seems the SkyLord is simply not familiar with what l2-scripts and Bonux represents today. His opinion is likely based on our older materials — which is understandable. We haven't been standing still. Over the years, the studio has moved to a fundamentally different level of development. Our early builds are still available on the legacy site at very accessible prices — and they remain entirely viable for launching a project. As practice shows, solid servers can still be built on them, albeit with greater effort. As for the market — Classic, Essence, and Main have long been running on l2-scripts engines, and the majority of successful servers have, at one stage or another, used our source code as their foundation. This isn't self-promotion — it's the history of the industry. Today, for established projects with a reputation, we offer a different format: private partnership with individual terms tailored to your business goals. If you're interested in long-term collaboration — we're open to the conversation. We have solutions for every level — from newcomers to top-tier projects. Feel free to reach out, and we'll be happy to discuss.
  • 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..