Jump to content
  • 0

Problem With Announcements!


Question

Posted
Hello all! i have a problem! when the announcements of this event appears all players can see them but is repetable! If 5 players are online 5 annoucments in each player appears...

Thanks in advance!

 

 

 

/*

* 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 java.util.Collection;

 

import net.sf.l2j.Config;

import net.sf.l2j.gameserver.ThreadPoolManager;

import net.sf.l2j.gameserver.Announcements;

import net.sf.l2j.gameserver.model.L2World;

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

 

 

/**

 * @creado KingBorracho69

 *

 */

public class AutoRewarder

{      

 

       public static void getInstance()

       {

               ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()

               {

                       public void run()

                       {

                               AutoReward();

                       }

                      

               }, 0,Config.AUTO_REWARD_DELAY * 1000);

       }

       public static void AutoReward()

       {

               Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();

               for (L2PcInstance p: pls)

               {

                  

                  Announcements.announceToAll("Online Time Reward!");

                       Announcements.announceToAll("Congratulations to all players!");

                       Announcements.announceToAll("Next reward in 30 minutes!");

                       p.addItem("Auto Reward Online", Config.AUTO_REWARD_ID, Config.AUTO_REWARD_COUNT, p, true);

               }

       }

 

}

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

Looks terribly wrong, both writting style and idea. You want to reward any online players, even shops ? Secondly, the reward section should be a subsection of a bigger engine ; by itself it runs independently from the moment you getInstance() it, and you can't even stop it to run.

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
{
     public void run()
     {
          Announcements.announceToAll("Online Time Reward!");
          Announcements.announceToAll("Congratulations to all players!");
          Announcements.announceToAll("Next reward in 30 minutes!");

          for (L2PcInstance p: L2World.getInstance().getAllPlayers().values())
               p.addItem("Auto Reward Online", Config.AUTO_REWARD_ID, Config.AUTO_REWARD_COUNT, p, true);

     }
}, 0,Config.AUTO_REWARD_DELAY * 1000);
Edited by Tryskell
  • 0
Posted

i am just niwbie in java language.... i just wanna reward the online players... all of them! Everything working good but when the Announcments appears as many players are online they will see the same ammount of Announcments... 5 players online... 5 same announcments!

  • 0
Posted (edited)

Because you wrote the announce under the for loop. Use code Tk provided.

Edited by SweeTs
  • 0
Posted (edited)
 public static void AutoReward()

       {

               Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();

               for (L2PcInstance p: pls)

               {

                  

                  Announcements.announceToAll("Online Time Reward!");

                       Announcements.announceToAll("Congratulations to all players!");

                       Announcements.announceToAll("Next reward in 30 minutes!");

                       p.addItem("Auto Reward Online", Config.AUTO_REWARD_ID, Config.AUTO_REWARD_COUNT, p, true);

               }

       }

Translation of your code.

When there is a player online announce to all bla bla bla.

Announcements should happen 1 time so they dont need to be inside any loop for players. Announcements is global function, you dont need to cast it for each player. The loop should just be for the individual global reward.

 

The bad way of writing shouldnt really worry you right now because you are newbie but, try to check how other global methods are handled in your pack or even check others codes doing global stuff so your writing will get more and more optimized.

Edited by TheAllKnowing
Guest
This topic is now closed to further replies.


  • Posts

    • ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚔️ L2JOmen High Five - SERVIDOR 100% RETAIL ⚔️ 📢 SOLICITAMOS APOYO PARA TESTING 📢 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ¡Saludos, comunidad de Lineage II! Estamos desarrollando un proyecto ambicioso y de calidad: L2JOmen High Five, un servidor  100% RETAIL que busca ofrecer la experiencia más auténtica de High Five.  Nos encontramos en la fase de desarrollo y testing, y necesitamos tu ayuda para hacerlo  grande. Si eres un amante del retail, disfrutas probar nuevas funciones y quieres formar  parte de un proyecto serio desde sus inicios, ¡tu apoyo es invaluable! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🎮 CARACTERÍSTICAS PRINCIPALES 🎮 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ SERVIDOR 100% RETAIL    • Experiencia auténtica de High Five    • Geodata PTS Official    • Plataforma Premium 2025 ✅ SISTEMA DE RATES DINÁMICO (Progresión Retail x1 con ayuda x5 -> x1)    • XP: 1-20 (5.0x) | 21-40 (3.0x) | 41-60 (2.0x) | 61-75 (1.5x) | 76-85 (1.0x)    • SP: 1-20 (5.0x) | 21-40 (3.0x) | 41-60 (2.0x) | 61-75 (1.5x) | 76-85 (1.0x)    • Adena: x2.0 (Retail con pequeño ajuste)    • Drop y Spoil: x1.0 (Mobs, Raids y Epics) ✅ SISTEMA DE ENCANTAMIENTO PROFESIONAL    • Enchant Safe: +6 (100% seguro hasta +6)    • Enchant Máximo: +30    • Tasas de encantamiento balanceadas:      * 0-3: 100% | 4: 80% | 5: 75% | 6: 70% | 7: 65% | 8: 60%      * 9: 55% | 10: 50% | 11: 45% | 12: 40%      * 13: 10% | 14-25: 5-9% | 26-30: 1-4%    • Sistema Blessed Enchant habilitado ✅ INICIO DE PERSONAJE    • Dynasty Masterwork Set completo +12    • 1 Ticket para Weapon S +12    • Duración: 7 días ✅ CONFIGURACIÓN RETAIL    • Element Limit: Nivel 4    • Buffs: Duración de 1 hora    • Nobless: Obtenible mediante quest    • Subclass Máxima: 10 (Certificación para cada Subclass) ✅ SISTEMA DE FARM Y ECONOMÍA    • Múltiples monedas de farm (Adena, Ancient Adena, Coin of Luck, PC Bang Points, Farm Coins)    • Varias zonas de farm disponibles    • Zona de Party Farm (se habilita cada 3 horas por 1 hora)    • 4 Raids diarias programadas ✅ SISTEMA PC BANG POINTS    • Aproximadamente 10,000 puntos por 24 horas conectado    • Entrega cada 10 minutos    • Jugadores Normales: 60-72 puntos/intervalo    • Jugadores Premium: 96-116 puntos/intervalo    • 5% probabilidad de doble puntos ✅ SHOPS COMPLETOS    • Shop Normal (Adena y Farm Coins)    • Shop Donate (con opciones premium)    • Armaduras y Armas hasta Grado Dynasty, Moirai, S84    • Joyas completas, no incluye Epics    • Scrolls (Normales, Blessed, Divine, Ancient)    • Elementos hasta nivel 4-7    • Accesorios y consumibles ✅ SISTEMA VIP    • 5 niveles de VIP disponibles    • Bonificaciones progresivas de XP/SP/Drop    • Recompensas diarias exclusivas ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🤝 ¿QUÉ NECESITAMOS DE TI? 🤝 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔍 TESTERS ACTIVOS    • Jugadores que prueben todas las funciones del servidor    • Feedback constructivo sobre bugs, balance y mejoras    • Reporte de problemas encontrados 🎮 JUGADORES DEDICADOS    • Amantes del retail que valoren la experiencia auténtica    • Personas dispuestas a ayudar a mejorar el proyecto    • Comunidad comprometida con el crecimiento del servidor 📊 REPORTES DETALLADOS    • Bugs y errores encontrados    • Sugerencias de balance    • Opiniones sobre el gameplay    • Feedback sobre sistemas implementados ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 💎 ¿POR QUÉ UNIRTE A L2JOmen? 💎 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🌟 PROYECTO SERIO Y COMPROMETIDO    • Desarrollo constante y mejoras continuas    • Atención a la comunidad activa    • Transparencia en todas las decisiones 🎯 EXPERIENCIA 100% RETAIL    • Sin modificaciones que rompan el juego original    • Balance auténtico de High Five    • Gameplay puro y tradicional ⚡ TECNOLOGÍA DE VANGUARDIA    • Servidor optimizado y estable    • Geodata oficial de PTS    • Sistema robusto y sin lag    • Sistema Anticheat Premium 🎁 RECOMPENSAS PARA TESTERS    • Participación activa en el desarrollo    • Reconocimiento especial en el lanzamiento    • Beneficios exclusivos para early testers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📞 CONTACTO E INFORMACIÓN 📞 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Si estás interesado en formar parte de este proyecto y ayudarnos a crear el mejor  servidor retail de High Five, contáctanos. Tu apoyo es fundamental para hacer realidad  este grandioso proyecto. 💬 Únete a nuestro grupo de testing 🌐 WhatsApp: https://chat.whatsapp.com/Km6uRtFsoUq2tNZZalo5HB?mode=wwt ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏆 ¡Juntos construimos el mejor servidor retail! 🏆 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  
    • any server used these files? if yes let me know in pm.
    • L2Net is an in-game (IG) bot. I already have Adrenaline for that. I'm looking for an out-of-game (OOG) bot - one that doesn’t require the Lineage 2 client to run.
    • I came here to say something about ave but it seems i am late already Note for people who might see this topic. Use custom sources of updater, do it your self, learn do it on your time and schedule. its only a how to build it in visual studio youtube video and you're done 90%   no time? pay to a pro like nevesoma.   its easy as fuck
  • 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