Jump to content

Recommended Posts

  • 2 weeks later...
Posted

/*
* 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.
*
* Since 3.0 (by KsrZ for L2JServer):
* Multi-Reward same time, if needed ((votes - getLastVoteCount() / _votesRequiredForReward) * ITEMs)
* log player name's
* 1 reward per ip
* 
*/
package custom.VoteEngine;

import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

/**
* @author KsrZ
* @version 3.0
*/
public class AutoVoteRewardHandler
{
protected static final Logger _log = Logger.getLogger(AutoVoteRewardHandler.class.getName());

//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
// Settings

private final static String _url = "http://l2.hopzone.net/lineage2/details/91037/L2-Orbis";//Add your URL from HopZone here!
private final int _votesRequiredForReward = 1; //Votes Requiered for next check

//Initial check
private final int initialCheck = 1; //initial Time to check

//Delay interval:
private final int delayForCheck = 15; //Delay for next check

//Reward:
//{ItemID, COUNT},
private final static int[][] ITEMs =
	{
		{ 4033, 1 }, // Blue Paper
		{ 57, 300000 }, // Adena
	};

//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
//System --> Don't touch anything from here.

private int _lastVoteCount = 0;
private List<String> already_rewarded;

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

private class AutoReward implements Runnable
{
	public void run()
	{
		String Player_Rewared = null;
		int votes = getVotes();
		int rewardedPlayers = 0;
		int VGV = (votes - getLastVoteCount()) / _votesRequiredForReward;
		if (votes > -1)
		{
			if  ((getLastVoteCount() != 0) && (votes >= (getLastVoteCount() + _votesRequiredForReward)))
			{

				already_rewarded = new ArrayList<String>();
				L2PcInstance[] pls = L2World.getInstance().getAllPlayers().getValues(new L2PcInstance[0]);

				for (L2PcInstance player : pls)
				{
					if ((player != null) && !player.getClient().isDetached())
					{

						for (int[] reward : ITEMs)
						{
							if(checkSingleBox(player))
							{
								if (player.getInventory().validateCapacityByItemId(reward[0]))
								{

									player.addItem("reward", reward[0], reward[1]*VGV, player, true);

									if(Player_Rewared == null)
										Player_Rewared = " " + player.getName();
									else if(Player_Rewared != null && !Player_Rewared.contains(player.getName()))
									Player_Rewared = Player_Rewared + " | " + player.getName();
								}
							}
						}
						rewardedPlayers++;

					}
				}
				setLastVoteCount((int)(votes - ((votes - getLastVoteCount()) - (VGV * _votesRequiredForReward))));
			}
			else if (getLastVoteCount() == 0 || votes < getLastVoteCount())
			{
				setLastVoteCount(votes);
			}

			if (VGV == votes / _votesRequiredForReward && Player_Rewared == null) 
			{
				VGV= 0;
				Player_Rewared = " ";
			}
			else if (Player_Rewared == null)
				Player_Rewared = " ";

			_log.info("   >------------------> Vote Reward Edited By KsrZ >---------------------------->");
			_log.info("   >| Server Votes: " + votes );
			_log.info("   >| Checking votes evry " + delayForCheck + " minutes.");
			_log.info("   >| " + rewardedPlayers + " rewarded, players: ");
			_log.info("     (" + Player_Rewared + ")");
			_log.info("   >| Reward X" + VGV + " times.");
			_log.info("   <----------------------------------------------------------------------------<");
			Announcements.getInstance().announceToAll("[HopZone Votes]: " + votes + ".");
			Announcements.getInstance().announceToAll("[HopZone]: Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");
		}
		else
		{
			_log.log(Level.WARNING, "[Auto Vote Reward]: 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, "[Auto Vote Reward]: " + e.getMessage(), e);
	}
	return votes;
}

private boolean checkSingleBox(L2PcInstance player){
                
                if(player.getClient()!=null && player.getClient().getConnection()!=null && !player.getClient().getConnection().isClosed()){
                        
                        String playerip = player.getClient().getConnection().getInetAddress().getHostAddress();
                        
                        if(already_rewarded.contains(playerip))
                                return false;
                        already_rewarded.add(playerip);
                        return true;
                }
                
                return false;
    }


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)
{
	AutoVoteRewardHandler.getInstance();
}
}

File from MediaFire: http://www.mediafire.com/?k2o1k7xtiqqyz3z

 

So I Just Download this .java, put it on instance manager and all done?

OR do i have to add lines on some other files? (as l2world.java or some other?)

 

please i need to get this code working for my serv.

Greets.

 

IanN

Posted

i mean do I have to "call it" or "import" it somewhere else? Looks weird to me that JUST 1 .java added, and no codes to edit :/ maybe cuz im new...but tbh, i dont get how u make this work....maybe some tutoring?

 

 

Greets.

IanN

  • 3 months later...
Posted

i mean do I have to "call it" or "import" it somewhere else? Looks weird to me that JUST 1 .java added, and no codes to edit :/ maybe cuz im new...but tbh, i dont get how u make this work....maybe some tutoring?

 

Greets.

IanN

 

You will have to register a gameserver code witch is

AutoVoteRewardHandler.getInstance() so the gameserver will read it when you lunch your server.

to import, you need to create a new file call it AutoVoteRewardHandler.java under

gameserver.handlers

good luck

  • 4 weeks later...
Posted

how to implant it for acis?...pls full discribtion

Create folder AutoVoteRewardHandler and file AutoVoteRewardHandler.java and paste this inside (data\scripts\custom directory). And then in data find scripts.cfg, find #custom and paste there custom/AutoVoteRewardHandler/AutoVoteRewardHandler.java

 

PS: It's the same vote rew, but w/o any changes, ready to use at aCis if I remember well ;)

Posted

damn got an error. it doesn't work?

 

error.png

 

Error on: D:\Lineage2 Server\SERVER acis\gameserver\data\scripts\custom\AutoVoteRewardHandler\AutoVoteRewardHandler.java.error.log

Line: -1 - Column: -1

 

java.lang.ClassNotFoundException: custom.AutoVoteRewardHandler.AutoVoteRewardHandler

 

 

Posted

damn got an error. it doesn't work?

 

It does. Just change this line

 

Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");

 

to

 

Announcements.getInstance();
Announcements.announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");

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

    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market
    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market
    • 📈 X (Twitter) — Promotion for all purposes  🚀 Boost reach, likes, views, and retweets with the best rates on the market!   🧠 Available services:  🔹 Likes, retweets, comments  🔹 Tweet and video views  🔹 Mentions and polls  🔹 Followers   💼 Perfect for:  ✔️ SMM specialists  ✔️ Arbitrage experts  ✔️ Crypto, NFT, and news account owners  ✔️ Agencies promoting businesses and personal brands ...and much more! Use our SMM Panel to boost on Facebook, Instagram, Telegram, Spotify, Soundcloud, YouTube, Reddit, Threads, Kick, Discord, LinkedIn, Likee, VK, Twitch, Kwai, Reddit, website traffic, TikTok, TrustPilot, Apple Music, Tripadvisor, Snapchat, and other digital products.   🎁 Promo code: XBOOST5 (5% discount)   🎁 Get $1 trial bonus:  Simply open a ticket titled “Get Trial Bonus” on our website (Support)  ➡ Go to SMM Panel (clickable)  Or contact support via bot 🎁   How to order:  ➡ SMM Panel: Click ✅  ➡ SMM Panel directly inside our Telegram bot: Click ✅ (Menu ➡ SMM Panel)   Our Digital Goods Store:  ➡ Online Store: Click ✅  ➡ Telegram Bot: Click ✅    Regular customers get extra discounts and promo codes!   Support:  ➡ Telegram: https://t.me/solomon_bog ✅  ➡ Discord: https://discord.gg/y9AStFFsrh ✅  ➡ WhatsApp: https://wa.me/79051904467 ✅  ➡ ✉ Email: solomonbog@socnet.store ✅   ➡ Telegram Channel: https://t.me/accsforyou_shop ✅   Use these contacts to:  — Discuss wholesale purchases  — Propose partnerships (current partners: https://socnet.bgng.io/partners )   — Become a supplier 🧩 SocNet — Digital Goods & Premium Subscriptions Store ✅
    • Want Telegram Premium at the best prices and with zero hassle? You’ve come to the right place! Premium subscriptions from 1 to 12 months — with or without account authorization. Full guarantee for the entire subscription period. Promo code: TGJULY (10% discount) Payment methods: bank cards · cryptocurrency · other popular options How to buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other services: ➡ SMM Panel: Click Available options: ➡ Telegram Premium subscription for 1 month to your account | Authorization in your account is required (via TDATA or phone number) | Price from: $6 ➡ Telegram Premium subscription for 3 months on your account | No authorization required | Full guarantee for the entire period | Price from: $19 ➡ Telegram Premium subscription for 6 months on your account | No authorization required | Full guarantee for the entire period | Price from: $23 ➡ Telegram Premium subscription for 12 months on your account | No authorization required | Full guarantee for the entire period | Price from: $37 Regular customers receive extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ ✉ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — Discuss wholesale orders — Propose partnerships (current partners: https://socnet.bgng.io/partners ) — Become a supplier SocNet — Digital Goods & Premium Subscriptions Store
    • Want Telegram Premium at the best prices and with zero hassle? You’ve come to the right place! Premium subscriptions from 1 to 12 months — with or without account authorization. Full guarantee for the entire subscription period. Promo code: TGJULY (10% discount) Payment methods: bank cards · cryptocurrency · other popular options How to buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other services: ➡ SMM Panel: Click Available options: ➡ Telegram Premium subscription for 1 month to your account | Authorization in your account is required (via TDATA or phone number) | Price from: $6 ➡ Telegram Premium subscription for 3 months on your account | No authorization required | Full guarantee for the entire period | Price from: $19 ➡ Telegram Premium subscription for 6 months on your account | No authorization required | Full guarantee for the entire period | Price from: $23 ➡ Telegram Premium subscription for 12 months on your account | No authorization required | Full guarantee for the entire period | Price from: $37 Regular customers receive extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ ✉ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — Discuss wholesale orders — Propose partnerships (current partners: https://socnet.bgng.io/partners ) — Become a supplier SocNet — Digital Goods & Premium Subscriptions Store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock