Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

[IMP] Comando .xpoff .xpon

Iniciado por Swarlog, Ago 05, 2022, 01:16 AM

Tema anterior - Siguiente tema

Swarlog

CitarCORE:

Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java   (revision 4267)
+++ java/com/l2jserver/Config.java   (working copy)
@@ -650,6 +650,7 @@
    public static boolean BANKING_SYSTEM_ENABLED;
    public static int BANKING_SYSTEM_GOLDBARS;
    public static int BANKING_SYSTEM_ADENA;
+   public static boolean NOXPGAIN_ENABLED;
    public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_CLAN;
    public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE;
    public static boolean OFFLINE_TRADE_ENABLE;
@@ -2217,6 +2218,8 @@
                BANKING_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("BankingEnabled", "false"));
                BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1"));
                BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000"));
+               
+               NOXPGAIN_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("NoXPGainEnable", "false"));
 
                OFFLINE_TRADE_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineTradeEnable", "false"));
                OFFLINE_CRAFT_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineCraftEnable", "false"));
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java   (revision 4272)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
@@ -804,6 +804,18 @@
 
    private int _movieId = 0;
 
+   private boolean _cantGainXP;
+
+   public void cantGainXP(boolean b)
+   {
+      _cantGainXP = b;
+   }
+   
+   public boolean cantGainXP()
+   {
+      return _cantGainXP;
+   }
+   
    private Future<?> _PvPRegTask;
 
    private long _pvpFlagLasts;
Index: java/com/l2jserver/gameserver/model/actor/stat/PcStat.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/stat/PcStat.java   (revision 4241)
+++ java/com/l2jserver/gameserver/model/actor/stat/PcStat.java   (working copy)
@@ -64,7 +64,7 @@
        L2PcInstance activeChar = getActiveChar();
 
         // Allowed to gain exp?
-       if (!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty())
+       if (!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty() || (Config.NOXPGAIN_ENABLED && getActiveChar().cantGainXP()))
               return false;
 
       if (!super.addExp(value)) return false;
@@ -103,7 +103,7 @@
        float ratioTakenByPet = 0;
        // Allowd to gain exp/sp?
        L2PcInstance activeChar = getActiveChar();
-       if (!activeChar.getAccessLevel().canGainExp() && activeChar.isInParty())
+       if (!activeChar.getAccessLevel().canGainExp() && activeChar.isInParty() || (Config.NOXPGAIN_ENABLED && getActiveChar().cantGainXP()))
              return false;
 
        // if this player has a pet that takes from the owner's Exp, give the pet Exp now
Index: java/config/l2jmods.properties
===================================================================
--- java/config/l2jmods.properties   (revision 4267)
+++ java/config/l2jmods.properties   (working copy)
@@ -223,6 +223,12 @@
 # Amount of Adena a player gets when they use the ".withdraw" command. Also the same amount they will lose with ".deposit".
 BankingAdenaCount = 500000000
 
+# ---------------------------------------------------------------------------
+# Voice-command for turning off XP-gain
+# ---------------------------------------------------------------------------
+# Player can use .xpoff to disable XP-gain, and .xpon to enable again.
+# Default: False
+NoXPGainEnable = False
 
 # ---------------------------------------------------------------------------
 # Warehouse Sorting

CitarDATA:

Index: data/scripts/handlers/MasterHandler.java
===================================================================
--- data/scripts/handlers/MasterHandler.java   (revision 7452)
+++ data/scripts/handlers/MasterHandler.java   (working copy)
@@ -299,6 +299,8 @@
          VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Wedding());
       if (Config.BANKING_SYSTEM_ENABLED)
          VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());
+      if (Config.NOXPGAIN_ENABLED)
+         VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new NoExp());
       if (Config.TVT_ALLOW_VOICED_COMMAND)
          VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoicedInfo());
       if (Config.L2JMOD_CHAT_ADMIN)
Index: data/scripts/handlers/voicedcommandhandlers/NoExp.java
===================================================================
--- data/scripts/handlers/voicedcommandhandlers/NoExp.java   (revision 0)
+++ data/scripts/handlers/voicedcommandhandlers/NoExp.java   (revision 0)
@@ -0,0 +1,60 @@
+/*
+ * 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 handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * This class allows user to turn XP-gain off and on.
+ *
+ * @author Notorious
+ */
+public class NoExp implements IVoicedCommandHandler
+{
+   private static final String[] _voicedCommands =
+   {
+      "xpoff",
+      "xpon"
+   };
+   
+   /**
+    *
+    * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
+    */
+   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+   {
+      if (command.equalsIgnoreCase("xpoff"))
+      {
+         activeChar.cantGainXP(true);
+         activeChar.sendMessage("You have turned XP-gain OFF!");
+      }
+      else if (command.equalsIgnoreCase("xpon"))
+      {
+         activeChar.cantGainXP(false);
+         activeChar.sendMessage("You have turned XP-gain ON!");
+      }
+      return true;
+   }
+   
+   /**
+    *
+    * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+    */
+   public String[] getVoicedCommandList()
+   {
+      return _voicedCommands;
+   }
+}