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.
Hello. You may encounter the Push item fail error when trying to pick up an item dropped on the ground by a mob.
or
You can throw something out of your inventory and pick it up again, several times.
Probably this is a quantum dependency) I don't understand at what point this happens, sometimes two items one after another experience push item errors, and sometimes I don't have enough thousands of attempts to repeat this trick)
In any case, this is just a visual error and after the relog, the item appears in the inventory. I think first i need to disconnect the extender and check it on a bare server. I still need time to check this, maybe it's not even about the autoloot function.
https://youtu.be/6mcfmdImofE
-----------
In general, I would like to thank our wonderful Emca Eressea for her deep knowledge in programming and reverse engineering. And for the fact that her work is open to everyone, this is very amazing, and incredibly valuable.
Question
Natsu
package net.sf.l2j.gameserver.instancemanager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.Announcements;
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;
public class AutoVoteRewardHandler
{
private final String HOPZONE = "Config.HopZone_ID";
// 60 * 1000(1000milliseconds = 1 second) = 60seconds
private final int initialCheck = 60 * 1000;
// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
private final int delayForCheck = Config.Delay_for_check * 1000;
private final int[] itemId = {Config.Item_ID};
private final int[] itemCount = {Config.Item_Count};
private final int[] maxStack = {Config.Max_Stack};
private final int votesRequiredForReward = Config.Votes_Required;
// do not change
private int lastVoteCount = 0;
private AutoVoteRewardHandler()
{
System.out.println("Vote Reward System Initiated.");
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
}
private class AutoReward implements Runnable
{
public void run()
{
int votes = getVotes();
System.out.println("Server Votes: " + votes);
if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("" +
"SELECT" +
" c.charId," +
" c.char_name" +
"FROM" +
" characters AS c" +
"LEFT JOIN" +
" accounts AS a" +
"ON" +
" c.account_name = a.login" +
"WHERE" +
" c.online > 0" +
"GROUP BY" +
" a.lastIP" +
"ORDER BY" +
" c.level" +
"DESC");
ResultSet rset = statement.executeQuery();
L2PcInstance player = null;
L2ItemInstance item = null;
while (rset.next())
{
player = L2World.getInstance().getPlayer("charId");
if (player != null && !player.getClient().isDetached())
{
for (int i = 0; i < itemId.length; i++)
{
item = player.getInventory().getItemByItemId(itemId);
if (item == null || item.getCount() < maxStack)
player.addItem("reward", itemId, itemCount, player, true);
}
}
}
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); }
}
setLastVoteCount(getLastVoteCount() + votesRequiredForReward);
}
Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + votesRequiredForReward) + " Votes.");
if (getLastVoteCount() == 0)
setLastVoteCount(votes);
}
}
private int getVotes()
{
URL url = null;
InputStreamReader isr = null;
BufferedReader in = null;
try
{
url = new URL(HOPZONE);
isr = new InputStreamReader(url.openStream());
in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("moreinfo_total_rank_text"))
return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
in.close();
}
catch (IOException e)
{}
try
{
isr.close();
}
catch (IOException e)
{}
}
return 0;
}
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();
}
}
to code beni ok exw vali kai ta ipolipa gameserver+config alla m vgeni ena error sto parapano code
if (player != null && !player.getClient().isDetached())
bori kapios na m pi pos to fix afto??
10 answers to this question
Recommended Posts
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.