Jump to content

[Share-Gift] HopZone Vote Reward [IT]


extr3me

Recommended Posts

  • 4 months later...
  • 4 weeks later...

Thanks

stop mother-beep-er saying "thanks" to something that DO NOT WORKS! :)

 

 

 

and here is the fix (copy paste it) make sure u will take a backup <3

/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

package net.sf.l2j.gameserver.model;

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

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

/**
*
* @author eXtr3me, mod by Rizel and ErHarD
*
*/
public class AutoVoteRewardHandler
{
private int	lastVoteCount = 0;
private int	initialCheck = 30 * 1000;														
private int	delayForCheck = 300 * 1000;														
private int	votesForReward = 20;
private int	maxRewardStack = 5;

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

private class AutoReward implements Runnable
{
	public void run()
	{
		System.out.println("Vote Count Check.");
		if (Config.VOTE_REWARD1_ID == 0 || Config.VOTE_REWARD1_COUNT == 0 || Config.VOTE_REWARD2_ID == 0 || Config.VOTE_REWARD2_COUNT == 0)
		{
			GmListTable.broadcastMessageToGMs("The rewards aren't Identified. Please take a look.");
			return;
		}
		int newVoteCount = getVotes(Config.VOTE_HTML_PATCH);
		System.out.println("newVoteCount:"+newVoteCount);
		System.out.println("getLastVoteCount:"+getLastVoteCount());
		if (newVoteCount != 0 && getLastVoteCount() != 0 && newVoteCount >= getLastVoteCount() + votesForReward)
		{

			Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
			for (L2PcInstance player : pls)
			{
				if (player != null)
				{
					L2ItemInstance item1 = player.getInventory().getItemByItemId(Config.VOTE_REWARD1_ID);
					if (item1 == null || item1.getCount() < maxRewardStack)
					{
						player.addItem("reward", Config.VOTE_REWARD1_ID, Config.VOTE_REWARD1_COUNT, player, true);
					}
					L2ItemInstance item2 = player.getInventory().getItemByItemId(Config.VOTE_REWARD2_ID);
					if (item2 == null || item2.getCount() < maxRewardStack)
					{
						player.addItem("reward", Config.VOTE_REWARD2_ID, Config.VOTE_REWARD2_COUNT, player, true);
					}
				}
			}	
			setLastVoteCount(getLastVoteCount()+ votesForReward);
		}
		Announcements.getInstance().announceToAll("Our Current vote count is: " + newVoteCount);
		Announcements.getInstance().announceToAll("Next reward at " + (getLastVoteCount()+ votesForReward) + " votes.");
		if (getLastVoteCount() == 0)
		{
			setLastVoteCount(newVoteCount);
		}
	}
}

private int getVotes(String urlString)
{
	InputStreamReader isr = null;
	BufferedReader in = null;
	try
	{
		URL url = new URL(urlString);
		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("rank anonymous tooltip"))
			{
				int Sub = 12;
				switch (inputLine.length())
				{
					case 116:
						Sub = 13; 
						break;
					case 117:
						Sub = 14; 
						break;
					case 118:
						Sub = 15;
						break;
					case 119:
						Sub = 16; 
						break;
				}
				voteCount = Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
				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 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();
}
}

Link to comment
Share on other sites

  • 2 months later...

stop mother-beep-er saying "thanks" to something that DO NOT WORKS! :)

 

 

 

and here is the fix (copy paste it) make sure u will take a backup <3

/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

package net.sf.l2j.gameserver.model;

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

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

/**
*
* @author eXtr3me, mod by Rizel and ErHarD
*
*/
public class AutoVoteRewardHandler
{
private int	lastVoteCount = 0;
private int	initialCheck = 30 * 1000;														
private int	delayForCheck = 300 * 1000;														
private int	votesForReward = 20;
private int	maxRewardStack = 5;

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

private class AutoReward implements Runnable
{
	public void run()
	{
		System.out.println("Vote Count Check.");
		if (Config.VOTE_REWARD1_ID == 0 || Config.VOTE_REWARD1_COUNT == 0 || Config.VOTE_REWARD2_ID == 0 || Config.VOTE_REWARD2_COUNT == 0)
		{
			GmListTable.broadcastMessageToGMs("The rewards aren't Identified. Please take a look.");
			return;
		}
		int newVoteCount = getVotes(Config.VOTE_HTML_PATCH);
		System.out.println("newVoteCount:"+newVoteCount);
		System.out.println("getLastVoteCount:"+getLastVoteCount());
		if (newVoteCount != 0 && getLastVoteCount() != 0 && newVoteCount >= getLastVoteCount() + votesForReward)
		{

			Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
			for (L2PcInstance player : pls)
			{
				if (player != null)
				{
					L2ItemInstance item1 = player.getInventory().getItemByItemId(Config.VOTE_REWARD1_ID);
					if (item1 == null || item1.getCount() < maxRewardStack)
					{
						player.addItem("reward", Config.VOTE_REWARD1_ID, Config.VOTE_REWARD1_COUNT, player, true);
					}
					L2ItemInstance item2 = player.getInventory().getItemByItemId(Config.VOTE_REWARD2_ID);
					if (item2 == null || item2.getCount() < maxRewardStack)
					{
						player.addItem("reward", Config.VOTE_REWARD2_ID, Config.VOTE_REWARD2_COUNT, player, true);
					}
				}
			}	
			setLastVoteCount(getLastVoteCount()+ votesForReward);
		}
		Announcements.getInstance().announceToAll("Our Current vote count is: " + newVoteCount);
		Announcements.getInstance().announceToAll("Next reward at " + (getLastVoteCount()+ votesForReward) + " votes.");
		if (getLastVoteCount() == 0)
		{
			setLastVoteCount(newVoteCount);
		}
	}
}

private int getVotes(String urlString)
{
	InputStreamReader isr = null;
	BufferedReader in = null;
	try
	{
		URL url = new URL(urlString);
		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("rank anonymous tooltip"))
			{
				int Sub = 12;
				switch (inputLine.length())
				{
					case 116:
						Sub = 13; 
						break;
					case 117:
						Sub = 14; 
						break;
					case 118:
						Sub = 15;
						break;
					case 119:
						Sub = 16; 
						break;
				}
				voteCount = Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
				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 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();
}
}

 

Is this the "Official Fix ?" or is it this same code, fixed?

Working nowaways?

Any idea if it may work on L2jServer G3 ? (ct2.3)

Tnx.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • I guess if you want to learn the whole process, your best bet is to start with a classic client (like salvation? also must be easy to modify so that you don't get stuck behind paywalls) and check how the network communication is implemented. L2jmobius has a lot of sources that use classic clients.
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hoodservices https://campsite.bio/utchihaamkt  
    • WTS Gold bars reborn interlude x10   discord : xeenthekeen
    • Guys, if you'd let me be the bearer of bad news, No amount of "break from server development" can justify your complete lack of idea how things work. If it was this easy, you should've been seeing 90% of the servers of the popular old versions, such as IL and HF, running on the newest client. For this task, you would need a lot of time - think at least 2 months, if you can code, have access to all the necessary tools for client development, and you have a relatively good idea of how server<->client communication works. f you don't, then you either find yourself a well-paying job and find someone who would do it for you or you put the idea aside (for no less than 1-2 years) and start reading and learning asap. Let me give you a little preview/breakdown of what some of the work includes. The work can be split into two parts - SERVER side and CLIENT side.  The server and the client communicate through packets. Each of these packets has a defined structure. Both, the server and the client MUST know this structure and MUST use the same structure, otherwise they won't be able to "understand" each other. - The server side predominantly includes the alteration of existing packet structure and the creation (from zero) of missing packets that the client requires. Then you also have to take these changes into account and alter the existing features of your server to match the changes. A good example for this is SKILL ENCHANTING. On older chronicles, the enchant level is determined by the LEVEL value of the skill and on the new clients, it has been taken out into a separate value. What this means is that you would have to figure out a way to adapt the old system to the new requirements. - Now that we mentioned the client, you would also need to edit a bunch of files, such as Interface, UTX, UNR, as well as DAT files, including those related to ITEMS, SKILLS, QUESTS, NPCS, and AUGMENTATION STATS and DESCRIPTIONS, etc. For some of those, you would also have to figure out how to check for missing entries and how to parse data from the older client to the new. The best example, again, would be the SKILLS. On the latest clients, the skill enchanting was limited to only +20. As such, even if there were some matching skills between the two different client versions, you would still need to add the missing 10 levels to +30. And once you complete all of that, you start testing and fixing bugs and sh1t. And once you have fixed all of that, you can start adding new features from the new client, because otherwise it would be one big mess and a waste of time and/or money.
  • Topics

×
×
  • Create New...