seikah Posted December 26, 2011 Share Posted December 26, 2011 Hi, i am triying to make it works but.. nothing can help me plz?. Uploaded with ImageShack.us package L2j.Infinity.gameserver.model.entity; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.net.URLConnection; import L2j.Infinity.ExternalConfig; import L2j.Infinity.gameserver.Announcements; import L2j.Infinity.gameserver.ThreadPoolManager; import L2j.Infinity.gameserver.model.L2ItemInstance; import L2j.Infinity.gameserver.model.L2World; import L2j.Infinity.gameserver.model.actor.instance.L2PcInstance; public class AutoVoteRewardHandler { private final String HOPZONE = ExternalConfig.WEBSITE_SERVER_LINK; // 60 * 1000(1000milliseconds = 1 second) = 60seconds private final int initialCheck = 60 * 1000; // 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes private final int delayForCheck = 1800 * 1000; private final int[] itemId = {ExternalConfig.ITEM_ID}; private final int[] itemCount = {ExternalConfig.ITEM_COUNT}; private final int[] maxStack = { 1 }; private final int votesRequiredForReward = ExternalConfig.REQUIREDVOTES; // do not change private int lastVoteCount = 0; private static ArrayList<String> _listedIps; private AutoVoteRewardHandler() { System.out.println("Vote Reward System Initiated."); ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck); } private class AutoReward implements Runnable { @Override public void run() { int votes = getVotes(); System.out.println("Server Votes: " + votes); if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward) { Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values(); int onlinePlayers = 0; for (L2PcInstance pl : pls) { if (pl.isOnline() && !pl.getClient().isDetached()) { onlinePlayers++; } } _listedIps = new ArrayList<String>(onlinePlayers); L2ItemInstance item; for (L2PcInstance player : pls) { if (player != null && player.isOnline() && !player.getClient().isDetached()) { for (int i = 0; i < itemId.length; i++) { item = player.getInventory().getItemByItemId(itemId); if (item == null || item.getCount() < maxStack) { String host = player.getClient().getConnection().getInetAddress().getHostAddress(); if (host != null && !_listedIps.contains(host)) _listedIps.add(host); else return; player.addItem("reward", itemId, itemCount, player, true); } } } } 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); URLConnection con = url.openConnection(); con.addRequestProperty("User-Agent", "Mozilla/4.76"); isr = new InputStreamReader(con.getInputStream()); 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(); } } Thx everyone! Quote Link to comment Share on other sites More sharing options...
0 kostantinosftw Posted December 29, 2011 Share Posted December 29, 2011 http://maxcheaters.com/forum/index.php?topic=226697.0 Quote Link to comment Share on other sites More sharing options...
0 seikah Posted December 29, 2011 Author Share Posted December 29, 2011 http://maxcheaters.com/forum/index.php?topic=226697.0 i need 200 pots and i havent :S can put me the thread/ code / download plz ? thx! you cant too see it, if you going to post something post whit knowledge Quote Link to comment Share on other sites More sharing options...
0 SweeTs Posted December 29, 2011 Share Posted December 29, 2011 Index: /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java =================================================================== --- /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java +++ /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java @@ -235,7 +235,7 @@ while ((inputLine = in.readLine()) != null) { - if (inputLine.contains("moreinfo_total_rank_text")) + if (inputLine.contains("rank anonymous tooltip")) { - votes = Integer.valueOf(inputLine.split(">")[2].replace("</div", "")); + votes = Integer.valueOf(inputLine.split(">")[2].replace("</span", "")); break; } Quote Link to comment Share on other sites More sharing options...
0 kostantinosftw Posted January 3, 2012 Share Posted January 3, 2012 I can't see in his code "votes = Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));" so I guess this isn't going to help him :/ Quote Link to comment Share on other sites More sharing options...
0 seikah Posted January 12, 2012 Author Share Posted January 12, 2012 yes.. it dont work :S! Quote Link to comment Share on other sites More sharing options...
0 Zoey76 Posted January 12, 2012 Share Posted January 12, 2012 Change: while ((inputLine = in.readLine()) != null) { if (inputLine.contains("moreinfo_total_rank_text")) { return Integer.valueOf(inputLine.split(">")[2].replace("</div", "")); } } For: while ((inputLine = in.readLine()) != null) { if (inputLine.contains("Anonymous User Votes")) { try { return Integer.parseInt(inputLine.substring(inputLine.indexOf("Votes") + 7, inputLine.indexOf("<", inputLine.indexOf("Votes")))); } catch (Exception e) { return -1; } } } Hope that helps. Quote Link to comment Share on other sites More sharing options...
0 seikah Posted January 22, 2012 Author Share Posted January 22, 2012 Thx all but, its still not working! :S Quote Link to comment Share on other sites More sharing options...
0 Zoey76 Posted January 22, 2012 Share Posted January 22, 2012 I tested it so you did something wrong, I cannot further help you... Quote Link to comment Share on other sites More sharing options...
0 ariasnoff Posted January 26, 2012 Share Posted January 26, 2012 Maybe your server its banned from the rank site ? Quote Link to comment Share on other sites More sharing options...
0 SweeTs Posted January 26, 2012 Share Posted January 26, 2012 http://maxcheaters.com/forum/index.php?topic=227053.0 Quote Link to comment Share on other sites More sharing options...
Question
seikah
Hi, i am triying to make it works but.. nothing can help me plz?.
Uploaded with ImageShack.us
Thx everyone!
Link to comment
Share on other sites
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.