Hello so recently i started working on my server again but i have problems with one vote script it doesnt want to start and check for votes
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package net.sf.l2j.gameserver.voteengine;import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URL;import java.net.URLConnection;import java.util.ArrayList;import java.util.Collection;import java.util.List;import java.util.logging.Logger;import net.sf.l2j.Config;import net.sf.l2j.gameserver.ThreadPoolManager;import net.sf.l2j.gameserver.model.L2World;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.network.L2GameClient;import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;import net.sf.l2j.gameserver.util.Broadcast;publicclassAutoVoteReward{publicstaticLogger _log =Logger.getLogger(AutoVoteReward.class.getName());privateint hopzoneVotesCount =0;privateint topzoneVotesCount =0;privateint networkVotesCount =0;protectedList<String> already_rewarded;protectedstatic boolean topzone =false;protectedstatic boolean hopzone =false;protectedstatic boolean network =false;privateAutoVoteReward(){
_log.info("VoteRewardSystem: Initialized.");if(hopzone){int hopzone_votes = getHopZoneVotes();if(hopzone_votes ==-1){
hopzone_votes =0;}
setHopZoneVoteCount(hopzone_votes);}if(Config.VOTE_TOPZONE_ENABLED){if(topzone){int topzone_votes = getTopZoneVotes();if(topzone_votes ==-1){
topzone_votes =0;}
setTopZoneVoteCount(topzone_votes);}}if(Config.VOTE_NETWORK_ENABLED){if(network){int network_votes = getNetworkVotes();if(network_votes ==-1){
network_votes =0;}
setNetworkVoteCount(network_votes);}}ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(newAutoReward(),Config.VOTES_SYSTEM_INITIAL_DELAY,Config.VOTES_SYSTEM_STEP_DELAY);}protectedclassAutoRewardimplementsRunnable{@Overridepublicvoid run(){if(hopzone){int hopzone_votes = getHopZoneVotes();if(hopzone_votes !=-1){
_log.info("Hopzone Votes: "+ hopzone_votes);
announce("[Hopzone] Actual Votes are "+ hopzone_votes +"...");if(hopzone_votes !=0&& hopzone_votes >= getHopZoneVoteCount()+Config.VOTES_FOR_REWARD){
already_rewarded =newArrayList<>();Collection<L2PcInstance> pls = L2World.getInstance().getPlayers();
announce("[Hopzone] Great Work! Check your inventory for Reward!!");for(L2PcInstance player : pls){if(player !=null){if(checkSingleBox(player)){
player.addItem("reward",Config.HOPZONE_REWARD_ID,Config.HOPZONE_REWARD_COUNT, player,true);}}}
setHopZoneVoteCount(hopzone_votes);}
announce("[Hopzone] Next Reward will be on - "+(getHopZoneVoteCount()+Config.VOTES_FOR_REWARD)+" Votes!!");
announce("[Hopzone] For Vote Visit our website - ");}}if(hopzone &&Config.VOTES_SYSTEM_STEP_DELAY >0){try{Thread.sleep(Config.VOTES_SYSTEM_STEP_DELAY /2);}catch(final InterruptedException e){
e.printStackTrace();}}if(Config.VOTE_TOPZONE_ENABLED){if(topzone){int topzone_votes = getTopZoneVotes();if(topzone_votes !=-1){
_log.info("TopZone Votes: "+ topzone_votes);
announce("[Topzone] Actual Votes are "+ topzone_votes +"...");if(topzone_votes !=0&& topzone_votes >= getTopZoneVoteCount()+Config.VOTES_FOR_REWARD){
already_rewarded =newArrayList<>();Collection<L2PcInstance> pls = L2World.getInstance().getPlayers();
announce("[Topzone] Great Work! Check your inventory for Reward!!");for(L2PcInstance player : pls){if(player !=null){if(checkSingleBox(player)){
player.addItem("reward",Config.TOPZONE_REWARD_ID,Config.TOPZONE_REWARD_COUNT, player,true);}}}
setTopZoneVoteCount(topzone_votes);}
announce("[Topzone] Next Reward will be on - "+(getTopZoneVoteCount()+Config.VOTES_FOR_REWARD)+" Votes!!");
announce("[Topzone] For Vote Visit our website - ");}}}if(topzone && hopzone &&Config.VOTES_SYSTEM_STEP_DELAY >0){try{Thread.sleep(Config.VOTES_SYSTEM_STEP_DELAY /2);}catch(final InterruptedException e){
e.printStackTrace();}}if(Config.VOTE_NETWORK_ENABLED){if(network){int network_votes = getNetworkVotes();if(network_votes !=-1){
_log.info("Network Votes: "+ network_votes);
announce("[Network] Actual Votes are "+ network_votes +"...");if(network_votes !=0&& network_votes >= getNetworkVoteCount()+Config.VOTES_FOR_REWARD){
already_rewarded =newArrayList<>();Collection<L2PcInstance> pls = L2World.getInstance().getPlayers();
announce("[Network] Great Work! Check your inventory for Reward!!");for(L2PcInstance player : pls){if(player !=null){if(checkSingleBox(player)){
player.addItem("reward",Config.NETWORK_REWARD_ID,Config.NETWORK_REWARD_COUNT, player,true);}}}
setNetworkVoteCount(network_votes);}
announce("[Network] Next Reward will be on - "+(getNetworkVoteCount()+Config.VOTES_FOR_REWARD)+" Votes!!");
announce("[Network] For Vote Visit our website - ");}}}if(topzone && hopzone && network &&Config.VOTES_SYSTEM_STEP_DELAY >0){try{Thread.sleep(Config.VOTES_SYSTEM_STEP_DELAY /2);}catch(final InterruptedException e){
e.printStackTrace();}}}}protected boolean checkSingleBox(L2PcInstance player){
L2GameClient client = player.getClient();if(player.getClient()!=null&& player.getClient().getConnection()!=null&&!client.isDetached()&&!player.getClient().getConnection().isClosed()){String playerip = player.getClient().getConnection().getInetAddress().getHostAddress();if(already_rewarded.contains(playerip))returnfalse;
already_rewarded.add(playerip);returntrue;}returnfalse;}protectedint getHopZoneVotes(){InputStreamReader isr =null;BufferedReader br =null;try{URLConnection con =new URL(Config.VOTES_SITE_HOPZONE_URL).openConnection();
con.addRequestProperty("User-Agent","Mozilla/4.76");
isr =newInputStreamReader(con.getInputStream());
br =newBufferedReader(isr);String line;while((line = br.readLine())!=null){if(line.contains("<li><span class=\"rank anonymous tooltip\" title")){int votes =Integer.valueOf(line.split(">")[2].replace("</span",""));return votes;}}
br.close();
isr.close();}catch(final Exception e){
_log.warning("[AutoVoteReward] Server L2Hopzone is offline or something is wrong in link");
announce("[Hopzone] is offline. We will check reward as it will be online again");}return-1;}protectedint getTopZoneVotes(){InputStreamReader isr =null;BufferedReader br =null;try{URLConnection con =new URL(Config.VOTES_SITE_TOPZONE_URL).openConnection();
con.addRequestProperty("User-Agent","L2TopZone");
isr =newInputStreamReader(con.getInputStream());
br =newBufferedReader(isr);String line;while((line = br.readLine())!=null){int votes =Integer.valueOf(line);return votes;}
br.close();
isr.close();}catch(Exception e){if(topzone)System.out.println("TOPZONE is offline. We will check reward as it will be online again.");
announce("[Topzone] is offline. We will check reward as it will be online again");}return-1;}protectedint getNetworkVotes(){InputStreamReader isr =null;BufferedReader br =null;try{URLConnection con =new URL(Config.VOTES_SITE_NETWORK_URL).openConnection();
con.addRequestProperty("User-Agent","Mozilla/5.0");
isr =newInputStreamReader(con.getInputStream());
br =newBufferedReader(isr);String line;while((line = br.readLine())!=null){if(line.contains("<div class=\"tls-in-sts\"><b style")){int votes =Integer.valueOf(line.split(">")[2].replace("</b",""));return votes;}}
br.close();
isr.close();}catch(Exception e){if(network)System.out.println("NETWORK is offline. We will check reward as it will be online again.");
announce("[Network] is offline. We will check reward as it will be online again");}return-1;}protectedvoid setHopZoneVoteCount(int voteCount){
hopzoneVotesCount = voteCount;}protectedint getHopZoneVoteCount(){return hopzoneVotesCount;}protectedvoid setTopZoneVoteCount(int voteCount){
topzoneVotesCount = voteCount;}protectedint getTopZoneVoteCount(){return topzoneVotesCount;}protectedvoid setNetworkVoteCount(int voteCount){
networkVotesCount = voteCount;}protectedint getNetworkVoteCount(){return networkVotesCount;}publicstaticAutoVoteReward getInstance(){if(Config.VOTES_SITE_HOPZONE_URL !=null&&!Config.VOTES_SITE_HOPZONE_URL.equals("")){
hopzone =true;}if(Config.VOTES_SITE_TOPZONE_URL !=null&&!Config.VOTES_SITE_TOPZONE_URL.equals("")){
topzone =true;}if(Config.VOTES_SITE_NETWORK_URL !=null&&!Config.VOTES_SITE_NETWORK_URL.equals("")){
network =true;}if(topzone || hopzone || network)returnSingletonHolder._instance;returnnull;}staticvoid announce(String msg){CreatureSay cs =newCreatureSay(0,18,"", msg);Broadcast.toAllOnlinePlayers(cs);}@SuppressWarnings("synthetic-access")privatestaticclassSingletonHolder{protectedstatic final AutoVoteReward _instance =newAutoVoteReward();}
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.
I present to your attention two options for the Hellbound location map
details in the archive
if you have larger effect files, you do not need to replace them
download
updates can be made behind the scenes, so if you catch a crit, post on the forum or download the archive, it may have already been fixed
additionally you can download
all la2 music from the latest version of the game 2025 download
the entire La2 ambisound from the latest version of the game 2025 download
I do what I like because I don't need to push myself to do things for L2 as a means of income. You, on the other hand, are here trying to scam people for $20k files...
But, since you're so talented and competent, I suppose you must be thriving on the fruits of your talents as an L2Off dev, no?
Oh wait
Guess not
Question
iAlreadyExist
Hello so recently i started working on my server again but i have problems with one vote script it doesnt want to start and check for votes
5 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.