/*
* 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.Collection;
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;
import com.l2jserver.gameserver.util.L2TIntObjectHashMap;
/**
* @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/93778/L2-Quittance";//Add your URL from HopZone here!
private final int _votesRequiredForReward = 10; //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 =
{
{ 9143, 1 }, // Blue Paper
{ 9627, 10 }, // 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();
}
}
and here is my error :
1. ERROR in \AutoVoteRewardHandler.java (at line 97)
L2PcInstance[] pls = L2World.getInstance().getAllPlayers().getValues(new
L2PcInstance[0]);
^^^^^^^^^
The method getValues(L2PcInstance[]) is undefined for the type L2TIntObjectHashM
ap<L2PcInstance>
----------
1 problem (1 error)The method getValues(com.l2jserver.gameserver.model.actor.ins
tance.L2PcInstance[]) is undefined for the type com.l2jserver.gameserver.util.L2
TIntObjectHashMap<com.l2jserver.gameserver.model.actor.instance.L2PcInstance>
Failed executing script: D:\High Five Server Project X\Stable\game\data\scripts\
custom\VoteEngine\AutoVoteRewardHandler.java. See AutoVoteRewardHandler.java.err
or.log for details.
just with this extender that I have shared it is not possible to start with c4 client, you have to make some changes to the extender and it works with c4 client perfectly.
regarding the updates in this last revision
🔹dll is not packaged with vmprotect
New custom zone types have been added:
🔹 NO_NOBLESS
begin MinX=84638 MaxX=92616 MinY=-87170 MaxY=-82018 MinZ=-6000 MaxZ=0 Type=NO_NOBLESS KickOutPos=83007/148057/-3464 end
▶️ This zone checks if the character is noble.
If it does not meet the condition, it will be automatically kicked to the indicated position (KickOutPos).
🔹 CUSTOM_SPAWN_ZONE
begin MinX=77275 MaxX=85704 MinY=10122 MaxY=18066 MinZ=-8000 MaxZ=5000 Type=CUSTOM_SPAWN_ZONE OutPos=83007/148057/-3464 Spawns={{82984/18066/-5256}};{{79275/15147/-5248}};{{82922/14263/-5256}};{{83704/10122/-5288}} end
▶️ This zone allows characters, upon death, to respawn with full buff, CP, HP and MP if they press “Fixed”.
They will only be able to revive in one of the positions defined in Spawns.
🔧 Both zones are fully configurable from territorydata.txt
🔧 Development Repository (SVN)
GX-EXT supports open, collaborative, and professional development. That’s why we provide access to our public SVN repository where you can:
✅ Compile your own version of the project
✅ Optimize and extend its features
✅ Learn from real production-quality source code
🔒 Delayed access: The repository is always 2 months behind the latest commercial release to prevent unauthorized reselling.
🔗 SVN URL: https://svn.l2servers.com.ar/!/#GX-EXT_INTERLUDE
Username: gx
Password: gx
You can use tools like TortoiseSVN to download and work with the code.
Could you tell me what changed in this update?
more one question:
Is it possible to log in through the c4 client instead of interlude? That would be great
Question
sirzufall
I am using the latest L2jServer unstable Pack.
Pls help me .. thx.
Here is my code :
and here is my error :
3 answers to this question
Recommended Posts