Autor Tema: [IMP] Limitar mensajes del chat con tiempo  (Leído 1396 veces)

Agosto 14, 2014, 01:15:57 pm

Conectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.584
  • Karma: 3
  • Sexo: Masculino
    • U3Games
Código: You are not allowed to view links. Register or Login
Index: java/config/options.properties
===================================================================
#[False] Does not necessarily imply that the GeoData buffer's content is not resident in physical memory.
ForceGeodata = True
+
+#True = Enable delay
+ShoutChatDelay = False
+TradeChatDelay = False

Código: You are not allowed to view links. Register or Login
Index: java/net/sf/l2j/Config.java
===================================================================
    /** AI max thread */
    public static int AI_MAX_THREAD;
+
+    public static boolean SHOUT_CHAT_DELAY;
+    public static boolean TRADE_CHAT_DELAY;
+
… …   
                FORCE_GEODATA                   = Boolean.parseBoolean(optionsSettings.getProperty("ForceGeoData", "True"));
                ACCEPT_GEOEDITOR_CONN           = Boolean.parseBoolean(optionsSettings.getProperty("AcceptGeoeditorConn", "False"));
+
+                SHOUT_CHAT_DELAY                  = Boolean.parseBoolean(optionsSettings.getProperty("ShoutChatDelay", "false"));
+                TRADE_CHAT_DELAY                  = Boolean.parseBoolean(optionsSettings.getProperty("TradeChatDelay", "false"));

Código: You are not allowed to view links. Register or Login
Index: java/net/sf/l2j/Config.java
===================================================================
    /** AI max thread */
    public static int AI_MAX_THREAD;
+
+    public static boolean SHOUT_CHAT_DELAY;
+    public static boolean TRADE_CHAT_DELAY;
+
… …   
                FORCE_GEODATA                   = Boolean.parseBoolean(optionsSettings.getProperty("ForceGeoData", "True"));
                ACCEPT_GEOEDITOR_CONN           = Boolean.parseBoolean(optionsSettings.getProperty("AcceptGeoeditorConn", "False"));
+
+                SHOUT_CHAT_DELAY                  = Boolean.parseBoolean(optionsSettings.getProperty("ShoutChatDelay", "false"));
+                TRADE_CHAT_DELAY                  = Boolean.parseBoolean(optionsSettings.getProperty("TradeChatDelay", "false"));

Código: You are not allowed to view links. Register or Login
Index: java/net/sf/l2j/gameserver/clientpackets/Say2.java
===================================================================
case SHOUT:
+   if (Config.SHOUT_CHAT_DELAY && !activeChar.isGM())
+ {
+ if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_SHOUTVOICE))
+ {
+ activeChar.sendMessage("Action failed. You are only able to speak in the Shout channel once every 10 seconds.");
+ return;
+ }
+ }
                if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") ||
                        (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
… …   
case TRADE:
+   if (Config.TRADE_CHAT_DELAY && !activeChar.isGM())
+ {
+ if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_TRADEVOICE))
+ {
+ activeChar.sendMessage("Action failed. You are only able to speak in the Trade channel once every 10 seconds.");
+ return;
+ }
+ }
if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") ||
(Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))

Código: You are not allowed to view links. Register or Login
Index: java/net/sf/l2j/gameserver/util/FloodProtector.java
===================================================================
         public static final int PROTECTED_ITEMPETSUMMON = 3;
         public static final int PROTECTED_HEROVOICE             = 4;
+         public static final int PROTECTED_SHOUTVOICE    = 5;
+         public static final int PROTECTED_TRADEVOICE    = 6;

         // =========================================================

config/options:

Código: You are not allowed to view links. Register or Login
# Chat configuration
# Values: GLOBAL, REGION, GM, OFF
# Global Chat - Default: REGION
GlobalChat = REGION
# Time limit between using Global Chat in 100ms
GlobalChatTime = 1
# Trade Chat - Default: REGION
TradeChat = REGION
# Time limit between using Trade Chat in 100ms
TradeChatTime = 1

Abril 01, 2017, 04:08:29 am
Respuesta #1

Desconectado Lagartijo

  • Usuario
  • *
  • Mensajes: 5
  • Karma: 0
Fataría una parte del código, esto algo que me interesa.

Gracias

Octubre 23, 2017, 05:34:09 am
Respuesta #2

Desconectado cesar777

  • Usuario
  • *
  • Mensajes: 7
  • Karma: 0
el apartado options.properties no lo tengo :( cual seria el mio? uso l2jacis interlude

Octubre 23, 2017, 07:38:42 pm
Respuesta #3

Conectado swarlog

  • Desarrollador
  • Usuario
  • *
  • Mensajes: 1.584
  • Karma: 3
  • Sexo: Masculino
    • U3Games
You are not allowed to view links. Register or Login
el apartado options.properties no lo tengo :( cual seria el mio? uso l2jacis interlude

Puedes añadirlo en cualquier otro que tengas, pero en el config recuerda asignarselo ^^

Ejemplo:

Código: You are not allowed to view links. Register or Login
SHOUT_CHAT_DELAY = Boolean.parseBoolean(optionsSettings.getProperty("ShoutChatDelay", "false"));
Cambia esto a donde lo pusiste:

Código: You are not allowed to view links. Register or Login
SHOUT_CHAT_DELAY = Boolean.parseBoolean(XXXXXXXXXXXX.getProperty("ShoutChatDelay", "false"));