• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Advanced PvP Arena (w/ recent bugfix)

I tried to compile with TFS 0.2.8 and there are some errors (Combat Zone code allready in and working!) but PVP Arena i get following message:

Code:
Compiler: Default compiler
Building Makefile: "C:\Dokumente und Einstellungen\Mathias\Desktop\Kopie von forgottenserver\Makefile.win"
Führt  make clean aus
rm -f account.o actions.o admin.o allocator.o ban.o baseevents.o chat.o combat.o commands.o condition.o configmanager.o connection.o container.o creature.o creatureevent.o cylinder.o database.o databasemysql.o databasesqlite.o depot.o exception.o fileloader.o game.o gui.o house.o housetile.o inputbox.o ioguild.o iologindata.o iomap.o iomapserialize.o item.o items.o logger.o luascript.o mailbox.o map.o md5.o monster.o monsters.o movement.o networkmessage.o npc.o otserv.o outfit.o outputmessage.o party.o player.o playerbox.o position.o protocol80.o protocol.o protocollogin.o quests.o raids.o rsa.o scheduler.o scriptmanager.o server.o spawn.o spells.o status.o talkaction.o tasks.o teleport.o textlogger.o thing.o tile.o tools.o trashholder.o vocation.o waitlist.o weapons.o pvparena.o Sinteria_Console_private.res SinteriaCON.exe

g++.exe -c account.cpp -o account.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

g++.exe -c actions.cpp -o actions.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from player.h:25,
                 from actions.cpp:24:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c admin.cpp -o admin.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from player.h:25,
                 from admin.h:80,
                 from admin.cpp:22:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c allocator.cpp -o allocator.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

g++.exe -c ban.cpp -o ban.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from player.h:25,
                 from ban.h:26,
                 from ban.cpp:24:

pvparena.h:39:23: warning: no newline at end of file

g++.exe -c baseevents.cpp -o baseevents.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

g++.exe -c chat.cpp -o chat.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from player.h:25,
                 from chat.cpp:23:

pvparena.h:39:23: warning: no newline at end of file

g++.exe -c combat.cpp -o combat.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from map.h:31,
                 from combat.h:27,
                 from combat.cpp:22:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c commands.cpp -o commands.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from commands.h:27,
                 from commands.cpp:26:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c condition.cpp -o condition.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from map.h:31,
                 from game.h:28,
                 from condition.cpp:23:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c configmanager.cpp -o configmanager.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

g++.exe -c connection.cpp -o connection.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from protocol80.h:29,

                 from connection.cpp:25:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c container.cpp -o container.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from map.h:31,
                 from iomap.h:25,
                 from container.cpp:23:
pvparena.h:39:23: warning: no newline at end of file

g++.exe -c creature.cpp -o creature.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Dev-Cpp/others/lua-5.1/include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__RULEVIOLATIONREPORTS__ -D__CONSOLE__ -D__COMBAT_ZONES__ -D__PVP_ARENA__  

In file included from tile.h:30,
                 from creature.h:31,
                 from creature.cpp:22:

pvparena.h:39:23: warning: no newline at end of file
creature.cpp: In member function `virtual void Creature::onDeath()':
creature.cpp:473: error: `creature' undeclared (first use this function)
creature.cpp:473: error: (Each undeclared identifier is reported only once for each function it appears in.)

make.exe: *** [creature.o] Error 1

Ausführung beendet


creature.cpp: In member function `virtual void Creature::eek:nDeath()':
creature.cpp:473: error: `creature' undeclared (first use this function)
creature.cpp:473: error: (Each undeclared identifier is reported only once for each function it appears in.)


Hope someone can help me out!
 
Last edited:
Well Im Gettin This Errors :confused:
Code:
 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp In member function `void Game::changeSkull(Player*, Skulls_t)': 
3943 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp 'class Tile' has no member named 'hasFlags' 
H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp In member function `bool Game::loadCombatZones()': 
4481 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp `doc' undeclared (first use this function) 
  (Each undeclared identifier is reported only once for each function it appears in.) 
 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\Makefile.win [Build Error]  [game.o] Error 1
 
Well Im Gettin This Errors :confused:
Code:
 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp In member function `void Game::changeSkull(Player*, Skulls_t)': 
3943 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp 'class Tile' has no member named 'hasFlags' 
H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp In member function `bool Game::loadCombatZones()': 
4481 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\game.cpp `doc' undeclared (first use this function) 
  (Each undeclared identifier is reported only once for each function it appears in.) 
 H:\Documents and Settings\Administrator\Desktop\Source\forgottenserver\Makefile.win [Build Error]  [game.o] Error 1
fixed the first error, typo :p.
No clue about the second error, some problem with my zones code...
 
If i want to compile this i get this error.

./creature.cpp: In member function `virtual void Creature:nDeath()':
./creature.cpp:468: error: `creature' undeclared (first use this function)
./creature.cpp:468: error: (Each undeclared identifier is reported only once for each function it appears in.)

make.exe: ** [./creature.o] Error 1

I'm use TFS 0.28
 
Now i get a another error

./game.cpp In member function `bool Game::loadCombatZones()':
Line 4366 ./game.cpp `DATA_DIRECTORY' is not a member of `ConfigManager'

Makefile.win [Build Error] [game.o] Error 1
 
change it to something like this line: xmlDocPtr doc = xmlParseFile("data/XML/pvpzones.xml");

PVP Zone not Arena?!?!
 
I've i replace
xmlDocPtr doc = xmlParseFile("data/XML/pvpzones.xml");

I get this error.

eroornb1.jpg
 
Last edited:
Now i get a another error
TFS is missing some config stuff then. Stupid TFS... just replace g_config.getString(ConfigManager::DATA_DIRECTORY) with std::string("data") ;)
and next time post in the proper thread. >_>

change it to something like this line: xmlDocPtr doc = xmlParseFile("data/XML/pvpzones.xml");

PVP Zone not Arena?!?!
Again, he posted in the wrong thread like a fool.

I've i replace

I get this error.

eroornb1.jpg
do as I said above.
 
Fully TFS-compatible and working code of PVP ARENAS.
It is dependable on pvp zones - click!.

1. Open creature.cpp, and find [in onDeath function]:
Code:
	if(getMaster())
		getMaster()->removeSummon(this);
replace it with:
Code:
	#ifdef __PVP_ARENA__ //Modified  by Elf
	Tile* tile = getTile();
	if(tile->pvparena)
	{
		if(hasMaster())
			getMaster()->removeSummon(this);
	}
	else
	{
	#endif //__PVP_ARENA__
	if(getMaster())
		getMaster()->removeSummon(this);
	#ifdef __PVP_ARENA__ //Modified  by Elf
	}
	#endif //__PVP_ARENA__
Find [in dropcorpse function]:
Code:
	g_game.removeCreature(this, false);
replace it with:
Code:
	#ifdef __PVP_ARENA__ //Modified  by Elf
	if(tile->pvparena)
	{
		tile->pvparena->removeCreature(this, true);
	}
	else
	{
	#endif //__PVP_ARENA__
	g_game.removeCreature(this, false);
	#ifdef __PVP_ARENA__ //Modified  by Elf
	}
	#endif //__PVP_ARENA__
Save and close the file.
2. Open game.cpp, and find:
Code:
	int32_t newStackPos = creature->getParent()->__getIndexOfThing(creature);
	creature->getParent()->postAddNotification(creature, newStackPos);
add after it:
Code:
	#ifdef __PVP_ARENA__
	if(PvPArena* pvparena = creature->getTile()->pvparena)
	{
		pvparena->addCreature(creature, true);
    }
	#endif //__PVP_ARENA__
Find [in changeSkull function]:
Code:
	if(getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;
replace it with:
Code:
	#ifdef __PVP_ARENA__
	if(player->getTile()->hasFlag(TILESTATE_NOSKULLS) || getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;
	#else
	if(getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;
	#endif //__PVP_ARENA__
Save and close the file.
3. Open tile.cpp and find:
Code:
ReturnValue Tile::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
	uint32_t flags) const
{
add after it:
Code:
	#ifdef __PVP_ARENA__
	if(pvparena)
	{
	    if(!pvparena->canAdd(thing))
	        return RET_NOTPOSSIBLE;
    }
	#endif //__PVP_ARENA__
Find:
Code:
void Tile::__addThing(int32_t index, Thing* thing)
{
	Creature* creature = thing->getCreature();
	if(creature){
add after it:
Code:
		#ifdef __PVP_ARENA__
        if(pvparena != creature->getParent()->getTile()->pvparena)
		{
		   if(pvparena)
		       pvparena->addCreature(creature);
           if(PvPArena* p = creature->getParent()->getTile()->pvparena)
               p->removeCreature(creature, false);
        }
		#endif //__PVP_ARENA__
Save and close the file.
4. Open tile.h, and find:
Code:
class Creature;
class Teleport;
class TrashHolder;
class Mailbox;
class MagicField;
class BedItem;
add after it:
Code:
#ifdef __PVP_ARENA__
#include "pvparena.h"
class PvPArena;
#endif //__PVP_ARENA__
Find:
Code:
Code:
	#ifdef __PVP_ZONES__
	,
	TILESTATE_PVPENFORCEDZONE = [color=red]XXX[/color]
	#endif //__PVP_ZONES__
(where XXX is value set while doing combat zones) add after it:
Code:
	#ifdef __PVP_ARENA__
	,
	TILESTATE_NOSKULLS = [color=blue]YYY[/color]
	#endif //__PVP_ARENA__
and replace the YYY with last XXX * 2.
(Eg. If XXXX was 8192, then Your YYYY value will be 16384. Else, if it was 16384, then Your value will be 32768).
Still in tile.h, find:
Code:
			thingCount = 0;
			m_flags = 0;
			ground = NULL;
add after it:
Code:
			#ifdef __PVP_ARENA__
			pvparena = NULL;
			#endif //__PVP_ARENA__
Find:
Code:
		Item* ground;
		ItemVector topItems;
		CreatureVector creatures;
		ItemVector downItems;
add after it:
Code:
		#ifdef __PVP_ARENA__
		PvPArena* pvparena;
		#endif //__PVP_ARENA__
Save and close the file.
5. Open player.cpp, and find:
Code:
if(!Combat::isInPvpZone(this, targetPlayer) &&
!targetPlayer->hasAttacked(this) &&
targetPlayer->getSkull() == SKULL_NONE)
{
replace it with:
Code:
			if(!Combat::isInPvpZone(this, targetPlayer) &&
				!targetPlayer->hasAttacked(this) &&
				targetPlayer->getSkull() == SKULL_NONE
				#ifdef __PVP_ARENA__
				&& !getTile()->hasFlag(TILESTATE_NOSKULLS)
				#endif //__PVP_ARENA__
				)
			{
Save and close the file.
6. Open otserv.cpp, and find:
Code:
	#ifdef __PVP_ZONES__
	std::cout << ">> Loading PVP zones" << std::endl;
	#ifndef __CONSOLE__
	SendMessage(gui.statusBar, WM_SETTEXT, 0, (LPARAM)">> Loading PVP zones");
	#endif
	g_game.loadCombatZones();
	#endif //__PVP_ZONES__
add after it:
Code:
	#ifdef __PVP_ARENA__
	std::cout << ">> Loading PVP arenas" << std::endl;
	#ifndef __CONSOLE__
	SendMessage(gui.statusBar, WM_SETTEXT, 0, (LPARAM)">> Loading PVP arenas");
	#endif
	PvPArena::loadArenas();
	#endif //__PVP_ARENA__
Save and close the file.
7. Create new file named 'pvparena.cpp', open it, and paste:
Code:
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// otserv main. The only place where things get instantiated.
//////////////////////////////////////////////////////////////////////
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#ifdef __PVP_ARENA__

#include "pvparena.h"
#include "player.h"
#include "configmanager.h"
extern ConfigManager g_config;

#include "game.h"
extern Game g_game;

#include "tools.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

PvPArena::PvPArena()
{
    exitPos = Position(0, 0, 7);
    flags = 0;
    arenaMembers.clear();
}

PvPArena::~PvPArena()
{
    arenaMembers.clear();
}

bool PvPArena::canAdd(const Thing* thing)
{
    if(!thing)
         return false;
    
    if(const Creature* creature = thing->getCreature())
    {
         if(!creature->isAttackable())
              return true;
         if(flags & ARENA_FLAG_NOSUMMONS && creature->getMonster() != NULL)
              return false;
         else if(!(flags & ARENA_FLAG_MULTICOMBAT) && arenaMembers.size() > 2 && creature->getPlayer())
         {
              std::list<Creature*>::iterator cit = std::find(arenaMembers.begin(), arenaMembers.end(), creature);
              if(cit == arenaMembers.end())
                  return false;
         }
    }
    else if(const Item* item = thing->getItem())
    {
         if(!(flags & ARENA_FLAG_NO_FIELDS) && item->isMagicField())
              return false;
    }
    return true;
}


bool PvPArena::loadArenas()
{
     //system("PAUSE");
     std::string filename = "data/XML/pvparenas.xml";
     xmlDocPtr doc = xmlParseFile(filename.c_str());
     if(!doc)
         return false;
     
     xmlNodePtr root, arenanode, tilenode;
     root = xmlDocGetRootElement(doc);
	 if(xmlStrcmp(root->name,(const xmlChar*)"pvparenas") != 0){
		xmlFreeDoc(doc);
		return false;
	 }
	 
	 arenanode = root->children;
	 while (arenanode){
         if(xmlStrcmp(arenanode->name,(const xmlChar*)"pvparena") == 0)
         {
             PvPArena* newArena = new PvPArena();
             int x, y, z;
             if(readXMLInteger(arenanode,"exitx",x) && 
                readXMLInteger(arenanode,"exity",y) && 
                readXMLInteger(arenanode,"exitz",z))
              {
                  newArena->exitPos = Position(x, y, z);
              }
              else
              {
                  puts("ERROR: Missing/incomplete exit pos for pvparena! Skipping...");
                  delete newArena;
                  arenanode = arenanode->next;
                  continue;
              }
              std::string strValue;
              int intValue;
              if(readXMLString(arenanode,"allowsummons",strValue) && strValue == "no")
                  newArena->flags |= ARENA_FLAG_NOSUMMONS;
              if(readXMLString(arenanode,"multi-combat",strValue) && strValue == "yes")
                  newArena->flags |= ARENA_FLAG_MULTICOMBAT;
              if(readXMLString(arenanode,"allowfields",strValue) && strValue == "no")
                  newArena->flags |= ARENA_FLAG_NO_FIELDS;
              tilenode = arenanode->children;
              while(tilenode)
              {
                  if(xmlStrcmp(tilenode->name,(const xmlChar*)"tiles") == 0)
                  {
                       int tox, toy, toz;
                       int fromx, fromy, fromz;
                       if(readXMLInteger(tilenode,"tox",tox) &&
                          readXMLInteger(tilenode,"toy",toy) &&
                          readXMLInteger(tilenode,"toz",toz) &&
                          readXMLInteger(tilenode,"fromx",fromx) &&
                          readXMLInteger(tilenode,"fromy",fromy) &&
                          readXMLInteger(tilenode,"fromz",fromz))
                        {
                            if(tox < fromx)
                               std::swap(tox, fromx);
                            if(toy < fromy)
                               std::swap(toy, fromy);
                            if(toz < fromz)
                               std::swap(toz, fromz);
                            for(int dx = fromx; dx <= tox; dx++)
                            {
                               for(int dy = fromy; dy <= toy; dy++)
                               {
                                   for(int dz = fromz; dz <= toz; dz++)
                                   {
                                       if(Tile* t = g_game.getTile(dx, dy, dz))
                                       {
                                            t->pvparena = newArena;
                                            t->setFlag(TILESTATE_PVPZONE);
                                            t->setFlag(TILESTATE_NOSKULLS);
                                       }
                                   }
                               }
                            }
                        }
                        else
                            puts("ERROR: incomplete tile range! Skipping...");
                  }
                  tilenode = tilenode->next;
              }
         }
         arenanode = arenanode->next;
     }
     xmlFreeDoc(doc);
     return true;
	 
}

void PvPArena::removeCreature(Creature* cr, bool death)
{
     if(!cr)
        return;
     if(!cr->isAttackable())
        return;
     
     std::list<Creature*>::iterator cit = std::find(arenaMembers.begin(), arenaMembers.end(), cr);
     if(cit != arenaMembers.end())
         arenaMembers.erase(cit);
     if(death)
     {
         if(Player* pr = cr->getPlayer())
         {
              if(g_game.internalTeleport(cr, exitPos, false) == RET_NOERROR)
                   g_game.addMagicEffect(exitPos, NM_ME_ENERGY_AREA);
              pr->changeHealth(pr->getMaxHealth());
         }
         else
         {
              g_game.removeCreature(cr);
         }
     }
}

void PvPArena::addCreature(Creature* cr, bool isLogin)
{
     if(!cr)
          return;
     if(!cr->isAttackable())
          return;
     // cant login on a pvp arena
     if(isLogin && cr->getPlayer())
     {
          if(g_game.internalTeleport(cr, cr->getMasterPos(), false) == RET_NOERROR)
          {
              g_game.addMagicEffect(cr->getMasterPos(), NM_ME_ENERGY_AREA);
              return;
          }
     }
     arenaMembers.push_back(cr);
}


#endif //__PVP_ARENA__
Remember to leave empty line and end of file.
Save and close the file.
8. Create new file named 'pvparena.h', open it, and paste:
Code:
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// otserv main. The only place where things get instantiated.
//////////////////////////////////////////////////////////////////////
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#ifdef __PVP_ARENA__
#ifndef __PVP_ARENA_H__
#define __PVP_ARENA_H__


#include "tile.h"
#include "position.h"
#include <list>

enum PvPArenaFlags_t
{
     ARENA_FLAG_NONE = 0,
     ARENA_FLAG_NOSUMMONS = 2,
     ARENA_FLAG_MULTICOMBAT = 4,
     ARENA_FLAG_NO_FIELDS = 8,
};
     

class PvPArena
{
    public:
       PvPArena();
       ~PvPArena();
       
       int flags;
       
       Position exitPos;
       
       virtual bool canAdd(const Thing*);
       std::list<Creature*> arenaMembers;
       
       static bool loadArenas();
       
       void removeCreature(Creature* cr,  bool death = false);
       void addCreature(Creature* cr, bool isLogin = false);
};

#endif //__PVP_ARENA_H__
#endif //__PVP_ARENA__
Remember to leave empty line and end of file.
Save and close the file.

9. Now add -D__PVP_ARENA__ to C++ compiler paramaters (for *nix, edit Makefile and add to FLAGS) and compile the server.

10. Usage:
Arenas are stored in data/XML/pvparenas.xml instead of data/pvparena.xml.
For more, read this link.


######### All credits go to Nate, for impressive piece of code. #########​
(@ I would be thankfull, if You would mention about it somewhere)
 
Last edited:
Great! but i wish it work.
i made the cords. but it doesn't make it pvp arena
 
Thank you ;)
works perfectly on the tfs newest release :)
except the message when u die in arena: you were downgraded from lvl to lvl. But its easy to fix
 
i newest version of tfs i cant find this:
Code:
Find [in changeSkull function]:
Code:

	if(getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;

replace it with:
Code:

	#ifdef __PVP_ARENA__
	if(player->getTile()->hasFlag(TILESTATE_NOSKULLS) || getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;
	#else
	if(getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;
	#endif //__PVP_ARENA__
 
hmmm whats this pvp script about?
 
Back
Top