Jump to content

Block PvP Option on certain map


Recommended Posts

  • Active+ Member

Hello Metin2 Dev.
As the title says, i'm here to present a way to block pvp option on certain maps, this is good for PvP Projects.

#Search this function:
def __OnClickPvPModeFreeButton(self):

#Replace with:
	def __OnClickPvPModeFreeButton(self):
		if self.__CheckPvPProtectedLevelPlayer():
			return

		self.__RefreshPVPButtonList()

		import background
		if background.GetCurrentMapName() == "metin2_map_c1":
			chat.AppendChat(chat.CHAT_TYPE_INFO, "You can't do this here. ")
		elif constInfo.PVPMODE_ENABLE:
			net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)

Wish you a good use on this.
With best regards,

Doose.

  • Good 1
Link to comment
Share on other sites

  • Premium
def __IsSpecialMap(self):
		import background
		dis_maps = [
			"metin2_map_duel",
			"metin2_map_ridack5",
			"metin2_map_t3"
		]
		if str(background.GetCurrentMapName()) in dis_maps:
			return TRUE
		return FALSE

	def __OnClickPvPModeFreeButton(self):
		if self.__CheckPvPProtectedLevelPlayer():
			return

		self.__RefreshPVPButtonList()

		if self.__IsSpecialMap():
			chat.AppendChat(chat.CHAT_TYPE_INFO, "You can't do this here. ")
		elif constInfo.PVPMODE_ENABLE:
			net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)

In case someone wants to add more maps and not just 1

  • Metin2 Dev 1
Link to comment
Share on other sites

  • Active Member

Src/game

pvp.cpp

Add:

#include "questmanager.h"


Find:
 

bool CPVPManager::CanAttack(LPCHARACTER pkChr, LPCHARACTER pkVictim)
{

Add below:
 

	if (quest::CQuestManager::instance().GetEventFlag("pvp_block_"+std::to_string(pkChr->GetMapIndex())) && pkVictim->IsPC())
		return false;



Usage in game:

Example in map c1

Activate:

/e pvp_block_41 1

Deactivate:
 

/e pvp_block_41 0


You can set any map index.

  • Metin2 Dev 1
Link to comment
Share on other sites

  • Active+ Member
On 8/30/2023 at 6:52 PM, firewall said:
def __IsSpecialMap(self):
		import background
		dis_maps = [
			"metin2_map_duel",
			"metin2_map_ridack5",
			"metin2_map_t3"
		]
		if str(background.GetCurrentMapName()) in dis_maps:
			return TRUE
		return FALSE

	def __OnClickPvPModeFreeButton(self):
		if self.__CheckPvPProtectedLevelPlayer():
			return

		self.__RefreshPVPButtonList()

		if self.__IsSpecialMap():
			chat.AppendChat(chat.CHAT_TYPE_INFO, "You can't do this here. ")
		elif constInfo.PVPMODE_ENABLE:
			net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)

In case someone wants to add more maps and not just 1

This is actually a good interaction.
A friend of mine asked me to do the code i wrote on this topic just for a single map, that's why i didn't do this way.

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.