Jump to content

Recommended Posts

Posted

Γεια σας μέλη του maxcheaters.

Λοιπων εδώ είναι ένας κώδικας για "Vote Reward" ο οποίος δούλευε σε "Interlude". Tου έχω κάνει μερικές αλλαγές και εχω προσθεσει καποια πράγματα ώστε να λειτουργεί σε "Freya"!!

 

Τα αρχικά credits πηγαίνουν στον "extr3me". Ειναι το πρώτο μου topic που έχει σχέση με CODE.!

 

Εδώ είμαστε λοιπών:

Index: java/config/l2jmods.properties
===================================================================
--- java/config/l2jmods.properties
+++ java/config/l2jmods.properties

# will be 1+2=3. Use 0 or negative value for unlimited number of connections.
# Default: 127.0.0.1,0 (no limits from localhost)
DualboxCheckWhitelist = 127.0.0.1,0
+
+#============================================
+#       Vote Reward System by GoldenBoy     =
+#============================================
+#Set it "True" if you want to Enable Vote Reward System.
+EnableVoteReward = False
+#If you enable Vote Reward System you must fill your Html Patch.
+#e.g. VoteHtmlPatch = http://l2.hopzone.net/lineage2/moreinfo/yourserver/65487.htm
+# Html Patch for Your Vote Site
+# Works with HopZone/HopZones/TopZone and other HopZone Like
+ServerNameForVotes = L2ServerName
+VoteHtmlPatch = 
+VoteReward1Count = 1000
+VoteReward2Count = 1000
+VoteReward1Id = 57
+VoteReward2Id = 57
+VotesForReward = 5
+#Max amount of reward items that you want to stop reward 
+#the player that have more than "MaxRewardCountForStack".
+MaxRewardCountForStackItem1 = 2000000000
+MaxRewardCountForStackItem2 = 2000000000
+#DelayForNextReward in seconds
+DelayForNextReward = 600

 

Index: java/com/l2jserver/gameserver/model/AutoVoteRewardHandler.java
===================================================================
--- java/com/l2jserver/gameserver/model/AutoVoteRewardHandler.java
+++ java/com/l2jserver/gameserver/model/AutoVoteRewardHandler.java
+/* 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 com.l2jserver.gameserver.model;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.GmListTable;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.model.L2ItemInstance;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author GoldenBoy
+ *
+ */
+
+
+public class AutoVoteRewardHandler
+{
+	private int	lastVoteCount = 0;
+	private int	initialCheck = 60 * 1000;														
+	private int	delayForCheck = Config.DELAY_FOR_NEXT_REWARD * 1000;	
+	
+	private AutoVoteRewardHandler()
+
+	{
+		if (Config.VOTE_REWARD_ENABLE)
+		{		
+		System.out.println("========= "+Config.SERVER_NAME_FOR_VOTES+" =========");
+		System.out.println("Vote Reward System activated");
+		System.out.println("========= "+Config.SERVER_NAME_FOR_VOTES+" =========");
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
+		}
+	}
+	
+
+	private class AutoReward implements Runnable
+	{
+		public void run()		
+		{
+			if (Config.VOTE_REWARD_ENABLE)
+			{
+			System.out.println("");
+			System.out.println("==================");
+			System.out.println("Vote Count Check.");
+			if (Config.VOTE_REWARD1_ID == 0 || Config.VOTE_REWARD1_COUNT == 0 || Config.VOTE_REWARD2_ID == 0 || Config.VOTE_REWARD2_COUNT == 0)
+			{
+				GmListTable.broadcastMessageToGMs("The rewards aren't Identified. Please take a look.");
+				return;
+			}
+			int newVoteCount = getVotes(Config.VOTE_HTML_PATCH);
+			System.out.println("getLastVoteCount:"+getLastVoteCount());
+			System.out.println("newVoteCount:"+newVoteCount);
+			System.out.println("==================");
+			System.out.println("");
+			if (newVoteCount != 0 && getLastVoteCount() != 0 && newVoteCount >= getLastVoteCount() + Config.VOTES_FOR_REWARD)
+			{
+				for (L2PcInstance player : L2World.getInstance().getAllPlayers().values())
+				{
+					if (player != null)
+					{
+							L2ItemInstance item1 = player.getInventory().getItemByItemId(Config.VOTE_REWARD1_ID);
+							if (item1 == null || item1.getCount() < Config.MAX_REWARD_COUNT_FOR_STACK_ITEM1)
+							{
+								if (player.getAppearance().getNameColor() != Config.OFFLINE_NAME_COLOR)
+								{
+									player.addItem("reward", Config.VOTE_REWARD1_ID, Config.VOTE_REWARD1_COUNT, player, true);
+								}
+							}
+							else
+							{
+								player.sendMessage("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "You have reached our limit for vote reward items!!");
+							}
+							L2ItemInstance item2 = player.getInventory().getItemByItemId(Config.VOTE_REWARD2_ID);
+							if (item2 == null || item2.getCount() < Config.MAX_REWARD_COUNT_FOR_STACK_ITEM2)
+							{
+								if (player.getAppearance().getNameColor() != Config.OFFLINE_NAME_COLOR)
+								{
+									player.addItem("reward", Config.VOTE_REWARD2_ID, Config.VOTE_REWARD2_COUNT, player, true);
+								}
+							}
+							else
+							{
+								player.sendMessage("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "You have reached our limit for vote reward items!!");
+							}
+					}
+				}	
+				setLastVoteCount(newVoteCount);
+			}
+			Announcements.getInstance().announceToAll("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "Our Current vote count is: " + newVoteCount);
+			Announcements.getInstance().announceToAll("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "The next reward will be given at " + (getLastVoteCount()+ Config.VOTES_FOR_REWARD) + " Votes.");
+			if (getLastVoteCount() == 0)
+			{
+				setLastVoteCount(newVoteCount);
+			}
+			}
+		}
+	}
+
+	private int getVotes(String urlString)
+	{
+		InputStreamReader isr = null;
+		BufferedReader in = null;
+		try
+		{
+			URL url = new URL(urlString);
+                      isr = new InputStreamReader(url.openStream());
+			in = new BufferedReader(isr);
+			String inputLine;
+			int voteCount = 0;
+			while ((inputLine = in.readLine()) != null)
+			{
+				if (inputLine.contains("moreinfo_total_rank_text"))
+				{
+					int Sub = 12;
+					switch (inputLine.length())
+					{
+						case 116:
+							Sub = 13; 
+							break;
+						case 117:
+							Sub = 14; 
+							break;
+						case 118:
+							Sub = 15;
+							break;
+						case 119:
+							Sub = 16; 
+							break;
+					}
+					voteCount = Integer.parseInt(inputLine.substring(inputLine.length() - Sub, inputLine.length() - 11));
+					break;
+				}
+			}
+			return voteCount;
+		}
+		catch (IOException e)
+		{
+			e.printStackTrace();
+			return 0;
+		}
+		finally
+		{
+			try
+			{
+				in.close();
+			}
+			catch (IOException e)
+			{
+				
+			}
+			try
+			{
+				isr.close();
+			}
+			catch (IOException e)
+			{
+				
+			}
+		}
+	}
+	
+	/**
+	 * @return
+	 */
+
+	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();
+	}
+}

 

Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java
+++ java/net/l2jserver/gameserver/GameServer.java

import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.handler.UserCommandHandler;
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
+import com.l2jserver.gameserver.model.AutoVoteRewardHandler;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.AirShipManager;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;

	SkillHandler.getInstance();
	UserCommandHandler.getInstance();
	VoicedCommandHandler.getInstance();
+	 	AutoVoteRewardHandler.getInstance();

	if (Config.L2JMOD_ALLOW_WEDDING)
		CoupleManager.getInstance();

 

Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java
+++ java/com/l2jserver/Config.java

public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
     
+    //Vote Reward
+    public static String 		VOTE_HTML_PATCH;
+    public static int 			VOTE_REWARD1_ID;
+    public static int 			VOTE_REWARD2_ID;
+    public static int 			VOTE_REWARD1_COUNT;
+    public static int 			VOTE_REWARD2_COUNT;
+    public static int 			VOTES_FOR_REWARD;
+    public static boolean 		VOTE_REWARD_ENABLE;
+    public static String 		SERVER_NAME_FOR_VOTES;
+    public static int 			MAX_REWARD_COUNT_FOR_STACK_ITEM1;
+    public static int 			MAX_REWARD_COUNT_FOR_STACK_ITEM2;
+    public static int 			DELAY_FOR_NEXT_REWARD;
+	

//--------------------------------------------------
// NPC Settings
//--------------------------------------------------
=================================================================================================================================================================
							_log.warning(StringUtil.concat("DualboxCheck[Config.load()]: invalid number -> DualboxCheckWhitelist \"", entrySplit[1], "\""));
						}
					}
				}
+					VOTE_HTML_PATCH = L2JModSettings.getProperty("VoteHtmlPatch", "Null");
+					VOTE_REWARD1_COUNT = Integer.parseInt(L2JModSettings.getProperty("VoteReward1Count", "1000"));
+					VOTE_REWARD2_COUNT = Integer.parseInt(L2JModSettings.getProperty("VoteReward2Count", "1000"));
+					VOTE_REWARD1_ID = Integer.parseInt(L2JModSettings.getProperty("VoteReward1Id", "57"));
+					VOTE_REWARD2_ID = Integer.parseInt(L2JModSettings.getProperty("VoteReward2Id", "57"));
+					VOTES_FOR_REWARD = Integer.parseInt(L2JModSettings.getProperty("VotesForReward", "5"));
+					VOTE_REWARD_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableVoteReward", "False"));
+					SERVER_NAME_FOR_VOTES                     = L2JModSettings.getProperty("ServerNameForVotes", "L2ServerName");
+					MAX_REWARD_COUNT_FOR_STACK_ITEM1 = Integer.parseInt(L2JModSettings.getProperty("MaxRewardCountForStackItem1", "2000000000"));
+					MAX_REWARD_COUNT_FOR_STACK_ITEM2 = Integer.parseInt(L2JModSettings.getProperty("MaxRewardCountForStackItem2", "2000000000"));
+					DELAY_FOR_NEXT_REWARD = Integer.parseInt(L2JModSettings.getProperty("DelayForNextReward", "600"));
			}
			catch (Exception e)
			{
				e.printStackTrace();

 

**UPDATE**

Έφτιαξα το error που είχε και το τέσταρα!

Αν θέλετε οι OfflineTrade παίκτες να μην παίρνουν το reward, ενεργοποιήστε το "Offline Name Collor". Έτσι όταν κάποιος παίκτης είναι OfflineTrade και έχει το Χρώμα στον τίτλο του που εσείς ορίσατε δεν θα παίρνει το reward!

 

Rework Credits : GoldenBoy™

Posted

Koitaxe ligo to code sou file merikes lexeis einai la8os grammenes kai merika  + lathos sigoura.:S

Kata ta alla einai kalo , elpizw na doulebei

Αφού είδες πως έχει λάθη δοκίμασε τον να μας πεις αν δουλεύει όντως ή απλά πες του τι είναι λάθος να το διορθώσει.

Posted

Παιδιά συγνώμη αν έχω κάποιο λάθος πάω τώρα αμέσως να το κοιτάξω ξανά!!!

 

EDIT: Το testara και είδα το λαθάκι που είχα! Τώρα δουλεύει πολύ καλά! Ευχαριστώ παίδες!

Posted

Παιδιά συγνώμη αν έχω κάποιο λάθος πάω τώρα αμέσως να το κοιτάξω ξανά!!!

 

EDIT: Το testara και είδα το λαθάκι που είχα! Τώρα δουλεύει πολύ καλά! Ευχαριστώ παίδες!

 

 

Just Tested... :P Doulevei Apsoga... Thanks Pou to ekanes Share... Keep Up ;) ..!

Posted

Fusiko  einai na kolaei kai tha kolaei sinexeia ma fou exei kanei lathos o filos mas o GoldenBoy™

ayto edw kato  prepei na fix.. diladi prepei na to kanete etsi..

 

#DelayForNextReward in seconds
-DelayForNextReward = 120
+DelayForNextReward = 600

 

Gia ton logo oti  kanei  se 120s  next vote kai kolaei..

Gi ayto balteto opws to ekana poio pano kai den tha exei provlima.. :)

Posted

Fusiko  einai na kolaei kai tha kolaei sinexeia ma fou exei kanei lathos o filos mas o GoldenBoy™

ayto edw kato  prepei na fix.. diladi prepei na to kanete etsi..

 

#DelayForNextReward in seconds
-DelayForNextReward = 120
+DelayForNextReward = 600

 

Gia ton logo oti  kanei  se 120s  next vote kai kolaei..

Gi ayto balteto opws to ekana poio pano kai den tha exei provlima.. :)

 

Εμένα δούλευε κανονικά και με 120sec και γιαυτό το είχα έτσι αλλά και για τον λόγο ότι το τέσταρα και ήθελα να δίνει γρήγορα το reward για να δω αν δουλεύει.!

Posted

vasika egw otan ton kanw ston test server pou exw ta kanei mia xara kai ta dinei(ta exw valei ana 1 vote kai ana 20 sec na check)... ston kanoniko omws otan erxete h wra na paroun to reward kai na dosei kainourio ari8mo gia vote kolaei ekei... apo thn mia pistevw ot ginete auto epeidh... mexri na ksanatsekarei exoun perasei ta vote pou 8elei kai kolaei...

pantws kati na to fixarw fast giati mou exei dimiourgi8ei provlima...

Posted

File GoldenBoy™  se test serevr kala to ekanes  kai  na to kaneis test  se  kanoniko server prepei na to kaneis 600 gia ton  logo  na min lagari kai ektos arxisou ta error ston server...

n

Posted

emena mou vgazei auto sto GS:

Exception in thread "GeneralSTPool-4" java.lang.NullPointerException
       at com.l2jserver.gameserver.model.AutoVoteRewardHandler$AutoReward.run(A
utoVoteRewardHandler.java:91)
       at com.l2jserver.gameserver.ThreadPoolManager$RunnableWrapper.run(Thread
PoolManager.java:86)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)

       at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$101(Unknown Source)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
runPeriodic(Unknown Source)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

Posted

File GoldenBoy™  se test serevr kala to ekanes  kai  na to kaneis test  se  kanoniko server prepei na to kaneis 600 gia ton  logo  na min lagari kai ektos arxisou ta error ston server...

n

 

Φίλε Flash™ έχεις δίκιο σε αυτό που λες απλά ξέχασα να το αλλάξω όταν πέρασα τον κώδικα εδώ!

 

==========================================================================

emena mou vgazei auto sto GS:

Exception in thread "GeneralSTPool-4" java.lang.NullPointerException
        at com.l2jserver.gameserver.model.AutoVoteRewardHandler$AutoReward.run(A
utoVoteRewardHandler.java:91)
        at com.l2jserver.gameserver.ThreadPoolManager$RunnableWrapper.run(Thread
PoolManager.java:86)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)

        at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$101(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
runPeriodic(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

 

Δες ξανά το topic είχα και εγώ αυτό το error και το fixara και το έκανα και εδώ update, προσθέτοντας την αλλαγή αυτή!

 

Αυτό εδώ άλλαξα:

+						if (item1 == null || item1.getCount() < Config.MAX_REWARD_COUNT_FOR_STACK_ITEM1)
+						{
+							player.addItem("reward", Config.VOTE_REWARD1_ID, Config.VOTE_REWARD1_COUNT, player, true);
+						}
+						else
+						{
+							player.sendMessage("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "You have reached our limit for vote reward items");
+						}

 

 

και αυτό:

+						if (item2 == null || item2.getCount() < Config.MAX_REWARD_COUNT_FOR_STACK_ITEM2)
+						{
+							player.addItem("reward", Config.VOTE_REWARD2_ID, Config.VOTE_REWARD2_COUNT, player, true);
+						}
+						else
+						{
+							player.sendMessage("[" + Config.SERVER_NAME_FOR_VOTES+"]" + "You have reached our limit for vote reward items");
+						}

 

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.




×
×
  • Create New...