Jump to content

Recommended Posts

Posted

Hello everybody. Here I am again with another topic.

Here you will learn about a few things in l2j.

It would be a bit annoying if I made a new topic for each guide, so I decided to compile them in this one. Let's begin?

 


 

Chapter 1: Voiced Commands

 

All of us know the Voiced Commands.

Simple commands for players that start with the dot (.)

 

So, let's see how to make a simple one!

Let's begin with the well known license (That part can be skipped, but let's do it for fun xD)

/*
* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

 

You can also replace it with your own "license".

Let's continue setting the package.

Since the Voicedcommands are made in the voicedcommandhandlers, the package will always be the same. Which means that the package will be:

package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

 

Okay we are done with this.

Now let's continue with the imports.

You have two options: You will either set the imports now, if you know what you'll use or leave it for later (you'll write what you want and import the proper stuff manually).

 

We'll work with the online voiced command in order to show you a few things (you all know what it does, it shows the ammount of Online players). Even if I know what we'll write, I won't add the imports now, to show you about the imports.

 

Okay, let's add your name as authors now, in order to show who wrote the code!

/**
* @author YourNameHere
*/

You just have to insert your name instead of the "YourNameHere".

 

Let's start the main stuff!

You have to set the class as public and show that it implements the "IVoicedCommandHandler".

So, the form will be like this:

public class OnlinePlayers implements IVoicedCommandHandler

For other codes, the form will be the same, although the "OnlinePlayers" must be replaced with your new voicedcommand.

 

Let's start writing. You all know how! {

Now, let's set the voicedcommands that will be made in this file.

how to do this? Simple. First decide what the command will be. Then show it in this form:

private static final String[] VOICED_COMMANDS ={"on"};

 

Instead of "on" you will need to write your command. Don't delete the "" though!

 

Now let's write what will happen when a player presses the command.

In this case, once the player presses the command he will see the ammount of players online.

So:

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
        {
	        if (command.startsWith("on"))
	        {
	            showPlayers(activeChar, target);		
	        }
	        return true;
               }

Don't forget! Instead of "on" you have to add your own command, and instead of the action I set (showPlayers) you have to set your own.

 

We would have to end our code with this:

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

 

Although, in this code we have to explain what the action above is.

Since the "showPlayers" doesn't exist, we have to "Explain" what it is and what it does.

So, in this case we set the void and make it to send some systemmessages to the player, in order to inform him about the ammount of online players.

So it will be:

public void showPlayers (L2PcInstance player, String target)
{

	{
          	        sm = new SystemMessage(SystemMessageId.S1_S2);	
          	        sm.addString("players are online.");
          	        sm.addNumber(L2World.getInstance().getAllPlayers().size());
          	        player.sendPacket(sm);

	}
}

 

In the end we just close it with a "}".

Now it's time to set the imports!

Let's see what we used.

In our imports we always use the IVoicedCommandHandler, so

import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;

Next, we used the L2World in order to see how many players are online.

So,

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

Don't forget the L2PcInstance, for the activeChar (the online active player).

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

And in the end we used systemmessages to tell him how many players were online.

So we import these two:

import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

Use the function "Organise Imports" and the code is ready!

Now save and close your file!

 

We are not done yet, though!

There is something left!

We have to register our code!

 

In Gracia it will be done on the MasterHandler file, so it will be registered on the VoicedCommands part like that:

VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new OnlinePlayers());

There's no need to import the location of the file, since it imports automaticaly every file at that folder.

 

In Interlude it will be different. You will have to go at Gameserver.java file, open it and add the import.

This file will be imported like:

import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;

And now comes the registeration.

Find the VoicedCommands part, and register the new command like:

_voicedCommandHandler.registerVoicedCommandHandler(new OnlinePlayers());

 

And we're done!

That's how you created a brand new Voiced Command! =]

 

 

Chapter 2: Configurations

 

All of us know the "Config" file. Custom/non modifications are being added there. The reason though is not to add custom features, but to make our lifes easier! Configs are made in order to handle specified settings from simple modifcations. For example, you can simply add a custom TvT Event. You add the teleporting coordinates, you enable it, you set the reward, etc. But if you want to change these settings, in the future many times, you will get pissed off if you don't find the values easily. The solution? You make them configurable. In the configs, you can just change a few numbers or a "True" to "False" (and vice versa) and change the whole server in no time! So we will now see easily, how to make our own configuration. We will make a simple one. My goal is not to teach you what each thing in Config.java does, or how to make every single value configurable. What I want to do, is to show you what Configurations are, and how to start Configuring stuff. Let's begin!

 

First of all, we find what we want to set configurable.

I picked the OnlinePlayers VoicedCommands that we created in a previous guide!

So, let's see.

We will set the use of the class configurable.

What do I mean?

We will create a config that if we set to "True", will enable the use of the VoicedCommand, otherwise (if set to "False) will disable it.

We first create the configuration at the Config.java file, located in net.sf.l2j

Open the file and search for

/**define L2JMODS */

Under this, we have to set the new boolean.. (If you don't know what booleans are, then read the last part of my l2j guide in the L2j Section).

So, let's add this:

public static boolean ENABLE_OUR_CODE;

Instead of ENABLE_OUR_CODE, you can set another name, like ENABLE_ONLINE_VC.

Now, let's search for

Properties L2JModSettings

.

You'll see some configurations about Champion Mobs, etc.

You will have to place the new configuration under those (for example).

So let's add this:

ENABLE_OUR_CODE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableTheCode", "True"));

 

You can replace again the ENABLE_OUR_CODE with something you like, although it must be the same with the one you set above. The "EnableTheCode" is what will be shown at the properties file. About the "True" value we set, you don't have to worry. The feature will be enabled/disabled depending ONLY to the value you will set at the properties file (In this case, l2jmods).

 

So we are done with the java part of the configuration.

Now, let's find the properties file (l2jmods) and add the new configuration.

Open the file and add in the end this:

EnableTheCode = True

You can set it either to true or false. Absolutely your decision.

 

The last part! We have to set this at a place where the code we added before (the custom voiced command, in this case) will be affected. What does this mean? We must find the proper place to add the configuration! In our case, we will go at the place where we registered the command! (MasterHandler for Gracia and Gameserver for Interlude).

Above the code with which we registered the command (this code:

_voicedCommandHandler.registerVoicedCommandHandler(new OnlinePlayers());

Above it, we add the configuration.

if(Config.ENABLE_OUR_CODE)

 

And that's it!

What did we finally do? We created a configuration for the OnlinePlayers voiced command.

If we set the value to "True" the command will be ok. If we set it to "False" the command will be disabled!

 

 

 

What did we learn today? How to create a new VoicedCommand, and how to make Configurations!

I did my best to explain everything in an informal way, so it can be understood by newbies.

If there is something you'd like to learn, or something you didn't understand, feel free to ask here!

Don't spam please.

 

Best Regards,

Coyote™.

 

PS: More guides like these will come soon, if I find free time.

 

To be Continued...

http://www.maxcheaters.com/forum/index.php?topic=123823.0

Posted

FUUUUUUUUUUUU ~~~

 

 

stolen ideas ajajajajajaj gg noob :D

 

Naah, there is just no space left in here.

http://www.maxcheaters.com/forum/index.php?topic=92146.0

 

So I continue them like that xD

Posted

Naah, there is just no space left in here.

http://www.maxcheaters.com/forum/index.php?topic=92146.0

 

So I continue them like that xD

from mine topic in greek section i meant :D

 

 

anyway make sure you will continue them , because noobs keep creating - using preconfs

Posted

anyway make sure you will continue them , because noobs keep creating - using preconfs

 

I will keep creating guides..

I just need free time, and the next days I doubt if I have some..

I'll continue them soon though, don't worry..

Posted

hahah the license and author part is funny.. well u have some good guides Coyote.. will help alot of nabs here that have no clue what they doing :P

i plan on making a full detailed guide "coding an event from scratch" and i will be coding a ctf or dm there.. but probably i wont soon since im a lazy ass.. xD

 

edit: btw u maybe wanna add somewhere in the guide that in epilogue instead of "net.sf.l2j" u need to put "com.l2jserver" (or something like that.. i dont have it in front of me right now)

Posted

hahah the license and author part is funny.. well u have some good guides Coyote.. will help alot of nabs here that have no clue what they doing :P

i plan on making a full detailed guide "coding an event from scratch" and i will be coding a ctf or dm there.. but probably i wont soon since im a lazy ass.. xD

 

Well, thanks and good luck with your future guide!

Posted

As a newbie in java, i have a question. What exactly is this part doing?

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)

 

It is the boolean that, let's say, shows the command and its use.

It shows that if the player presses ".on" then the action below happens.

  • 2 months later...
Posted

i can't add new command becaus my VoicedCommandHandler.java it look like this:

 

package net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());

private static VoicedCommandHandler _instance;

private Map<String, IVoicedCommandHandler> _datatable;

public static VoicedCommandHandler getInstance()
{
	if (_instance == null)
	{
		_instance = new VoicedCommandHandler();
	}
	return _instance;
}

private VoicedCommandHandler()
{
	_datatable = new FastMap<String, IVoicedCommandHandler>();
}

public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
	String[] ids = handler.getVoicedCommandList();
	for (int i = 0; i < ids.length; i++)
	{
		if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
		_datatable.put(ids[i], handler);
	}
}

public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
	String command = voicedCommand;
	if (voicedCommand.indexOf(" ") != -1) {
		command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
	}
	if (Config.DEBUG)
		_log.fine("getting handler for command: "+command+
				" -> "+(_datatable.get(command) != null));
	return _datatable.get(command);
}

    public int size()
    {
        return _datatable.size();
    }
}

what can i do?

Posted

i can't add new command becaus my VoicedCommandHandler.java it look like this:

 

package net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());

private static VoicedCommandHandler _instance;

private Map<String, IVoicedCommandHandler> _datatable;

public static VoicedCommandHandler getInstance()
{
	if (_instance == null)
	{
		_instance = new VoicedCommandHandler();
	}
	return _instance;
}

private VoicedCommandHandler()
{
	_datatable = new FastMap<String, IVoicedCommandHandler>();
}

public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
	String[] ids = handler.getVoicedCommandList();
	for (int i = 0; i < ids.length; i++)
	{
		if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
		_datatable.put(ids[i], handler);
	}
}

public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
	String command = voicedCommand;
	if (voicedCommand.indexOf(" ") != -1) {
		command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
	}
	if (Config.DEBUG)
		_log.fine("getting handler for command: "+command+
				" -> "+(_datatable.get(command) != null));
	return _datatable.get(command);
}

    public int size()
    {
        return _datatable.size();
    }
}

what can i do?

 

Add them in gameserver

serch for:

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

and add before:

_voicedCommandHandler.registerVoicedCommandHandler(new Wedding());

Replace Wedding with your VoicedCommand Name Save & Exit and you are done :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I was there my name Mike99 Dark elf Dagger Skinikothegreek we’re together playing everyday I rember orc Lupu . Mysliwa female human  DestinyNide  Ailon OnlyMe Clan so much nostalgia … I wish to see again that server I will be back for sure!!
    • I connected everything without any problems. Does anyone know why I'm not getting experience for killing mobs? Has anyone encountered this? I'm setting the rates to x300, but it still doesn't give experience or level for killing mobs.
    • I'm using Myext64 HF and recently tried to replicate the "br_xmas09_event" Raising Rudolph Event. Detailed event information can be found at https://legacy-lineage2.com/news/_rudolf_the_red.html After configuring .eventdata.xml and starting the server, t  server log shows: 12/02/2025 15:39:01.809, [NO_ERROR] SpawnEx2 [br_xmas2009_invisible][schuttgart20_npc2213_xs03m1] [1][0][0][0][0][346796390] 12/02/2025 15:39:02.057, DummyPacket received from L2Server 12/02/2025 15:39:02.058, server socket close 312ac(f0820224) error(997) 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][0] Begin 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][2][1] void IOThread_common 1 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][4][3] void __cdecl CServerSocket::OnClose(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][5] End l2server log: 12/02/2025 15:39:02.112, npc server closed(127.0.0.1) error: 64 read buffer size: (server:0 npc:0) 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.131, dwTime[0] < 80 !!!!!!! 12/02/2025 15:39:02.131, [CallStack][tid:7][tick:1][0] Begin 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][2][1] void IOThread_common 1 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][4][3] void __cdecl NpcSocket::OnClose(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][5] End 12/02/2025 15:39:31.767, server closed(127.0.0.1) Error: 64 Read buffer size: (server:0 npc:0) 12/02/2025 15:39:31.768, [NO_ERROR] Logout All Characters : 1   The NPC server sent a packet to the L2 server while generating the br_xmas2009_invisible game NPC server, and the NPC server subsequently crashed.     After some digging, I found a clue in a very old MXC post, but the fix was for the GF version. The whole problem is in l2server side support for NPC function CreateOnePrivateNearUser. It sends CreatePacket but Koreans made some changes in it (added instance ID) so it got broken. As Santa event is the only AI that uses this function, they probably don't know about it    So is there a way to fix this problem, specifically for Myext64 HF? I'd be happy to buy him coffee. set_compiler_opt base_event_type(@NTYPE_NPC_EVENT) class ai_br_vital_manager : default_npc { parameter: int br_vitality2010_EVENT_ID = 20108888; handler: EventHandler CREATED() { } EventHandler TALKED(talker) { ShowPage(talker, "br_vi_stevu001.htm"); super; } EventHandler GIVE_EVENT_DATA(talker, i0, i1, i2, i3, i4) { i3 = i2 / 3600; i2 = i2 - i3 * 3600; i4 = i2 / 60; i2 = i2 - i4 * 60; if (i1 == 20108888) { if (i0 == 1) { CastBuffForQuestReward(talker, @s_br_vitality_day_1); CastBuffForQuestReward(talker, @s_br_vitality_day_2); ShowPage(talker, "br_vi_stevu002.htm"); } else { ShowPage(talker, "br_vi_stevu003.htm"); } } } EventHandler MENU_SELECTED(talker, ask, reply, c0) { if (ask == 50021) { select (reply) { case 1: CanGiveEventData(talker, 20108888); break; case 2: if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu005.htm"); } else if (IsInCategory(@fighter_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_body_for_newbie); CastBuffForQuestReward(talker, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(talker, @s_regeneration_for_newbie); CastBuffForQuestReward(talker, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu006.htm"); } else if (IsInCategory(@mage_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(talker, @s_acumen_for_newbie); CastBuffForQuestReward(talker, @s_concentration_for_newbie); CastBuffForQuestReward(talker, @s_empower_for_newbie); ShowPage(talker, "br_vi_stevu007.htm"); } break; case 3: c0 = GetSummon(talker); if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu011.htm"); } else if (IsNullCreature(c0) == 0 && IsInCategory(@summon_npc_group, c0.class_id) && IsInCategory(@pet_group, c0.class_id) == 0) { CastBuffForQuestReward(c0, @s_wind_walk_for_newbie); CastBuffForQuestReward(c0, @s_shield_for_newbie); CastBuffForQuestReward(c0, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(c0, @s_bless_the_body_for_newbie); CastBuffForQuestReward(c0, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(c0, @s_regeneration_for_newbie); CastBuffForQuestReward(c0, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(c0, @s_acumen_for_newbie); CastBuffForQuestReward(c0, @s_concentration_for_newbie); CastBuffForQuestReward(c0, @s_empower_for_newbie); CastBuffForQuestReward(c0, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu009.htm"); } else { ShowPage(talker, "br_vi_stevu010.htm"); } break; } } } } Another one is about the " br_vitality2010_event event".   GIVE_EVENT_DATA is likely the only one in the activity AI script that uses this handle.      
    • Offtopic, personal attacks, probably too old to use that much memes and what's YOUR actual contribution to L2J, in order I laugh aswell ?   The main poster quotes my pack so I answer accordingly, while you advertise L2JFrozen in both of your posts - discontinued since 2014 (? 1132 rev), with none taking back the open source lead while anyone could.   If you're somewhat affiliated to hopzone, you probably packed way more money than me. Packs don't make any type of money (barely 100e/month) and if you would follow me, you would know there are ways to handle it or even getting paid.   Hope I was short enough, 🧂🤡.
  • 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