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");
+						}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server! Create your free account here  
    • I've purchased the Samurai interface. Everything went smoothly, and the interface is excellent. Highly recommended!
    • For quick reference, I’ve been using the D12 dice roller when testing dice mechanics—clean design and instant results help a lot. It might give you a solid visual template to work from as you build your own games.
    • 🪙 GoldRush — High Five x20 🪙   A fresh High Five server focused on active progression, fair competition, and a healthy player-driven economy.   GoldRush is built for players who want a fresh spin on our beloved game that is connected to today's world via Web3 marketplace.    🏅 Gold Bar & Marketplace • Gold Bars are part of the server's custom economy — they can be used in Marketplace or Cosmetics shop. • Tokens are optional and used only for server Marketplace features.   ⚙️ Server Rates • EXP: 20x • SP: 20x • Adena: 10x • Normal Drop Chance: 8x • Spoil Chance: 12x • Raid Drop Chance: 3x • Quest Item Drop Amount: 5x • Quest EXP/SP Reward: 10x • Quest Adena Reward: 5x   ✨ Enchant Rates • Max Enchant: Weapons +16 / Armors +12 • +0 to +3 armor / weapon = 100% safe • +0 to +4 full body armor = 100% safe • +4 to +6 = 66% • +7 to +9 = 60% • +10 to +12 = 54% • +13 to +14 = 48% • +15 to +16 = 42%   🛒 Alt+B Services GoldRush includes useful Alt+B services: • GM Shop up to Dynasty • Buffer 1h • Teleports • Drop Search • Rankings   🎒 Auto-Loot • Normal mob drops: auto-loot • Adena: auto-loot • Raid drops: stay on the ground • Herbs: stay on the ground   🧙 Class Progression • 1st and 2nd professions are free with shadow weapon reward. • 3rd profession: 5kk • Auto Learn Skills • Subclass - No Quest • Noblesse - Full Quest     ⚔️ Olympiad • Hero period: 1 week • Olympiad time: 18:00–00:00 server time • Match duration: 5 minutes • Max enchant in Olympiad: +6   🏰 Sieges Castle sieges take place on Sundays at 16:00 and 20:00 GMT+3. The first siege will happen 2 weeks after launch.   🐉 Grand Boss Respawn Queen Ant: 24h + 2h random Core: 30h + 2h random Orfen: 48h + 2h random Baium: 120h + 3h random Antharas: 120h + 24h random Valakas: 120h + 24h random Beleth: 120h + 24h random   ⚔️ Fair Play Bots are strictly forbidden and will result in a ban without warning. Dualbox is limited to 1 box. GoldRush is built around a healthy player-to-player economy. Website : https://www.goldrushpvp.xyz/ Discord : https://discord.com/invite/v3zRZVV6ka Guide of how to make an account on our web3 server!  
    • Patch notes of update v1.0 is done regarding some feedbacks. Added Special Buffs category to the buffer. Queen Cat, Seraphim and Dwarf equipment buffs are now available. Special buffs last 1 hour and can be saved in schemes. Players can now Shift+Click monsters to check drops and spoil directly in-game.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..