dialogue with an NPC directly via ext.jar

L2g

Heir
Customer
Good evening, is it possible to detect dialogue with an NPC directly via ext.jar?

Att:
My idea is to generate this log:

Log: Player [Test] clicked and interacted with the NPC [Gm-shop ID: xxxxxx]

This is just a study and will not be applied on a live server with players.
 
Last edited:
What specifically is your task, what exactly do you need? You can directly receive data in your NPC upon request or during a dialogue. What specific goal are you pursuing?
 
What specifically is your task, what exactly do you need? You can directly receive data in your NPC upon request or during a dialogue. What specific goal are you pursuing?
My idea is to generate this log:

Log: Player [Test] clicked and interacted with the NPC [Gm-shop ID: xxxxxx]

This is just a study and will not be applied on a live server with players.
 
My idea is to generate this log:

Log: Player [Test] clicked and interacted with the NPC [Gm-shop ID: xxxxxx]

This is just a study and will not be applied on a live server with players.

Lucera already has:

Log.service("Test", player, "DID THIS...");

Logged in gameserver/service.log
 
  • Like
Reactions: L2g
package LGMods;

import l2.gameserver.model.Creature;
import l2.gameserver.model.Player;
import l2.gameserver.model.instances.NpcInstance;
import l2.gameserver.listener.actor.OnAttackListener;
import l2.gameserver.model.actor.listener.CharListenerList;
import l2.gameserver.scripts.ScriptFile;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
* PURPOSE: Capture interaction with NPCs using the Attack Listener (test purpose).
* USAGE: Since dialog click (FirstTalk) is not working on this revision,
* we use the attack click to validate that logging works correctly.
* DATE: 01/18/2026 10:30
*/
public class SentinelNpcInteractionTest implements ScriptFile {

/**
* Listener responsible for capturing attacks against NPCs
*/
private static class NpcTestListeners implements OnAttackListener {

@Override
public void onAttack(Creature attacker, Creature target) {

// Check if the attacker is a player and the target is an NPC
if (attacker == null || !attacker.isPlayer() || target == null || !target.isNpc()) {
return;
}

Player player = attacker.getPlayer();
NpcInstance npc = (NpcInstance) target;

String time = new SimpleDateFormat("HH:mm:ss").format(new Date());

// Formatted log output
String log = String.format(
"[%s] Player [%s] clicked and interacted with the NPC [%s ID: %d]",
time,
player.getName(),
npc.getName(),
npc.getNpcId()
);

// Print to console
System.out.println("[LOG-test] " + log);
}
}

@Override
public void onLoad() {
// Register the listener globally
NpcTestListeners listeners = new NpcTestListeners();
CharListenerList.addGlobal(listeners);

System.out.println("[test] Test Log Module successfully loaded!");
}

@Override
public void onReload() {
// Not used
}

@Override
public void onShutdown() {
// Not used
}
}
[LOG-test] [10:30:05] Player [SilverTitanium] clicked and interacted with the NPC [Valkyrie ID: 40010]
[LOG-test] [10:30:46] Player [SilverTitanium] clicked and interacted with the NPC [Global Gatekeeper ID: 40012]
I managed to get it working like this:

I went to a non-peace zone (outside the city), pressed control and attacked. On the first attack, it generated a log. It worked for NPCs but not for players.

It's similar to what I want, but I need the system to work in a peace zone with NPCs, maybe some (only custom ones), and without pressing control.

Sorry for the insistence and perhaps the way I'm writing; I'm just starting to study this now and also using AI to help me. Just translate it into English correcting the grammar.

NOTE: I didn't know about the development section, that's why I posted in the wrong place. I'll post future questions there.
 
Lucera already has:

Log.service("Test", player, "DID THIS...");

Logged in gameserver/service.log
Yes, that helps, but I didn't understand how to capture this interaction via mod.ext.jar to customize it the way I want. And it only works for some NPCs there; I want GK, Buffer, GM Shop...
 
Back
Top