Little help over here :P

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
HyperByter
Posts: 28
Joined: Tue Jun 04, 2013 1:26 am
Contact:

Little help over here :P

Post by HyperByter »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision 6040M:
L2JDP Revision 9776:

Ok guys i tried to fix this problem for hours but unsuccessfully, so now its time to get help from better devs than me lol :P i m trying to make some custom castle battle event ( i will contribute it to L2J as soon as its finished )

Code: Select all

 /* * Copyright (C) 2004-2013 L2J DataPack *  * This file is part of L2J DataPack. *  * L2J DataPack 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. *  * L2J DataPack 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 *fork*.CastleBattle; import java.util.Calendar;import java.util.logging.Logger; import com.l2jserver.gameserver.Announcements;import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; /** * @author HyperByter * @version Beta * @build 2.7.2013 */ public class CastleBattle{    private static Logger _log = Logger.getLogger("CastleBattle");        private static String htm_path = "data/scripts/*fork*/CastleBattle/";    private static int CB_State = 1; // 0 - Disabled, 1 - Not in progress, 2 - Participation, 3 - Running, 4 - Event ended        // Initialize Engine    private static void CB_Init()    {        if (CB_State != 0)        {            SetStartTime();        }    }        // Event Loop    public static void SetStartTime()    {        Calendar _nextTime = Calendar.getInstance();        int _m = _nextTime.get(Calendar.MINUTE);        int x = 1;        while (_m > 5)        {            _m -= 5;            x++;        }        _nextTime.set(Calendar.MINUTE, x * 5);        ThreadPoolManager.getInstance().scheduleGeneral(new CastleBattleLoop(), _nextTime.getTimeInMillis() - System.currentTimeMillis());    }        // Allow players to participate in the event    public static void StartParticipation()    {        CB_State = 2;        Announcements.getInstance().announceToAll("Castle Battle participation has started.");        _log.info("Castle Battle participation has started.");    }        // Player requests to join event via NPC    public static void CB_bypass(String _cmd, L2PcInstance _player)    {        if (_cmd.startsWith("InitHtmlRequest"))        {            if (CB_State == 0)            {                NpcHtmlMessage _html = new NpcHtmlMessage(0);                _html.setFile("", htm_path + "CB_Disabled.htm");                _player.sendPacket(_html);            }            if (CB_State == 1)            {                NpcHtmlMessage _html = new NpcHtmlMessage(0);                _html.setFile("", htm_path + "CB_NotInProgress.htm");                _player.sendPacket(_html);            }            if (CB_State == 2)            {                NpcHtmlMessage _html = new NpcHtmlMessage(0);                _html.setFile("", htm_path + "CB_Participate.htm");                _player.sendPacket(_html);            }        }    }        public static void main(String[] args)    {        _log.info("# Castle Battle Engine #");        _log.info("Author : HyperByter");        _log.info("Version : Beta");        _log.info("Version : 2.7.2013");        CastleBattle.CB_Init();    }    } class CastleBattleLoop implements Runnable{    @Override    public void run()    {        CastleBattle.StartParticipation();    }} 
everything works fine without errors, but the problem is that variable CB_State doesnt change after starting participation, it still says its 1 ( not in progress ). i rly got no idea what more to change to get it working...

thx for your help ;)

[EDIT] : i see that l2()dc string was replaced with *fork* but it isnt from fork, its shortened name of my server.
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Little help over here :P

Post by BiggBoss »

replace

Code: Select all

 class CastleBattleLoop implements Runnable{    @Override    public void run()    {        CastleBattle.StartParticipation();    }} 
for

Code: Select all

 static class CastleBattleLoop implements Runnable{    @Override    public void run()    {        CastleBattle.StartParticipation();    }} 
EDIT: And make it inner class
Image
User avatar
HyperByter
Posts: 28
Joined: Tue Jun 04, 2013 1:26 am
Contact:

Re: Little help over here :P

Post by HyperByter »

ok i did, but now i m getting error :

Illegal modifier for the class CastleBattleLoop; only public, abstract & final are permitted
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Little help over here :P

Post by BiggBoss »

HyperByter wrote:ok i did, but now i m getting error :

Illegal modifier for the class CastleBattleLoop; only public, abstract & final are permitted
yeah, i edited the post while you was changing :mrgreen:
Make it inner class
Image
User avatar
HyperByter
Posts: 28
Joined: Tue Jun 04, 2013 1:26 am
Contact:

Re: Little help over here :P

Post by HyperByter »

mhm i m not sure if i understood correctly, so i should put CastleBattleLoop class inside CastleBattle class ?
If yes i did but now how to call this class with scheduled function ? new CastleBattleLoop() doesnt work :P

Anyway i dont think its cuz of this loop class, i tried to call StartParcitipation method directly from SetStartTime and same shit happened :D CB_State value didnt change. looks like i need to declare it in other way, but i m not that pro in java lol
Last edited by HyperByter on Tue Jul 02, 2013 10:10 am, edited 1 time in total.
User avatar
BiggBoss
L2j Veteran
L2j Veteran
Posts: 1104
Joined: Wed Apr 15, 2009 3:11 pm
Location: Spain

Re: Little help over here :P

Post by BiggBoss »

dunno what are you doing wrong or what is going wrong, but the code does not seems to have any problem
Image
User avatar
HyperByter
Posts: 28
Joined: Tue Jun 04, 2013 1:26 am
Contact:

Re: Little help over here :P

Post by HyperByter »

yep its pretty obvious cuz i didnt find any problem with it aswell except of this never changing int value. maybe there is some other detail which i missed and thats why it isnt working properly, well lets see what other devs will suggest, anyway thx for your help dude ;)
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7008
Joined: Tue Aug 11, 2009 3:36 am

Re: Little help over here :P

Post by Zoey76 »

Powered by Eclipse 4.34 🌌 | Eclipse Temurin 21 ☕ | MariaDB 11.3.2 🗃️ | L2J Server 2.6.3.0 - High Five 🚀

🔗 Join our Discord! 🎮💬
User avatar
HyperByter
Posts: 28
Joined: Tue Jun 04, 2013 1:26 am
Contact:

Re: Little help over here :P

Post by HyperByter »

thx for answer Zoey :P

so the result of your enhancement is following :

When I tried to talk to npc which holds this script before event started, it wrote "Castle Battle is not currently running"... which is OK, but then event didnt start at all, so I restarted server and didnt talk to npc before event started ( then it did ) but then when I spoke to to it, it still said "Castle Battle is not currently running"

I bypassed CB_bypass function thru getInstance method but you see what it did.. anyway I managed to learn something about those Singletons methods before you responded, and got it partially working with the following code ( it got expanded a little in meanwhile ) :

http://pastebin.com/vjxCtBEv

The only one problem is that it starts only when I talk to npc at least once, then participation starts properly at time which is defined at SetStartTime.

So I tried to put CastleBattle.getInstance.CB_bypass("",null) to main method so the instance get automatically initialized, but then the result was that participation started twice ( once automatically, 2nd time when I spoke to NPC )
Well I guess I shouldn't put anything inside class constructor, but then the result will be that participation starts automatically if I call CB_Init from main method thru getInstance, but after that, NPC will say that Castle Battle engine is disabled ( int CB_State = 0 );

[EDIT] : NPC bypass script : http://pastebin.com/6asNEEK8
Post Reply