Jump to content

Recommended Posts

Posted

As l2topzone.com updated it's source and hopzone's vote reward does not work for topzone too here is a vote reward,

 

 package net.sf.l2j.gameserver.model;

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

import javolution.util.FastList;

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;
import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;


public class TopzoneVoteRewardHandler
{
private int	lastVoteCount = 0;
private int	initialCheck = 60 * 1000;														
private int	delayForCheck = 300 * 1000;														
private int	votesForReward = 5;
private int	maxRewardStack = 500;

@SuppressWarnings("synthetic-access")
private TopzoneVoteRewardHandler()
{
	System.out.println("Topzone Vote Reward System activated.");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
}

private class AutoReward implements Runnable
{
	public void run()
	{
		System.out.println("Topzone Vote Count Check.");
		if (Config.TOPZONE_VOTE_REWARD1_ID == 0 || Config.TOPZONE_VOTE_REWARD1_COUNT == 0)
		{
			GmListTable.broadcastMessageToGMs("The rewards aren't Identified. Please take a look.");
			return;
		}
		int newVoteCount = getVotes(Config.TOPZONE_VOTE_HTML_PATCH);
		System.out.println("newVoteCount:"+newVoteCount);
		System.out.println("getLastVoteCount:"+getLastVoteCount());
		if (newVoteCount != 0 && getLastVoteCount() != 0 && newVoteCount >= getLastVoteCount() + votesForReward)
		{
			FastList<InetAddress> ip = new FastList<InetAddress>();
			Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
			for (L2PcInstance player : pls)
			{
				if (player != null)
				{
					L2ItemInstance item1 = player.getInventory().getItemByItemId(Config.TOPZONE_VOTE_REWARD1_ID);
					if (item1 == null || item1.getCount() < maxRewardStack)
					{
						InetAddress ipc = player.getClient().getConnection().getSocketChannel().socket().getInetAddress();

						if(ip.contains(ipc))
							continue;

						ip.add(ipc);
						player.addItem("reward", Config.TOPZONE_VOTE_REWARD1_ID, Config.TOPZONE_VOTE_REWARD1_COUNT, player, true);
						player.sendMessage("Keep Voting For Us.Rewards given.");
					}
				}
			}	
			setLastVoteCount(getLastVoteCount()+ votesForReward);
		}

		Announcements.getInstance().announceToAll("L2Godrich TopZone : " + newVoteCount + " Votes.");
		Announcements.getInstance().announceToAll("Next reward will be on : " + (getLastVoteCount()+ votesForReward) + " Votes.");
		Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

		if (getLastVoteCount() == 0)
		{
			setLastVoteCount(newVoteCount);
		}
	}
}

static int getVotes(String urlString)
{
	String htmlText = "";
	boolean startAdd = false;
	int voteCount = 0;
	boolean ok = false;
	try
	{
		URL pageToDisplay;
		pageToDisplay = new URL(urlString);
		URLConnection conn = pageToDisplay.openConnection();
		conn.connect();				
		InputStream in = conn.getInputStream();
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		htmlText = "";
		while(!ok)
		{
			String newLine = br.readLine();
			if (newLine == null)
			{
				ok = true;
			}
			else 
			{
				if (htmlText.length() < 110000)
				{
					if (!startAdd && newLine.indexOf(">Votes<") > 0) 
						startAdd = true;
					if (startAdd && newLine.indexOf(">Uptime<") > 0) 
						startAdd = false;
					if (startAdd) 
						htmlText = htmlText+newLine;
					if (htmlText.length() > 10 && !startAdd) 
						ok = true;					     
				}
			}
		}
		br.close();
	}
	catch (MalformedURLException mfe)
	{
	} 
	catch (IOException e)
	{ 
	}
	htmlText = htmlText.substring(htmlText.indexOf("font-size")+ 31);
	htmlText = htmlText.substring(0,htmlText.indexOf("</font>"));
	try
	{
		voteCount = Integer.parseInt(htmlText);
	}
	catch (NumberFormatException a)
	{
		voteCount = 0;
	}
        return voteCount;
}

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

private int getLastVoteCount()
{
	return lastVoteCount;
}

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

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

 

Config.java

public static boolean TOPZONE_VOTE_ENABLE;
public static String TOPZONE_VOTE_HTML_PATCH;
public static int TOPZONE_VOTE_REWARD1_ID;
public static int TOPZONE_VOTE_REWARD2_ID;
public static int TOPZONE_VOTE_REWARD1_COUNT;
public static int TOPZONE_VOTE_REWARD2_COUNT;




TOPZONE_VOTE_ENABLE = Boolean.parseBoolean(Customs.getProperty("TopzoneVoteEnable", "False"));
    			PROTECTED_GAMESERVER = Boolean.parseBoolean(Customs.getProperty("ProtectGameServerWithPassword", "False"));
                TOPZONE_VOTE_HTML_PATCH = Customs.getProperty("TopzoneVoteHtmlPatch", "Null");
			TOPZONE_VOTE_REWARD1_COUNT = Integer.parseInt(Customs.getProperty("TopzoneVoteReward1Count", "1000"));
			TOPZONE_VOTE_REWARD2_COUNT = Integer.parseInt(Customs.getProperty("TopzoneVoteReward2Count", "1000"));
			TOPZONE_VOTE_REWARD1_ID = Integer.parseInt(Customs.getProperty("TopzoneVoteReward1Id", "57"));
			TOPZONE_VOTE_REWARD2_ID = Integer.parseInt(Customs.getProperty("TopzoneVoteReward2Id", "57"));
    			

Do not forget to register this on gameserver.

 

Credits: me

 

PS: it's tested.

  • 2 months later...
  • 2 months later...

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

    • We are excited to announce the open beta testing of the Fulgrim x4 server, starting November 29th, 2024, at 19:00 server time (19:00 по МСК). There will be an NPC available on the test server from whom you can purchase items, gain levels, professions, and other services.   More information at our >Forum
    • Server mid rate craft PvP   CLIENTE INTERLUDE Website server Discord olympus x25 &nbsp;server 🇧🇷🇦🇷🇨🇱🇬🇷🇲🇽🇵🇪🇸🇰🇪🇸🇺🇾 Server mid rate craft PvP 🔱CLIENTE INTERLUDE🔱 🔅xpx25 🔅Sp x25 🔅Adena x15 🔅Droop x2 🔅Spoil x2 🔅Raidboss xp x2 🔅Raidboss sp x2 🔅Raidboss droop x1 🔅All Rate quest reward  x1 ⚠️All Quest drop reward. x1 🔅Manor x 3 🔅Seal stone x1 🛡️🗡️INFO GRADO S🗡️🛡️ ⚠️Inicia desabilitado drop/spoil/quest. 🔱PROFESIONES/SUBCLASS🔱 🛡️1st profession - 50medal 🛡️2nd profession - 500 medal 🛡️3rd profession - 1k medal +30kk adena 🛡️Sub class - Quest. No necesita matar raids. ⚙️Configuraciones⚙️ 🛡️Gmshop  grade - B. 🛡️Grade A-S Craft - yes x1 chance 🛡️Globlal teleport - yes 🛡️Buffer 1hora. 🛡️Buffer slot 24(+4divine)+12 dances-song 🛡️Auto learn skils - yes 🛡️Autoloot - yes 🛡️Mana potion recarga 1000 ,9segundos delay. 🛡️Champions system:     ▫️lvl 30 - 76     ▫️chance respawn 0.5%.     ▫️adena x20 🛡️Max lvl party 14 lvl. 🛡️Festive sweeper on. 🛡️Max client pc 2. 🛡️Raid boss respawn retail. 🛡️Nobleza quest - yes. 🛡️Barakiel respawn 6 horas + -30 min. 🛡️Olimpiada duracion 14 dias. 🛡️Olimpiada de 18:00 a 00:00 🛡️Safe enchant +3 🛡️Normal enchant scroll 50% ⚠️+11-16 chance 30% 🛡️Bleesed enchant scroll 55% ⚠️+11-16 chance 35% 🛡️Rate dinamico x1 lvl 77-80   🛡️🗡️CLANES INFO🗡️🛡️ 🔅Crear clan min. level 20 🔅Max Alianzas 1 🔅Duracion penalidades clan / alianzas 8 horas. 🔅Cambio de lider 24 horas. 🛡️⚔️ ASEDIOS ⚔️🛡️ 🔅Cada 2 semanas. 🔅Proteccion hwid 1 pc. 🔅Clanes registrados. acceden a zona de asedio. 🔅Castillo asediable Aden. 🔅Reward 1000 FA 🔅Horario 16:00 GMT-3 🎊PACK DE INICIO🎊 🔅Start set - armor\weapon no grade. 🔅Level 20  - 5 shadow cuppon grado D 🔅Level 40 - 5 shadow cuppon grado C 🔅Free Autofarm 24 horas. 💰 INFO PREMIUM 💰 🔅Free autofarm. 🔅xp x30 🔅sp x30 🔅adena x17 🔅drop x4 🔅spoil x4 🔅enchant +2% 🔅seal stone x1 🔅Altb Gk-Gmshop/buffe ⚔️ RAID  BOSS INFO ⚔️ 🔅Raid boss 70 ++ respawn 5 días despues. 🔅Raid boss 75 ++ respawn 15 días despues 🔅Drop LETTER L2DAY para tradear en GMshop. ⚔️ INFO SEVEN SING ⚔️ 🔅Inicio del drop Seal stones dia 5 de iniciado el server. 🎊 EPIC RAID INFO 🎊 🔅Queen Ant (lvl 40)respawn Lunes a Viernes 22:00 GMT-3 drop chance 30%. 🔅Core (lvl 80)respawn Martes-miercoles 20:20 GMT-3 drop chance 100%. 🔅Orfen (lvl 80)respawn Martes-miercoles 21:00 GMT-3 drop chance 100%. 🔅Zaken (lvl 80)respawn Jueves 23:00 GMT-3 drop chance 100%. 🔅Frintezza (lvl 80)respawn Viernes 23:00 GMT-3 drop chance 100%. 🔅Baium (lvl 80)respawn Sabado 22:00 GMT-3 drop chance 100%. 🔅Valakas (lvl 80)respawn Domingo 20:00 GMT-3 drop chance 100%. 🔅Antharas (lvl 80)respawn Domingo 22:00 GMT-3 drop chance 100%.
  • Topics

×
×
  • Create New...