Jump to content

Recommended Posts

Posted

With this command the players from your server can vote for the server restart.

 

If there are 25 (config) votes the server will restart by him self.

 

And here is the code:

Index: D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties	(revision 194)
+++ D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties	(working copy)
@@ -227,3 +227,12 @@
# Announce Level Settings
MinLevelToAnnounce = 1
MaxLevelToAnnounce = 80
+
+# ========================== #
+#   Server Restart Voting    #
+# ========================== #
+# Enable Server Restart Command
+AllowServerRestartCommand = False
+
+# Votes For Restart
+VotesNeededForRestart = 20
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java	(revision 194)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java	(working copy)
@@ -960,6 +960,10 @@
     public static int NPC_ANNOUNCER_MIN_LVL_TO_ANNOUNCE;
     public static int NPC_ANNOUNCER_MAX_LVL_TO_ANNOUNCE;
     public static boolean NPC_ANNOUNCER_DONATOR_ONLY;
+    
+    /** Server Restart */
+    public static boolean ALLOW_SERVER_RESTART_COMMAND;
+    public static int     VOTES_NEEDED_FOR_RESTART;

	/** Event Automation */
	public static int TIME_BETWEEN_EVENTS;
@@ -2091,6 +2095,9 @@
         		NPC_ANNOUNCER_MAX_ANNOUNCES_PER_DAY = Integer.parseInt(Mods.getProperty("AnnouncesPerDay", "20"));
         		NPC_ANNOUNCER_MIN_LVL_TO_ANNOUNCE = Integer.parseInt(Mods.getProperty("MinLevelToAnnounce", "0"));
         		NPC_ANNOUNCER_MAX_LVL_TO_ANNOUNCE = Integer.parseInt(Mods.getProperty("MaxLevelToAnnounce", "80"));
+        		
+        		ALLOW_SERVER_RESTART_COMMAND = Boolean.parseBoolean(Mods.getProperty("AllowServerRestartCommand", "False"));
+        		VOTES_NEEDED_FOR_RESTART     = Integer.parseInt(Mods.getProperty("VotesNeededForRestart", "20"));
             }
             catch (Exception e)
             {
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 196)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -617,6 +617,9 @@
     public boolean _inEventVIP = false;
     public boolean _isNotVIP = false, _isTheVIP = false;
     public int _originalNameColourVIP, _originalKarmaVIP;
+    
+    /** Server Restart Vote Parameters */
+    public boolean		_voteRestart		= false;

	/** new loto ticket **/
	private int _loto[] = new int[5];
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java	(revision 189)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -204,6 +204,7 @@
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.JoinVIP;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.PmOff;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.ServerRestartVote;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TradeOff;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoiceInfo;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Wedding;
@@ -620,6 +621,9 @@
			_voicedCommandHandler.registerVoicedCommandHandler(new BuyRec());

		_voicedCommandHandler.registerVoicedCommandHandler(new JoinVIP());
+		
+		if(Config.ALLOW_SERVER_RESTART_COMMAND)
+			_voicedCommandHandler.registerVoicedCommandHandler(new ServerRestartVote());

		_log.config("VoicedCommandHandler: Loaded " + _voicedCommandHandler.size() + " handlers.");

 

Now create new file named ServerRestartVote.java in net.sf.l2j.gameserver.commandhandler.voicedcommands and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.RestartVoteVariable;

/**
* @author SkyLanceR
*/

public class ServerRestartVote implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = {"vote_restart"};

/**
 * 
 * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
 */

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	RestartVoteVariable e = new RestartVoteVariable();

	if(command.startsWith("vote_restart"))
	{
		if (activeChar._voteRestart == false)
		{
			e.increaseVoteCount("restart");
			activeChar._voteRestart = true;
			activeChar.sendMessage("You succesfully voted for the server restart. Votes For The Moment: " + e.getVoteCount("tvt") + ".");
			Announcements.getInstance().announceToAll("Player: "+activeChar.getName()+" has voted for server restart. If you whant to support him type .vote_restart !");
		}
		else
		{
			activeChar.sendMessage("You have already voted for an server restart.");
		}
	}
	return false;
}

public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}
}

 

Create new file named VoteVariable.java in net.sf.l2j.gameserver.model.actor.entity and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/

package net.sf.l2j.gameserver.model.entity;

/**
*@author SkyLanceR
*/

public class RestartVoteVariable
{
public int				_voteCountRestart = 0;
private int				_voteCount = 0;

public int getVoteCount(String name)
{
	if (name == "restart")
	{
		_voteCount = _voteCountRestart;
	}
	return  _voteCount;
}

public void increaseVoteCount(String name)
{
	if (name == "restart")
	{
		_voteCountRestart = _voteCountRestart+1;
	}
}
}

 

Create new file named RestartTheServer.java in net.sf.l2j.gameserver.model.actor.entity and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.model.entity;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.Shutdown;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;


/**
* @author SkyLanceR
*/

public class RestartTheServer
{

public static void playerRestart(L2PcInstance activeChar, boolean restart)
{
	RestartVoteVariable e = new RestartVoteVariable();

	if (e.getVoteCount("restart") > Config.VOTES_NEEDED_FOR_RESTART)
	{
		Shutdown.getInstance().startShutdown(activeChar, 60, restart);
	}
}
}

 

Tested in L2J Interlude & Working

Thats all.

Hope its useful and helpful.

Credits: SkyLancer & Me

Guest
This topic is now closed to further replies.


  • Posts

    • Provide proofs not providing any kind of proofs i will just issue warnings
    • For the odbc you have to run the Instalador.exe and click crear dsn, but you have to rename them so the lin2clancomm.dsn for example becomes l2c4_lin2clancomm but also check if the file inside has as database value the correct file name, about the client i also wanted a clean client because i had a problem with the monsters because the character didn't have collision with the monsters and he was running through them but i fixed it with files from a normal interlude client, also my client is now c3 😛 i changed the maps, staticmeshes, systextures so now i do not have the fortresses at antharas lair for example but i also have the c3 sounds and login screen. Where is @GX-Ext
    • I really wonder if they launched the server without testing it even once. All players are creating new characters and transferring the level 20 reward to their main ones. It seems banning people is much easier than sending them a direct message in-game. If you can’t do your job properly, get in touch with people who can help you. I made 17 million in 10 minutes on a 1x Adena rate server and got an Icarus weapon. My suggestion to you — as it's written on the character you banned — is to wipe the server and run a proper OBT. Good luck with your time as administrators; although it doesn't look like it will last very long.  
    • all the reports vanished into thin air  
    • 🔥L2 INTERPRIDE - Pride Style  OPENING THIS NOVEMBER! 🔥  ✅ Grand Opening - November 15th! ✅ ❤️ Open Beta - October 08th! ❤️  🩵  The most up-to date client on the market! ▶️  Retail Pride Style Interlude with the new Client! 💡Discord: https://discord.gg/l2interpride 🌍 General Information Client: Interlude Type: Custom PvP Server Rates: High Rates Starting Level: 56 Balanced PvP Environment Unique PvP Enchant System PvP Synergy System: Support Classes earn PvP Score when assisting DDs in kills Toggle Skills → Now Passive Killing Spree: Every 25 kills grants Hero Aura + Hero Skills until death 🐉 Raid Boss System If you are within 1500 radius when a Raid Boss dies, you automatically receive 1 Raid Boss Chest in your inventory! 💫 Join the Battle ⚔️ Experience modern PvP gameplay on a classic Interlude foundation! 🔥 Build your power. Earn glory. Dominate Aden. 🧙 Custom Items Armors: 🛡️ Tier 1: Dread ⚔️ Tier 2: Titanium 👑 Tier 3: Pride Weapons: 🔱 Tier 1: Unique (PvP / PvE) ⚔️ Tier 2: Pride 💀 Tier 3: Abyssal Accessories: Up to 30 custom accessories with unique stats Legendary Dyes: +5 / -2 Belts: Various special stats ⚔️ Custom PvP Skills PvPs Name Color Reward Skill 500 Blue Firework CP Heal +800 1000 Violet Firework Cleanse 1500 Green Blessed Body 2000 Yellow MP Recharge 2500 Light Blue Special Focus 3000 Orange Death Whisper Debuff 3500 Dark Purple Might 4000 Red Empower 4500 Red Increase Weight Debuff 5000 Red Wind Walk 6000 Red Berserker Spirit 7000 Red Recall NPC 🛒 Shops & NPCs Item Store: Up to A/S grade, Potions, Consumables & more Mysterious Merchant: Custom Armors, Weapons, Accessories NPC Buffer: All Buffs + Scheme System Class Master: Free Class Change 🔥 Enchant System Safe Enchant: +7 Max Enchant: +25 Weapon Rate: Custom (higher enchant = lower rate) Armor Rate: Custom (higher enchant = lower rate) Jewel Rate: Custom (higher enchant = lower rate) ⚙️ Rates Experience: x5000 Skill Points: x5000 Drop Rate: x1 Adena: x500 🏆 Events Team vs Team (TvT) Capture the Flag (CTF) Death Match Castle Siege Hunting Grounds URF TvT 💎 Custom Features ALT + Left Click → Remove selected Buff ALT + F → Teleport System Shift + Left Click → View Monster Droplist
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock