Jump to content

Question

Posted

Hello everyone!
can someone help me modify my code so that my pvp and pk ad show in which region the battle took place? Here an example:

 

0IV8ChX.png

 

 

/*
 * Copyright (C) 2004-2015 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 handlers.custom;

import l2r.Config;
import l2r.gameserver.model.actor.instance.L2PcInstance;
import l2r.gameserver.model.events.Containers;
import l2r.gameserver.model.events.EventType;
import l2r.gameserver.model.events.impl.character.player.OnPlayerPvPKill;
import l2r.gameserver.model.events.listeners.ConsumerEventListener;
import l2r.gameserver.network.SystemMessageId;
import l2r.gameserver.network.serverpackets.SystemMessage;
import l2r.gameserver.util.Broadcast;

public class CustomAnnouncePkPvP
{
	public CustomAnnouncePkPvP()
	{
		if (Config.ANNOUNCE_PK_PVP)
		{
			Containers.Players().addListener(new ConsumerEventListener(Containers.Players(), EventType.ON_PLAYER_PVP_KILL, (OnPlayerPvPKill event) -> OnPlayerPvPKill(event), this));
		}
	}
	
	/**
	 * @param event
	 * @return
	 */
	private Object OnPlayerPvPKill(OnPlayerPvPKill event)
	{
		L2PcInstance pk = event.getActiveChar();
		if (pk.isGM())
		{
			return null;
		}
		L2PcInstance player = event.getTarget();
		
		String msg = Config.ANNOUNCE_PVP_MSG;
		if (player.getPvpFlag() == 0)
		{
			msg = Config.ANNOUNCE_PK_MSG;
		}
		msg = msg.replace("$killer", pk.getName()).replace("$target", player.getName());
		if (Config.ANNOUNCE_PK_PVP_NORMAL_MESSAGE)
		{
			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1);
			sm.addString(msg);
			Broadcast.toAllOnlinePlayers(sm);
		}
		else
		{
			Broadcast.toAllOnlinePlayers(msg, false);
		}
		return null;
	}
}

 

Recommended Posts

  • 0
Posted
42 minutes ago, Rootware said:

 

You are definitely an affiliated person with some members. It look as advertise.

its bad? if its not allowed remove my post :(

you know anyone else? i always send my customers on him and had no complaints so far..

  • 0
Posted (edited)
/**
 * @author Kara
 */
public class YourClass
{
	public Object onPlayerPvPKill(OnPlayerPvPKill event)
	{
		final L2PcInstance activeChar = event.getActiveChar();
		
		if (!activeChar.isGM())
		{
			final String msg = MapRegionManager.getInstance().getMapRegion(activeChar).getName() + ": " + (activeChar.getKarma() > 0 ? Config.ANNOUNCE_PK_MSG : Config.ANNOUNCE_PVP_MSG).replace("$killer", activeChar.getName()).replace("$target", event.getTarget().getName());
			
			if (Config.ANNOUNCE_PK_PVP_NORMAL_MESSAGE)
			{
				Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.S1).addString(msg));
			}
			else
			{
				Broadcast.toAllOnlinePlayers(msg, false);
			}
		}
		
		return null;
	}
}

 

Edited by V-Ray
  • 0
Posted
1 minute ago, HARDECORE said:

Excuse me, sorry to disturb your chat, but can someone help me? :thinking:

 

Search for something called MapRegionManager, you should have normally methods to retrieve zone name. It depends about the pack.

  • 0
Posted
5 minutes ago, HARDECORE said:

Excuse me, sorry to disturb your chat, but can someone help me? :thinking:

 

4 hours ago, V-Ray said:

/**
 * @author Kara
 */
public class YourClass
{
	public Object onPlayerPvPKill(OnPlayerPvPKill event)
	{
		final L2PcInstance activeChar = event.getActiveChar();
		
		if (!activeChar.isGM())
		{
			final String msg = MapRegionManager.getInstance().getMapRegion(activeChar).getName() + ": " + (activeChar.getKarma() > 0 ? Config.ANNOUNCE_PK_MSG : Config.ANNOUNCE_PVP_MSG).replace("$killer", activeChar.getName()).replace("$target", event.getTarget().getName());
			
			if (Config.ANNOUNCE_PK_PVP_NORMAL_MESSAGE)
			{
				Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.S1).addString(msg));
			}
			else
			{
				Broadcast.toAllOnlinePlayers(msg, false);
			}
		}
		
		return null;
	}
}

 

are you blind or something?

  • 0
Posted
2 minutes ago, HARDECORE said:

 

What's wrong?

 

1dsHFwj.png

 

listen he made you an example of the function you dont replace everything :D how experienced are you on this field?

  • 0
Posted
1 minute ago, Nightw0lf said:

ouça, ele fez de você um exemplo da função em que você não substitui tudo: D qual é a sua experiência nesse campo?

very little. I am not a programmer. starting to study in the area

  • 0
Posted

in this case

this is the full example

/*
 * Copyright (C) 2004-2015 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 handlers.custom;

import l2r.Config;
import l2r.gameserver.model.actor.instance.L2PcInstance;
import l2r.gameserver.model.events.Containers;
import l2r.gameserver.model.events.EventType;
import l2r.gameserver.model.events.impl.character.player.OnPlayerPvPKill;
import l2r.gameserver.model.events.listeners.ConsumerEventListener;
import l2r.gameserver.network.SystemMessageId;
import l2r.gameserver.network.serverpackets.SystemMessage;
import l2r.gameserver.util.Broadcast;

public class CustomAnnouncePkPvP
{
	public CustomAnnouncePkPvP()
	{
		if (Config.ANNOUNCE_PK_PVP)
		{
			Containers.Players().addListener(new ConsumerEventListener(Containers.Players(), EventType.ON_PLAYER_PVP_KILL, (OnPlayerPvPKill event) -> OnPlayerPvPKill(event), this));
		}
	}
	
	/**
	 * @param event
	 * @return
	 */
	public Object onPlayerPvPKill(OnPlayerPvPKill event)
	{
		final L2PcInstance activeChar = event.getActiveChar();
		
		if (!activeChar.isGM())
		{
			final String msg = MapRegionManager.getInstance().getMapRegion(activeChar).getName() + ": " + (activeChar.getKarma() > 0 ? Config.ANNOUNCE_PK_MSG : Config.ANNOUNCE_PVP_MSG).replace("$killer", activeChar.getName()).replace("$target", event.getTarget().getName());
			
			if (Config.ANNOUNCE_PK_PVP_NORMAL_MESSAGE)
			{
				Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.S1).addString(msg));
			}
			else
			{
				Broadcast.toAllOnlinePlayers(msg, false);
			}
		}
		
		return null;
	}
}

checkout the imports and see if the classes exist try to compile then see for compilation errors

  • 0
Posted
6 minutes ago, Nightw0lf said:

in this case

this is the full example


/*
 * Copyright (C) 2004-2015 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 handlers.custom;

import l2r.Config;
import l2r.gameserver.model.actor.instance.L2PcInstance;
import l2r.gameserver.model.events.Containers;
import l2r.gameserver.model.events.EventType;
import l2r.gameserver.model.events.impl.character.player.OnPlayerPvPKill;
import l2r.gameserver.model.events.listeners.ConsumerEventListener;
import l2r.gameserver.network.SystemMessageId;
import l2r.gameserver.network.serverpackets.SystemMessage;
import l2r.gameserver.util.Broadcast;

public class CustomAnnouncePkPvP
{
	public CustomAnnouncePkPvP()
	{
		if (Config.ANNOUNCE_PK_PVP)
		{
			Containers.Players().addListener(new ConsumerEventListener(Containers.Players(), EventType.ON_PLAYER_PVP_KILL, (OnPlayerPvPKill event) -> OnPlayerPvPKill(event), this));
		}
	}
	
	/**
	 * @param event
	 * @return
	 */
	public Object onPlayerPvPKill(OnPlayerPvPKill event)
	{
		final L2PcInstance activeChar = event.getActiveChar();
		
		if (!activeChar.isGM())
		{
			final String msg = MapRegionManager.getInstance().getMapRegion(activeChar).getName() + ": " + (activeChar.getKarma() > 0 ? Config.ANNOUNCE_PK_MSG : Config.ANNOUNCE_PVP_MSG).replace("$killer", activeChar.getName()).replace("$target", event.getTarget().getName());
			
			if (Config.ANNOUNCE_PK_PVP_NORMAL_MESSAGE)
			{
				Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.S1).addString(msg));
			}
			else
			{
				Broadcast.toAllOnlinePlayers(msg, false);
			}
		}
		
		return null;
	}
}

checkout the imports and see if the classes exist try to compile then see for compilation errors

  

I added and compiled it. no mistake! but when I test in game the ad does not appear and this error occurs in gameserver

 

zSPbow7.png

 

  • 0
Posted
5 minutes ago, HARDECORE said:

  

I added and compiled it. no mistake! but when I test in game the ad does not appear and this error occurs in gameserver

 

zSPbow7.png

 

 

Either the MapRegionManager return null cause it cannot find the region which is weird, unless you're in a custom map (Which is not included i guess) OR the target of the event is null (which most unlikely).

 

Do a null check in target like 

if (event.getTarget() == null)
{
   //Print message here to confirm is null
   return null;
}

 

If the MapRegionManager return null region and you're not on a custom region then throw your pack in the garbage as i already see is downloaded L2ro.

Guest
This topic is now closed to further replies.
  • Posts

    • Hi everyone,   In 2014, I completely stepped away from developing L2 servers and doing L2J-related work. Since then, I’ve only opened this server about once a year and helped a few servers and individuals for free. I haven’t taken on any paid L2J work since then.   LINEAGE2.GOLD is a project that has reached about Season 6. The first season launched at the end of 2020 and was a fully rebuilt Gold-style server on the Classic client (protocol 110). It featured many custom systems and enhancements. After several seasons, I decided to abandon the Mobius-based project and move to Lucera, as my goal was to get as close as possible to Interlude PTS behavior while still staying on the L2J platform.   The current project was once again completely rebuilt, this time on the Essence client (protocol 306), and is based on Lucera. Because of that, acquiring a license from Deazer is required.   My Lucera extender includes, but is not limited to: Formulas.java Basic anti-bot detection, which proved quite effective, we caught most Adrenaline users using relatively simple server-side logic, logged them, and took staff action. Simple admin account lookup commands based on IP, HWID, and similar identifiers. In-game Captcha via https://lineage2.gold/code, protected by Cloudflare, including admin commands for blacklisting based on aggression levels and whitelisting. Additional admin tools such as Auto-Play status checks, Enchanted Hero Weapon live sync, force add/remove clans from castle sieges, item listeners for live item monitoring, and more. A fully rewritten Auto-Play system with support for ExAutoPlaySetting, while still using the Auto-Play UI wheel, featuring: Debuff Efficiency Party Leader Assist Respectful Hunting Healer AI Target Mode Range Mode Summoner buff support Dwarf mechanics Reworked EffectDispelEffects to restore buffs after Cancellation. Raid Bomb item support. Reworked CronZoneSwitcher. Prime Time Raid Respawn Service. Community Board features such as Top rankings and RB/Epic status. Custom systems for Noblesse, Subclasses, support-class rewards, and much more.   Depending on the deal, the project can include: The lineage2.gold domain The website built on the Laravel PHP framework The server’s Discord Client Interface source Server files and extender source The server database (excluding private data such as emails and passwords)   I’m primarily looking for a serious team to continue the project, as it would be a shame to see this work abandoned. This is not cheap. You can DM me with offers. If you’re wondering why I’m doing this: I’ve felt a clear lack of appreciation from the L2 community, and I’m not interested in doing charity work for people who don’t deserve it. I’m simply not someone who tolerates BS. Server Info: https://lineage2.gold/info Server for test: https://lineage2.gold/download Over 110 videos YouTube playlist: https://www.youtube.com/watch?v=HO7BZaxUv2U&list=PLD9WZ0Nj-zstZaYeWxAxTKbX7ia2M_DUu&index=113
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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