Jump to content

Disable Duel for Some Map


Recommended Posts

Hi guys :D

 

Someone wanna disable duel for some map.

 

If you're ready then let's go ;)

 

 

open uigameoption.py and add this module in your uigameoption.py

import background

after search this.

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

		self.__RefreshPVPButtonList()

		if constInfo.PVPMODE_ENABLE:
			net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)

replace to 

	def __OnClickPvPModeFreeButton(self):
		if self.__CheckPvPProtectedLevelPlayer():
			return
			
			
		mapDict = (
			"metin2_map_a1",
			"metin2_map_b1",
			"metin2_map_c1",
		)
		
		if(background.GetCurrentMapName() in mapDict):
			chat.AppendChat(chat.CHAT_TYPE_INFO, "You can not change pvp mode on this map.")
			return

		self.__RefreshPVPButtonList()

		if constInfo.PVPMODE_ENABLE:
			net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)

If player wanna change PvP-Mode and player in this map, player can not change pvp-mode.

 

thanks @metin2_team

	def __SendChatPacket(self, text, type):
#		if text[0] == '/':
#			if ENABLE_CHAT_COMMAND or constInfo.CONSOLE_ENABLE:
#				pass
#			else:
#				return

		if net.IsChatInsultIn(text):
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING)
		else if "pkmode" in text:
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
			return
		else:
			net.SendChatPacket(text, type)

thanks @Sanchez for r40k

 

 

 

The thread and the idea is great, but NEVER do something like this on client-side. Here is the server-side solution:

Add mapindex.cpp and mapindex.h to your project
 
Copy this to mapindex.cpp:

#include "fstream"
#include "stdafx.h"

std::vector<std::string> ExcludeIndex;

void LoadIndexes()
{
    std::string tempIndex;
    std::ifstream File("locale/mapindex.txt");

    if (!File.is_open())
    {
        sys_log(0, "WARNING: locale/mapindex.txt");
        return;
    }

    ExcludeIndex.clear();

    while (!File.eof())
    {
        File >> tempIndex;
        ExcludeIndex.push_back(tempIndex);
    }

    File.close();
}

Copy this to mapindex.h:

extern std::vector<std::string> ExcludeIndex;
extern void LoadIndexes();

Add this to main.cpp:

#include "mapindex.h"

Add this under PanamaLoad(); still in main.cpp:

LoadIndexes();

Add this to char.cpp:

#include "mapindex.h"

And these events:

std::string CHARACTER::LongToString(long data)
{
    std::ostringstream convert;
    convert << data;
    return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
    for (int i = 0; i < ExcludeIndex.size(); i++)
    {
        if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
        {
            return false;
        }
    }

    return true;
}

Open cmd_general.cpp and navigate to ACMD(do_pvp)
Add this to the begin of the event:

    if (!ch->AllowMapIndex())
    {
        ch->ChatPacket(CHAT_TYPE_INFO, ("PVP has been blocked on this map!"));
        return;
    }

Example mapindex.txt:

1
2
3
4
5
6
7

 

 

Kind Regards

HaveBeen

  • Love 5

Plain logic saves lives.

Link to comment
Share on other sites

  • Premium

The thread and the idea is great, but NEVER do something like this on client-side. Here is the server-side solution:

Add mapindex.cpp and mapindex.h to your project
 
Copy this to mapindex.cpp:

#include "fstream"
#include "stdafx.h"

std::vector<std::string> ExcludeIndex;

void LoadIndexes()
{
	std::string tempIndex;
	std::ifstream File("locale/mapindex.txt");

	if (!File.is_open())
	{
		sys_log(0, "WARNING: locale/mapindex.txt");
		return;
	}

	ExcludeIndex.clear();

	while (!File.eof())
	{
		File >> tempIndex;
		ExcludeIndex.push_back(tempIndex);
	}

	File.close();
}

Copy this to mapindex.h:

extern std::vector<std::string> ExcludeIndex;
extern void LoadIndexes();

Add this to main.cpp:

#include "mapindex.h"

Add this under PanamaLoad(); still in main.cpp:

LoadIndexes();

Add this to char.cpp:

#include "mapindex.h"

And these events:

std::string CHARACTER::LongToString(long data)
{
	std::ostringstream convert;
	convert << data;
	return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
	for (int i = 0; i < ExcludeIndex.size(); i++)
	{
		if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
		{
			return false;
		}
	}

	return true;
}

Open cmd_general.cpp and navigate to ACMD(do_pvp)
Add this to the begin of the event:

	if (!ch->AllowMapIndex())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, ("PVP has been blocked on this map!"));
		return;
	}

Example mapindex.txt:

1
2
3
4
5
6
7
  • Love 11
Link to comment
Share on other sites

Really, a function LongToString on a CHARACTER class?
Why don't you compare numbers (with the already existing function for string to number saving), rather than converting number to strings and comparing them? Isn't that a bit counterintuitive?
 
I know I only complain but well...  the concept is fine so it's hard to correct add anything there. (Please don't take it as anything else but as constructive criticism)

 

 

Someone not blocked this word. I just wanna show a solution.

 

And I was just pointing out this wasn't a definitive solution at all - As Sanchez said, anything clientside only is a very bad idea, anyone with enough experience will go over your block as if it weren't there.

 

Regards.

  • Love 1
Link to comment
Share on other sites

 

The thread and the idea is great, but NEVER do something like this on client-side. Here is the server-side solution:

Add mapindex.cpp and mapindex.h to your project

 

Copy this to mapindex.cpp:

#include "fstream"
#include "stdafx.h"

std::vector<std::string> ExcludeIndex;

void LoadIndexes()
{
	std::string tempIndex;
	std::ifstream File("locale/mapindex.txt");

	if (!File.is_open())
	{
		sys_log(0, "WARNING: locale/mapindex.txt");
		return;
	}

	ExcludeIndex.clear();

	while (!File.eof())
	{
		File >> tempIndex;
		ExcludeIndex.push_back(tempIndex);
	}

	File.close();
}

Copy this to mapindex.h:

extern std::vector<std::string> ExcludeIndex;
extern void LoadIndexes();

Add this to main.cpp:

#include "mapindex.h"

Add this under PanamaLoad(); still in main.cpp:

LoadIndexes();

Add this to char.cpp:

#include "mapindex.h"

And these events:

std::string CHARACTER::LongToString(long data)
{
	std::ostringstream convert;
	convert << data;
	return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
	for (int i = 0; i < ExcludeIndex.size(); i++)
	{
		if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
		{
			return false;
		}
	}

	return true;
}

Open cmd_general.cpp and navigate to ACMD(do_pvp)

Add this to the begin of the event:

	if (!ch->AllowMapIndex())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, ("PVP has been blocked on this map!"));
		return;
	}

Example mapindex.txt:

1
2
3
4
5
6
7

 

Thanks for comment. But i don't make for r40k :) Just for r2089,r34083 :)

 

Hovewer, i'll add your comment in my topic :D

 

Kind Regards

HaveBeen

  • Love 2

Plain logic saves lives.

Link to comment
Share on other sites

 

 

 

Someone not blocked this word. I just wanna show a solution.

 

clientside only is a very bad idea, anyone with enough experience will go over your block as if it weren't there.

 

Regards.

 

Yep i understand you. only clientside is very bad but these files just for r2089,r34083. Already if i'll make for r40k, i'll share source files on this forum :)

 

Thanks for advice.

 

Kind Regards

HaveBeen

Plain logic saves lives.

Link to comment
Share on other sites

  • 1 year later...

there is a lot of code for me also adding new files etc 

i did it more easy way 

find

if (ch->GetArena() != NULL || CArenaManager::instance().IsArenaMap(ch->GetMapIndex()) == true)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´ë·ÃÀå¿¡¼­ »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù."));
        return;
    }


change 

if (ch->GetArena() != NULL || CArenaManager::instance().IsArenaMap(ch->GetMapIndex()) == true || ch->GetMapIndex() == 222)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´ë·ÃÀå¿¡¼­ »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù."));
        return;
    }

 

|| ch->GetMapIndex() == 222 its your map index to be blocked  u can change o copy it 

 

Link to comment
Share on other sites

  • 3 weeks later...

Compile error:

Spoiler

 

char.cpp: At global scope:
char.cpp:7399: error: no 'std::string CHARACTER::LongToString(long int)' member function declared in class 'CHARACTER'
char.cpp: In member function 'std::string CHARACTER::LongToString(long int)':
char.cpp:7401: error: aggregate 'std::ostringstream convert' has incomplete type and cannot be defined
char.cpp: At global scope:
char.cpp:7406: error: no 'bool CHARACTER::AllowMapIndex()' member function declared in class 'CHARACTER'
 


cmd_general.cpp: In function 'void do_pvp(CHARACTER*, const char*, int, int)':
cmd_general.cpp:785: error: 'class CHARACTER' has no member named 'AllowMapIndex'

 


 

where add this? in what file cpp?

And these events:

std::string CHARACTER::LongToString(long data)
{
	std::ostringstream convert;
	convert << data;
	return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
	for (int i = 0; i < ExcludeIndex.size(); i++)
	{
		if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
		{
			return false;
		}
	}

	return true;
}
Link to comment
Share on other sites

  • 3 months later...
On 06.01.2016 at 11:34 PM, daredevil09 said:

Compile error:

  Hide contents

 

char.cpp: At global scope:
char.cpp:7399: error: no 'std::string CHARACTER::LongToString(long int)' member function declared in class 'CHARACTER'
char.cpp: In member function 'std::string CHARACTER::LongToString(long int)':
char.cpp:7401: error: aggregate 'std::ostringstream convert' has incomplete type and cannot be defined
char.cpp: At global scope:
char.cpp:7406: error: no 'bool CHARACTER::AllowMapIndex()' member function declared in class 'CHARACTER'
 


cmd_general.cpp: In function 'void do_pvp(CHARACTER*, const char*, int, int)':
cmd_general.cpp:785: error: 'class CHARACTER' has no member named 'AllowMapIndex'

 


 

where add this? in what file cpp?

And these events:


std::string CHARACTER::LongToString(long data)
{
	std::ostringstream convert;
	convert << data;
	return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
	for (int i = 0; i < ExcludeIndex.size(); i++)
	{
		if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
		{
			return false;
		}
	}

	return true;
}

up

Link to comment
Share on other sites

 

On 06.01.2016 at 11:34 PM, daredevil09 said:

Compile error:

  Reveal hidden contents

 

char.cpp: At global scope:
char.cpp:7399: error: no 'std::string CHARACTER::LongToString(long int)' member function declared in class 'CHARACTER'
char.cpp: In member function 'std::string CHARACTER::LongToString(long int)':
char.cpp:7401: error: aggregate 'std::ostringstream convert' has incomplete type and cannot be defined
char.cpp: At global scope:
char.cpp:7406: error: no 'bool CHARACTER::AllowMapIndex()' member function declared in class 'CHARACTER'
 


cmd_general.cpp: In function 'void do_pvp(CHARACTER*, const char*, int, int)':
cmd_general.cpp:785: error: 'class CHARACTER' has no member named 'AllowMapIndex'

 


 

where add this? in what file cpp?

And these events:


std::string CHARACTER::LongToString(long data)
{
	std::ostringstream convert;
	convert << data;
	return convert.str();
}

bool CHARACTER::AllowMapIndex()
{
	for (int i = 0; i < ExcludeIndex.size(); i++)
	{
		if (!strcmp(LongToString(GetMapIndex()).c_str(), ExcludeIndex[i].c_str()))
		{
			return false;
		}
	}

	return true;
}

 

Link to comment
Share on other sites

  • 3 months later...

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.