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