Jump to content
  • 0

Help


HARDECORE

Question

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;
	}
}

 

Link to comment
Share on other sites

Recommended Posts

  • 0
2 hours ago, DenArt Designs said:

and the correct anwser is: @V-Ray

 

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

Link to comment
Share on other sites

  • 0
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..

Link to comment
Share on other sites

  • 0
/**
 * @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
Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

  • 0
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?

Link to comment
Share on other sites

  • 0
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?

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0
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

 

Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • Diablo III, the action-packed hack-and-slash RPG developed by Blizzard Entertainment, has captivated gamers worldwide since its release in 2012. Now, imagine a world where Diablo III's source code is opened up to the community, inviting developers and enthusiasts alike to enhance and refine this beloved game. This topic delves into the possibilities, challenges, and community desires surrounding the idea of Diablo III as an open-source project.   Key Points: 1. Defining Diablo III: Diablo III is an action role-playing game set in the dark fantasy world of Sanctuary. Players traverse through randomized dungeons, battling hordes of demons and collecting loot to strengthen their characters. With its compelling storyline, addictive gameplay mechanics, and rich lore, Diablo III has amassed a dedicated fanbase over the years.   2. Open Source Potential: Opening up the source code of Diablo III could unlock a wealth of opportunities for the game's future. Community developers could introduce new features, enhance existing gameplay elements, and address long-standing issues. The modding community, known for its creativity and innovation, could breathe new life into the game by creating custom content, game modes, and user interface improvements. 3. Community Interest: The question arises - would the gaming community welcome the idea of Diablo III becoming open source? Many players are eager to see the game evolve beyond its current state, with enhancements such as improved balance, expanded end-game content, and enhanced multiplayer features. By involving the community in the development process, Diablo III could foster a stronger sense of ownership and collaboration among its players. 4. Challenges and Considerations: While the concept of Diablo III as an open source is enticing, it also presents several challenges. Ensuring the integrity of the game's balance and preventing cheating would be paramount concerns. Additionally, coordinating development efforts and maintaining a cohesive vision for the game could prove challenging in a community-driven environment. However, with proper oversight and collaboration, these obstacles can be overcome. 5. Is Diablo III an MMORPG? Diablo III is often categorized as an action RPG rather than a traditional MMORPG (massively multiplayer online role-playing game). While it does feature online multiplayer elements, including cooperative play and player-versus-player combat, it lacks the persistent open world typically associated with MMORPGs. Instead, Diablo III focuses on instanced dungeons and smaller-scale multiplayer interactions. The Benefits of Improvement: Improving Diablo III through open-source development could revitalize the game, attracting new players and re-engaging existing fans. By embracing community-driven innovation, Diablo III could remain relevant and enjoyable for years to come. Additionally, fostering an active modding community could extend the game's longevity and create new opportunities for player expression and creativity.   Source code  
    • Good evening, can someone help me, I'm looking for client classic zaken eu protocol 110, is there a download link?  thank you
    • Great developer made my changes in less than 2 weeks. Has full knowledge from start to finish. Definitely recommend. 
    • We are giving out promo codes for 3GBs for testing Asocks proxy. All you need to do is post a reply in this thread.
  • Topics

×
×
  • Create New...