Jump to content

Recommended Posts

Posted

Thanks *NeverMore* gia tin idea....

Perigrafi:

Kathe 12 ores ginete announce automata an oi players

theloun o server na ginei rr, etsi tous dinete to dikeoma

na patisoun .yes . no(san vote).

Auto krataei gia 3 lepta....molis teliosoun ta 3 lepta

ginonte announce ta apotelesmata.

Analoga me ta nai kai ta oxi, o server kanei restart i

sinexizei ti litourgia.

 

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

	/** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
	private L2FolkInstance _lastFolkNpc = null;
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -197,6 +197,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.PartyInfo;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Time;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Wedding;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.autorestart;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.stats;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.AuctionManager;
@@ -219,6 +220,7 @@
import net.sf.l2j.gameserver.model.L2Manor;
import net.sf.l2j.gameserver.model.L2PetDataTable;
import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.entity.AutoRestart;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.entity.TvTManager;
import net.sf.l2j.gameserver.network.L2GameClient;
@@ -390,6 +392,8 @@
		CastleManager.getInstance();
		SiegeManager.getInstance();

+		AutoRestart.getInstance();
+		
		TeleportLocationTable.getInstance();
		LevelUpData.getInstance();
		L2World.getInstance();
@@ -589,6 +593,7 @@

		_voicedCommandHandler = VoicedCommandHandler.getInstance();
		_voicedCommandHandler.registerVoicedCommandHandler(new stats());
+		_voicedCommandHandler.registerVoicedCommandHandler(new autorestart());

		if(Config.L2JMOD_ALLOW_WEDDING)
			_voicedCommandHandler.registerVoicedCommandHandler(new Wedding());
Index: java/net/sf/l2j/gameserver/model/entity/AutoRestart.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AutoRestart.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AutoRestart.java	(revision 0)
@@ -0,0 +1,139 @@
+/* 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.model.entity;
+
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.Shutdown;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author  Codex
+ */
+public class AutoRestart 
+{
+	static boolean canVote = false;
+	public static int yes = 0;
+	public static int no = 0;
+	
+	class Task implements Runnable{
+		public void run()
+		{
+			handle();
+		}	
+	}
+
+	void handle(){
+		globalMessage("Want a server restart? Vote now by pressing .yes or .no");
+		setCanVote(true);
+		globalMessage("In 3 minutes, votes are closed...please press .yes or .no");
+		waitMinutes(2);
+		globalMessage("In 1 minutes, votes are closed...please press .yes or .no");
+		waitMinutes(1);
+		setCanVote(false);
+		globalMessage("Votes closed, results will be shown in 30 seconds");
+		waitSeconds(30);
+		checkTheVotes();
+		clear();
+		
+	}
+	void globalMessage(String s){
+		Announcements.getInstance().announceToAll(s);
+	}
+	
+	void setCanVote(boolean z){
+		canVote = z;
+	}
+	
+	public static boolean getCanVote(){
+		return canVote;
+	}
+	
+	void waitMinutes(int i){
+		try{
+			Thread.sleep(i * 60000);
+		}
+		catch(Exception ie){
+			ie.printStackTrace();
+		}
+	}
+	
+	void waitSeconds(int i){
+		try{
+			Thread.sleep(i * 1000);
+		}
+		catch(Exception ie){
+			ie.printStackTrace();
+		}
+	}
+	
+	public static void increaseYes(boolean n){
+		if(n){
+			yes = yes + 1;
+		}
+		else{
+			no = no + 1 ;
+		}	
+	}
+	
+	int takeYes(){
+		return yes;
+	}
+	
+	int takeNo(){
+		return no;
+	}
+	
+	void checkTheVotes(){
+		globalMessage("Results: Yes: "+takeYes()+", No: "+takeNo());
+		if(takeYes() > takeNo()){
+			globalMessage("Server will restart...");
+			for(L2PcInstance p: L2World.getInstance().getAllPlayers()){
+			Shutdown.getInstance().startShutdown(p, 30, true);}
+		}
+		else if(takeYes() < takeNo()){
+			globalMessage("Server will not restart...");
+			globalMessage("Server is continuing normally");
+		}
+	}
+	
+	void clear(){
+		yes = 0;
+		no = 0;
+		for(L2PcInstance p: L2World.getInstance().getAllPlayers())
+			p._vote = false;
+	}
+	
+	private AutoRestart()
+	{
+	ThreadPoolManager.getInstance().scheduleGeneral(new Task(), 43200000);
+	}
+	
+	 public static AutoRestart getInstance()
+	 {
+	return SingletonHolder._instance;
+	 }
+	      
+	 private static class SingletonHolder
+	 {
+	 @SuppressWarnings("synthetic-access")
+	protected static final AutoRestart _instance = new AutoRestart();
+	}
+}
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java	(revision 0)
@@ -0,0 +1,76 @@
+/* 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.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.AutoRestart;
+
+/**
+ *
+ * @author  Codex
+ */
+public class autorestart implements IVoicedCommandHandler
+{
+
+	private static final String[] VOICED_COMMANDS = { "yes", "no"};
+	
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar,String target)
+	{
+		if(command.startsWith("yes")){
+		if(!AutoRestart.getCanVote()){
+		   return false;
+		}
+		else if(activeChar._vote = true){
+			activeChar.sendMessage("You have already voted.");
+			return false;
+		}
+		else if(activeChar == null) return false;
+		
+		else {
+			activeChar.sendMessage("You voted successfully.");
+			AutoRestart.increaseYes(true);
+			activeChar._vote = true;
+		}
+	}
+		else if(command.startsWith("no")){
+			if(!AutoRestart.getCanVote()){
+				   return false;
+				}
+			else if(activeChar._vote = true){
+				activeChar.sendMessage("You have already voted.");
+				return false;
+			}
+				else if(activeChar == null) return false;
+			
+			activeChar.sendMessage("You voted successfully.");
+			AutoRestart.increaseYes(false);
+			activeChar._vote = true;
+		}
+		return true;
+}
+
+	/**
+	 * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+	 */
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+
+}

Credits:Me

Einai kalo se servers me polla atoma pisteuw, isos an kolisei o server kamia fora, oi an oi gm den einai mesa.

Posted

akomi ena kalo share apo esena .... Aksizei karma i douleia s tis teleutaies meres nomizw alla krima pou dn mporw na sto dosw ... Otan exo xrono 8a to kanw test na dw ama doulevei

 

 

Thanks For share ...

Posted

poly kalo alla na rotiso ekei pou exeis bali auto:

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

simeni oti den ta boroun na psifizoun oi hero kai oi nobless?

Posted

poly kalo alla na rotiso ekei pou exeis bali auto:

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

simeni oti den ta boroun na psifizoun oi hero kai oi nobless?

oxi vevea.....
  • 8 months later...

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

    • i'm doing the same, but 'training with olympiad videos.
    • Hi, I’m interested in purchasing a C4 (Chronicle 4) server pack or source code, preferably something that has already been tested and run on a live server. I’m looking for a stable, well-tested project rather than a fresh/unproven build. If you have something available for sale, please send me some details, including the price and what is included.
    • ⚡ High-performance AI tools ready to boost your productivity. Instant delivery on ChatGPT Plus, Claude, and Cursor!
    • To give your server the maximum launch exposure, we built L2Calendar as a calendar-first listing. We are pushing it hard with constant SEO, a 4-language Blog/Vlog, and a Public API to bring real players to your listing — our primary goal is to become the most complete and best-known L2 calendar on the internet.   FREE Server Adding — Auto-Approved, add your server in just 2 minutes at l2calendar.com/addnews. Simply add our button to your website and your listing is auto-approved instantly. We give you the code, you paste it, done. VIP Auto-Approved Instantly No button required. Any VIP listing is approved automatically upon submission. 🎁 All 4 VIP tiers are currently FREE (limited stock), so you can get top placement completely free at l2calendar.com/addnews_vip 4 VIP Tiers — Fully Automated Choose Bronze, Silver, Gold, or Gold+, all pinned above free servers. Select the number of days and your VIP goes live instantly. Manage everything yourself using your Unique ID (xxx-xxx-xxx-xxx) at l2calendar.com/extend-vip — extend or upgrade anytime. A 20% discount will be available when paid tiers return.  VIP4 Announcer + LIVE Countdown Timer, only VIP Gold+ (VIP4) gets the animated homepage announcer with a live ticking countdown (e.g. “Starts in 02:14:33”). It gives upcoming launches extra visibility and creates real hype before opening. EXCLUSIVE: Add to Calendar — Google / Outlook / AppleEvery server card includes an Add to Calendar option. Players can add your opening in one click to Google Calendar, Outlook, or Apple Calendar and receive a native notification when your server starts. More day-one logins, fewer missed launches. Powerful Discovery, players can discover servers by 15 Chronicles (Interlude to Essence), 5 Rate Types (Low / Craft / PvP / GvE / PTS), 12 Feature Labels, and Calendar Date (Today / Tomorrow / Next 10 Days / Past 10 Days + date picker).   Our Website: https://l2calendar.com Collaboration Contact: admin@l2calendar.com
  • 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..