[Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

Page 144 of 147 FirstFirst ... 4494134136137138139140141142143144145146147 LastLast
Results 3,576 to 3,600 of 3658
  1. #3576
    HITMAN CAPITOL is offline
    MemberRank
    Apr 2013 Join Date
    PhilippinesLocation
    717Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    SmileYzn, Compiled the sources from GitHub in VS 2013 but had errors and warnings. Do you have skype?

  2. #3577
    Evolution Team Th3AnG3L is offline
    MemberRank
    Apr 2014 Join Date
    634Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Source code : vs2010
    https://mega.nz/#!XZF3SLRb!rYfa0dxnj...1CADFGKvY-d2YI

    Known bugs:
    - Offtrade cant login account
    - CallCharacter
    - Some offsets make it crash
    - T Button dupe hole
    - and configurations
    - Custom Wings are unfinished
    so you need to make it yourself this steps i give info

  3. #3578
    Enthusiast erikgaston is offline
    MemberRank
    Jul 2015 Join Date
    35Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    repairing:
    -Call Character
    -News Event (the disabled in commonserver and keep coming).
    please: D

  4. #3579
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Do not run the command (/banpost /banacc /banchar ) Please tell me the solution

  5. #3580
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    When you enter these commands the server does not respond. Help me please.... (((((

  6. #3581
    Don't be afraid to ask! RevolGaming is offline
    MemberRank
    Jun 2012 Join Date
    1,458Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    maybe check the logs... have you got permission to use the commands? .... etc...

  7. #3582
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    All teams are allowed. Rights exhibited.
    Team /gmove will teleport himself only.
    On the other commands the server is not responding. for example /banacc /banchar /banpost
    The logs are no errors

    10-15-17-34-06-a10-15-17-32-04-a10-15-17-34-06-a10-15-17-32-04-a

    - - - Updated - - -

    I apologize in advance. I am writing through an interpreter

    - - - Updated - - -

    HEEEELP ME PLEASE!!!!
    Attached Thumbnails Attached Thumbnails 10-15-17-31-02-a  

  8. #3583
    HITMAN CAPITOL is offline
    MemberRank
    Apr 2013 Join Date
    PhilippinesLocation
    717Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Try putting the name of the character in the Whisper slot chatbox

  9. #3584
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Command /setpk Nickname <pklvl> | /gmove NickName <map> <x> <y> | /status | /banpost | /banacc | /banchar | and NickName (PM) Does not work. The server does not see them!!!!!!!!!!

    - - - Updated - - -

    Does not work 10-15-22-08-00-a

  10. #3585
    Enthusiast erikgaston is offline
    MemberRank
    Jul 2015 Join Date
    35Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    32767 have stat, and took away the yetis 2000 O.o.
    the calcharacter although you will go down and go up the numbers as usual.

  11. #3586
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    It can not be that even one person can not help solve the problem (

  12. #3587
    Enthusiast erikgaston is offline
    MemberRank
    Jul 2015 Join Date
    35Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    GSCs malfunctions.
    if you go to Valley of Loren Crywolf or disconnects users.
    if you put a power in these map gameserver crash, disconnects all users

  13. #3588
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    please help fix the team playing the wizard. I do not where to ask for help.

  14. #3589
    HITMAN CAPITOL is offline
    MemberRank
    Apr 2013 Join Date
    PhilippinesLocation
    717Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    SmileYzn
    Tested your source and found a problem on the Duel, after scoring 1 the duel suddenly declared a winner. Thanks

  15. #3590
    Evolution Team Th3AnG3L is offline
    MemberRank
    Apr 2014 Join Date
    634Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Quote Originally Posted by CAPITOL View Post
    SmileYzn
    Tested your source and found a problem on the Duel, after scoring 1 the duel suddenly declared a winner. Thanks
    and you got teleported to 0,0,0 ;d

  16. #3591
    Apprentice Smerch196011 is offline
    MemberRank
    Oct 2015 Join Date
    12Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Honorable SmileYzn spit on these files, asking for his help, he said, that just puts the server, but does not support. Hence the server completely into bugs and help to fix them, he does not want to. Conclusion - no one wants to help people.

  17. #3592
    Evolution Team Th3AnG3L is offline
    MemberRank
    Apr 2014 Join Date
    634Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    and why you think of that he doesnt help people?
    i must say that smiley is much more good person than others here.
    and this source i had posted in previous page, yes it has some bugs more but you can continued it and fix it. Or try create something if there is error post here and will help you.

  18. #3593
    #ChangeBrazil SmileYzn is offline
    MemberRank
    Nov 2012 Join Date
    0x00401000Location
    927Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Quote Originally Posted by Smerch196011 View Post
    Honorable SmileYzn spit on these files, asking for his help, he said, that just puts the server, but does not support. Hence the server completely into bugs and help to fix them, he does not want to. Conclusion - no one wants to help people.
    when i have used ia julia sources to fix it, nobody offers properly support.
    This is not my files dude i only take fixes and post here.

    Try to do this simple fixes using your brain not mine.

    Ps. For move after duel, try to change the terrain file, i guess that is corrupted.

  19. #3594
    cMuServices™ L1ron is offline
    MemberRank
    Jun 2014 Join Date
    315Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Quote Originally Posted by CAPITOL View Post
    SmileYzn
    Tested your source and found a problem on the Duel, after scoring 1 the duel suddenly declared a winner. Thanks
    Quote Originally Posted by Th3AnG3L View Post
    and you got teleported to 0,0,0 ;d
    Quote Originally Posted by SmileYzn View Post
    when i have used ia julia sources to fix it, nobody offers properly support.
    This is not my files dude i only take fixes and post here.

    Try to do this simple fixes using your brain not mine.

    Ps. For move after duel, try to change the terrain file, i guess that is corrupted.
    problem at Duel System Configs , Fix this :) at my files it already fixed :)
    Hey Cleverson @SmileYzn

    Att, Liron

  20. #3595
    HITMAN CAPITOL is offline
    MemberRank
    Apr 2013 Join Date
    PhilippinesLocation
    717Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    SmileYzn

    Your files were great, some fixes is available on other sources that's why I manage to make the Duel System work. Thanks

  21. #3596
    Evolution Team Th3AnG3L is offline
    MemberRank
    Apr 2014 Join Date
    634Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Quote Originally Posted by CAPITOL View Post
    SmileYzn

    Your files were great, some fixes is available on other sources that's why I manage to make the Duel System work. Thanks
    you mean from the first post source

  22. #3597
    Enthusiast erikgaston is offline
    MemberRank
    Jul 2015 Join Date
    35Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    bug fix duel? help?

  23. #3598
    cMuServices™ L1ron is offline
    MemberRank
    Jun 2014 Join Date
    315Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Quote Originally Posted by erikgaston View Post
    bug fix duel? help?
    send message at skype - liron.e1

  24. #3599
    Evolution Team Th3AnG3L is offline
    MemberRank
    Apr 2014 Join Date
    634Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    Duel.cpp
    Code:
    // ================================================== //
    // #			GameServer 1.00.90					# //
    // #			Imagination Arts					# //
    // #			Julia Project 1.1.x					# //
    // ================================================== //
    // #	http://imaginationarts.net/forum/			# //
    // #	http://mu.raklion.ru/						# //
    // ================================================== //
    
    
    #include "StdAfx.h"  
    #include "Configs.h"
    #ifdef _GS
    #include "DuelManager.h"
    #include "User.h" 
    #include "Utilits.h"
    #include "Logger.h"
    #include "ChatCommands.h"
    #include "Query.h"
    
    
    // ----------------------------------------------------------------------------------------------------------------
    cDuelSystem DuelSystem;
    // ----------------------------------------------------------------------------------------------------------------
    static const struct DUEL_GATES
    {
    	int Gate01;
    	int Gate02;
    	int SeparatorGate;
    } 
    // ----------------------------------------------------------------------------------------------------------------
    
    
    g_DuelGates[MAX_DUEL_ROOMS] =
    {
    	{295, 296, 303},
    	{297, 298, 304},
    	{299, 300, 305},
    	{301, 302, 306}
    };
    // ----------------------------------------------------------------------------------------------------------------
    
    
    cDuelSystem::cDuelSystem(void)
    {
    	ZeroMemory(&this->g_DuelRooms, sizeof(this->g_DuelRooms));
    	// ----
    	for(short i = 0; i < MAX_DUEL_ROOMS; ++i) 
    	{
    		this->g_DuelRooms[i].RoomFree	 = true;
    		this->g_DuelRooms[i].DuelWaiting = false;
    		this->g_DuelRooms[i].szWinner	 = false;
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    
    
    cDuelSystem::~cDuelSystem(void)
    {
    	// ----
    }
    
    
    void cDuelSystem::Load()
    {		  			   
    	Config.Enabled					= Configs.GetInt(0, 1,					1,		"DuelManager",	"DuelEnabled",					ServerCommon);  
    	if(!Config.Enabled)return;
    	Config.Ranking					= Configs.GetInt(0, 1,					0,		"DuelManager",	"DuelRanking",					ServerCommon);
    	Config.Logging					= Configs.GetInt(0, 1,					1,		"DuelManager",	"DuelLogging",					ServerCommon);
    	Config.DuelGate					= Configs.GetInt(0, 65535,				294,	"DuelManager",  "DuelOutGate",					ServerCommon);
    }
    
    
    // ----------------------------------------------------------------------------------------------------------------
    //## Находим игроков в руме
    int cDuelSystem::GetUserDuelRoom(LPOBJ lpObj)
    {
    	for(short i = 0; i < MAX_DUEL_ROOMS; ++i)
    	{
    		if(this->g_DuelRooms[i].szlpObjOne == lpObj || this->g_DuelRooms[i].szlpObjTy == lpObj) 
    		{
    			return i;
    		}
    	}
    	return -1;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Глобальная функция
    void cDuelSystem::Run()
    {
    	for(short i = 0; i < MAX_DUEL_ROOMS; ++i)
    	{
    		if(this->g_DuelRooms[i].RoomFree == FALSE)
    		{
    			if(GetTickCount() - this->g_DuelRooms[i].dwStartTime < 5000)
    			{
    				continue;
    			}
    			// ----
    			for(short u = 0; u < MAX_DUEL_SEPARATORS; u++)
    			{
    				if(this->g_DuelRooms[i].szSeparators[u] == NULL)
    				{
    					continue;
    				}
    				// ----
    				if(Utilits.gObjIsConnected(this->g_DuelRooms[i].szSeparators[u]->m_Index))
    				{
    					// ----
    					if(this->g_DuelRooms[i].szSeparators[u]->MapNumber != 0x40)
    					{
    						this->SendEndDuel(this->g_DuelRooms[i].szSeparators[u]);
    						// ----
    						AddBuff(this->g_DuelRooms[i].szSeparators[u], 18, 0, 0, 0, 0, 1);
    						// ----
    						gObjViewportListProtocolCreate(this->g_DuelRooms[i].szSeparators[u]);
    						// ----
    						GCStateInfoSendg(this->g_DuelRooms[i].szSeparators[u], 0, 98);
    						// ----
    
    
    						if(Config.Logging)
    						{
    							Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Spectator [%s] Leave [%d] Room", 
    								this->g_DuelRooms[i].szSeparators[u]->Name, i + 1);
    						}				
    						// ----
    						this->SendSpectatorRemove(u, i);
    						// ----
    						this->g_DuelRooms[i].szSeparators[u] = NULL;
    					}
    				}
    				else
    				{
    					if(Config.Logging)
    					{
    						Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Spectator Leave Room [%d]", i + 1);
    					}
    					// ----
    					this->g_DuelRooms[i].szSeparators[u] = NULL;
    					// ----
    					this->SendSpectatorList(i);
    				}
    				SendSpectatorList(i);
    			}
    			// ----
    			if(this->g_DuelRooms[i].szlpObjOne != NULL || this->g_DuelRooms[i].szlpObjTy != NULL)
    			{
    				if(Utilits.gObjIsConnected(this->g_DuelRooms[i].szlpObjOne->m_Index) == FALSE || 
    					Utilits.gObjIsConnected(this->g_DuelRooms[i].szlpObjTy->m_Index)  == FALSE )
    				{
    					this->RoomReset(i);
    					continue;
    				}
    				// ----
    				else if((this->g_DuelRooms[i].szlpObjOne->MapNumber != 0x40 ||
    					this->g_DuelRooms[i].szlpObjTy->MapNumber  != 0x40) && 
    					this->g_DuelRooms[i].szWinner == FALSE)
    				{
    					this->RoomReset(i);
    					continue;
    				}
    				// ----
    				else if(this->g_DuelRooms[i].szlpObjOne->Connected < PLAYER_PLAYING ||
    					this->g_DuelRooms[i].szlpObjTy->Connected  < PLAYER_PLAYING)
    				{
    					this->RoomReset(i);
    					continue;
    				}
    			}
    			// ----
    			else
    			{
    				this->RoomReset(i);
    				continue;
    			}
    			// ----
    			if(this->UpdateLifebarTime < GetTickCount())
    			{
    				this->SendLifebarStatus(i);
    				this->UpdateLifebarTime = GetTickCount() + 2000;
    			}
    			// ----
    			if(this->g_DuelRooms[i].dwTicketCount != 0)
    			{
    				if(this->g_DuelRooms[i].dwTicketCount < GetTickCount())
    				{
    					this->RoomReset(i);
    					// ---
    					if(Config.Logging)
    					{
    						Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Room [%d] Cleaned", i + 1);
    					}
    				}
    			}
    			// ----
    			if(this->g_DuelRooms[i].RoomFree == FALSE && this->g_DuelRooms[i].DuelWaiting == FALSE && 
    				this->g_DuelRooms[i].szWinner == FALSE)
    			{
    				for(short s = 0; s < MAX_DUEL_SEPARATORS; s++)
    				{
    					if(this->g_DuelRooms[i].szSeparators[s] != NULL)
    					{
    						if(AddTab[this->g_DuelRooms[i].szSeparators[s]->m_Index].DUEL_SpecVisible == 1)
    						{
    							AddBuff(this->g_DuelRooms[i].szSeparators[s], 18, 0, 0, 0, 0, -10);
    							// ----
    							gObjViewportListProtocolDestroy(this->g_DuelRooms[i].szSeparators[s]);
    							// ----
    							if(Config.Logging)
    							{
    								Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System]Character [%s] Added Invisible", 
    									this->g_DuelRooms[i].szSeparators[s]->Name);
    							}
    							// ----
    							AddTab[this->g_DuelRooms[i].szSeparators[s]->m_Index].DUEL_SpecVisible = 0;
    						}
    					}
    				}
    			}
    		}
    	}
    	// ----
    	for(short n = 0; n < MAX_DUEL_ROOMS; n++)
    	{
    		if(this->g_DuelRooms[n].DuelWaiting == TRUE)
    		{
    			if(Utilits.gObjIsConnected(this->g_DuelRooms[n].szlpObjOne->m_Index) == FALSE || 
    				Utilits.gObjIsConnected(this->g_DuelRooms[n].szlpObjTy->m_Index)  == FALSE )
    			{
    				this->RoomReset(n);
    				continue;
    			}
    			// ----
    			else if(this->g_DuelRooms[n].szlpObjOne->Connected < PLAYER_PLAYING ||
    				this->g_DuelRooms[n].szlpObjTy->Connected  < PLAYER_PLAYING)
    			{
    				this->RoomReset(n);
    				continue;
    			}
    		}
    	}
    	// ----
    	if(this->UpdateTickCount < GetTickCount())
    	{
    		for(short i = 8000; i < OBJECT_MAX; ++i)
    		{
    			LPOBJ lpObj    = (LPOBJ)OBJECT_POINTER(i);
    			// ----
    			if((lpObj->m_IfState.use) && lpObj->m_IfState.type == 20)
    			{
    				this->SendDuelStatus(lpObj);
    			}
    		}
    		this->UpdateTickCount = GetTickCount() + 6000;
    	}
    	return;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Обновляем Результаты дуэля;
    void cDuelSystem::UpdateDuelScore(short iRoom)
    { 
    	if(iRoom < 0 || iRoom > MAX_DUEL_ROOMS - 1)
    	{
    		return;
    	}
    	// ----
    	int aIndex = this->g_DuelRooms[iRoom].szlpObjOne->m_Index;
    	int uIndex = this->g_DuelRooms[iRoom].szlpObjTy->m_Index;
    	// ----
    	PMSG_DUEL_SCORE pMsg;
    	// ----
    	pMsg.h.c			= 0xC1;
    	pMsg.h.size			= sizeof(pMsg);
    	pMsg.h.headcode		= 0xAA;
    	pMsg.h.subcode		= 0x04;
    	pMsg.NumberH1		= SET_NUMBERH(aIndex);
    	pMsg.NumberL1		= SET_NUMBERL(aIndex);
    	pMsg.NumberH2		= SET_NUMBERH(uIndex);
    	pMsg.NumberL2		= SET_NUMBERL(uIndex);
    	pMsg.btDuelScore1	= this->g_DuelRooms[iRoom].szPointsOne;
    	pMsg.btDuelScore2	= this->g_DuelRooms[iRoom].szPointsTy;
    	LPOBJ gObj     = (LPOBJ)OBJECT_POINTER(aIndex);
    	LPOBJ lpObj    = (LPOBJ)OBJECT_POINTER(uIndex);
    	// ----
    	if(Config.Logging)
    	{
    		Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Room [%d] Results [%s][%s] VS [%s][%s] Rank [%d] : [%d]", 
    			iRoom + 1, gObj->AccountID, gObj->Name, lpObj->AccountID, lpObj->Name,
    			g_DuelRooms[iRoom].szPointsOne, g_DuelRooms[iRoom].szPointsTy);
    	}
    	// ----
    	if(g_DuelRooms[iRoom].szPointsOne >= MAX_DUEL_WIN_POINTS)
    	{
    		if(Config.Ranking)
    		{
    			SaveDuel(gObj->AccountID, gObj->Name, lpObj->AccountID,lpObj->Name,
    				g_DuelRooms[iRoom].szPointsOne, g_DuelRooms[iRoom].szPointsTy);
    		}	   			
    	}
    	// ----
    	if(g_DuelRooms[iRoom].szPointsTy >= MAX_DUEL_WIN_POINTS)
    	{
    		if(Config.Ranking)
    		{
    			SaveDuel(lpObj->AccountID, lpObj->Name, gObj->AccountID, gObj->Name,
    				g_DuelRooms[iRoom].szPointsTy, g_DuelRooms[iRoom].szPointsOne);
    		}
    	}
    	// ----
    	DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
    	DataSend(uIndex, (LPBYTE)&pMsg, pMsg.h.size);
    	// ----
    	for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    	{
    		if(this->g_DuelRooms[iRoom].szSeparators[i] == NULL) 
    		{
    			continue;
    		}
    		DataSend(this->g_DuelRooms[iRoom].szSeparators[i]->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Обновляем результаты чара;
    void cDuelSystem::PlayerScore(LPOBJ lpObj)
    {
    	int iRoom = this->GetUserDuelRoom(lpObj);
    	// ----
    	if(iRoom >= 0 && iRoom < MAX_DUEL_ROOMS)
    	{
    		if(this->g_DuelRooms[iRoom].szlpObjOne->m_Index == lpObj->m_Index)
    		{
    			this->g_DuelRooms[iRoom].szPointsOne++;
    			this->UpdateDuelScore(iRoom);
    		}
    		// ----
    		else if(this->g_DuelRooms[iRoom].szlpObjTy->m_Index == lpObj->m_Index)
    		{
    			this->g_DuelRooms[iRoom].szPointsTy++;
    			this->UpdateDuelScore(iRoom);
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Пакет для конца дуэли;
    void cDuelSystem::SendEndDuel(LPOBJ lpObj)
    { 
    	if(lpObj == NULL)
    	{
    		return;
    	}
    	if(Utilits.gObjIsConnected(lpObj->m_Index) == FALSE)
    	{ 
    		return;
    	}
    	// ----
    	BYTE lpMsgClose[5] = {0xC1, 0x05, 0xAA, 0x03, 0x00};
    	// ----
    	DataSend(lpObj->m_Index, &lpMsgClose[0], lpMsgClose[1]);
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Смотрим результат Сепараторов;
    int cDuelSystem::GetSpectatorCount(short iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS) 
    	{
    		return -1;
    	}
    	// ----
    	int szCount = 0;
    	// ----
    	for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    	{
    		if(this->g_DuelRooms[iRoom].szSeparators[i] != NULL) 
    		{
    			szCount++;
    		}
    	}
    	return szCount;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Интерфейс дуэль сепараторов;
    void cDuelSystem::SendDuelStatus(LPOBJ lpObj)
    {
    	PMSG_DUEL_STATUS pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode	= 0x06;
    	// ----
    	ZeroMemory(&pMsg.pRoomStatus, sizeof(pMsg.pRoomStatus));
    	// ----
    	for(short i = 0; i < MAX_DUEL_ROOMS; ++i)
    	{
    		if(this->g_DuelRooms[i].RoomFree == FALSE)
    		{
    			if(this->g_DuelRooms[i].szlpObjOne == NULL || this->g_DuelRooms[i].szlpObjTy == NULL)
    			{
    				continue;
    			}
    			// ----
    			pMsg.pRoomStatus[i].btDuelRunning = TRUE;
    			// ----
    			int szSeparatorCount  = this->GetSpectatorCount(i);
    			// ----
    			if(szSeparatorCount < 0 || szSeparatorCount >= 10)
    			{
    				pMsg.pRoomStatus[i].btDuelOpen = FALSE;
    			}
    			// ----
    			else
    			{
    				pMsg.pRoomStatus[i].btDuelOpen = TRUE;
    			}
    			// ----
    			memcpy(&pMsg.pRoomStatus[i].szName1[0], &this->g_DuelRooms[i].szlpObjOne->Name[0], 10);
    			memcpy(&pMsg.pRoomStatus[i].szName2[0], &this->g_DuelRooms[i].szlpObjTy->Name[0], 10);
    		}
    	}
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Даём Индекс пустой румы;
    int cDuelSystem::GetFreeRoomIndex()
    {
    	for(short i = 0; i < MAX_DUEL_ROOMS; ++i)
    	{
    		if(this->g_DuelRooms[i].RoomFree == TRUE)
    		{
    			if(this->g_DuelRooms[i].DuelWaiting == FALSE)
    			{
    				return i;	
    			}
    		}
    	}
    	return -1;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Обновляем Информацию дуэли;
    void cDuelSystem::UserDuelInfoReset(LPOBJ lpObj)
    { 
    	if(lpObj == NULL) 
    	{	
    		return;
    	}
    	// ----
    	int aIndex = lpObj->m_Index;
    	AddTab[aIndex].DUEL_Room = -1;
    	lpObj->m_iDuelUser					 = -1;
    	lpObj->m_iDuelUserRequested			 = -1;
    	lpObj->m_iDuelUserReserved			 = -1;
    	lpObj->m_btDuelScore				 = 0;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Чистим руму дуэльки;
    void cDuelSystem::RoomReset(short iRoom, bool dontMove, bool dontSendEnd)
    {
    	if(this->g_DuelRooms[iRoom].szlpObjOne != NULL) //  Игрок номер 1
    	{
    		if(Utilits.gObjIsConnected(this->g_DuelRooms[iRoom].szlpObjOne->m_Index))
    		{
    			if(dontSendEnd == false)
    			{
    				this->SendEndDuel(this->g_DuelRooms[iRoom].szlpObjOne);
    			}
    			// ----
    			if(this->g_DuelRooms[iRoom].szlpObjOne->MapNumber == 0x40)
    			{
    				if(dontMove == false)
    				{
    					gObjMoveGate(this->g_DuelRooms[iRoom].szlpObjOne->m_Index, DuelSystem.Config.DuelGate);
    				}
    			}
    		}
    		// ----
    		this->UserDuelInfoReset(this->g_DuelRooms[iRoom].szlpObjOne);
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjTy != NULL)  // Игрок номер 2
    	{
    		if(Utilits.gObjIsConnected(this->g_DuelRooms[iRoom].szlpObjTy->m_Index))
    		{
    			if(dontSendEnd == false)
    			{
    				this->SendEndDuel(this->g_DuelRooms[iRoom].szlpObjTy);
    			}
    			// ----
    			if(this->g_DuelRooms[iRoom].szlpObjTy->MapNumber == 0x40)
    			{
    				if(dontMove == false)
    				{
    					gObjMoveGate(this->g_DuelRooms[iRoom].szlpObjTy->m_Index, DuelSystem.Config.DuelGate);
    				}
    			}
    		}
    		// ----
    		this->UserDuelInfoReset(this->g_DuelRooms[iRoom].szlpObjTy);
    	}
    	// ----
    	for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    	{
    		if(this->g_DuelRooms[iRoom].szSeparators[i] != NULL)
    		{
    			this->SendEndDuel(this->g_DuelRooms[iRoom].szSeparators[i]);
    			// ----
    			AddBuff(this->g_DuelRooms[iRoom].szSeparators[i], 18, 0, 0, 0, 0, 1);
    			// ----
    			gObjViewportListProtocolCreate(this->g_DuelRooms[iRoom].szSeparators[i]);
    			// ----
    			GCStateInfoSendg(this->g_DuelRooms[iRoom].szSeparators[i], 0, 98);
    			// ----
    			gObjMoveGate(this->g_DuelRooms[iRoom].szSeparators[i]->m_Index, DuelSystem.Config.DuelGate);
    		}
    		// ----
    		this->g_DuelRooms[iRoom].szSeparators[i] = NULL;
    	}
    	this->g_DuelRooms[iRoom].szlpObjOne   = NULL;
    	this->g_DuelRooms[iRoom].szPointsOne  = 0;
    	// ----
    	this->g_DuelRooms[iRoom].szlpObjTy    = NULL;
    	this->g_DuelRooms[iRoom].szPointsTy   = 0;
    	// ----
    	this->g_DuelRooms[iRoom].RoomFree	  = TRUE;
    	this->g_DuelRooms[iRoom].DuelWaiting  = FALSE;
    	this->g_DuelRooms[iRoom].szWinner	  = FALSE;
    	// ----
    	this->g_DuelRooms[iRoom].dwTicketCount= 0;
    	this->g_DuelRooms[iRoom].dwStartTime  = 0;
    	// ----
    	if(Config.Logging)
    	{
    		Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Room [%d] Has Restarted", iRoom +1);
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Табличка с Победителем и Проигравшим;
    void cDuelSystem::SendEndDuelNotification(LPOBJ lpObj, char* Winner, char* Looser)
    {
    	PMSG_DUEL_FINISH pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode	= 0x0C;
    	// ----
    	memcpy(pMsg.szWinner, Winner, 10);
    	memcpy(pMsg.szLooser, Looser, 10);
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Интерфейс сепараторов;
    void cDuelSystem::SendSpectatorAdd(short iSpecIndex, int iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(iSpecIndex < 0 || iSpecIndex >= MAX_DUEL_SEPARATORS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szSeparators[iSpecIndex] == NULL) 
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_SPEC_ADD pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode	= 0x08;
    	// ----
    	memcpy(pMsg.szName, this->g_DuelRooms[iRoom].szSeparators[iSpecIndex]->Name, 10);
    	// ----
    	for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    	{
    		if(i == iSpecIndex) 
    		{
    			continue;
    		}
    		// ----
    		if(this->g_DuelRooms[iRoom].szSeparators[i] != NULL)
    		{
    			DataSend(this->g_DuelRooms[iRoom].szSeparators[i]->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    		}
    	}
    
    
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Проверяет когда сепаратор заходит выходит;
    void cDuelSystem::SendSpectatorRemove(short iSpecIndex, int iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(iSpecIndex < 0 || iSpecIndex >= MAX_DUEL_SEPARATORS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szSeparators[iSpecIndex] == NULL)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_SPEC_ADD pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode  = 0x0A;
    	// ----
    	memcpy(pMsg.szName, this->g_DuelRooms[iRoom].szSeparators[iSpecIndex]->Name, 10);
    	// ----
    	for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    	{
    		if(i == iSpecIndex)
    		{ 
    			continue;
    		}
    		// ----
    		if(this->g_DuelRooms[iRoom].szSeparators[i] != NULL)
    		{
    			DataSend(this->g_DuelRooms[iRoom].szSeparators[i]->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Проверяем количество сепараторов
    void cDuelSystem::SendSpectatorList(short iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].RoomFree == FALSE)
    	{
    		for(short u = 0; u < MAX_DUEL_SEPARATORS; u++)
    		{
    			if(this->g_DuelRooms[iRoom].szSeparators[u] != NULL)
    			{
    				this->SendSpectatorList(this->g_DuelRooms[iRoom].szSeparators[u], iRoom);
    			}
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## сверяем с клиентом количество сепараторов;
    void cDuelSystem::SendSpectatorList(LPOBJ lpObj, int iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_SPEC_LIST pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode	= 0x0B;
    	pMsg.btCount	= 0;
    	// ----
    	if(this->g_DuelRooms[iRoom].RoomFree == FALSE)
    	{
    		for(short u = 0; u < MAX_DUEL_SEPARATORS; u++)
    		{
    			if(this->g_DuelRooms[iRoom].szSeparators[u] != NULL)
    			{
    				memcpy(&pMsg.szName[pMsg.btCount++][0], this->g_DuelRooms[iRoom].szSeparators[u]->Name, 10);
    			}
    		}
    	}
    	pMsg.h.size = 5 + (pMsg.btCount * 10);
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## показываем хп сепараторам;
    void cDuelSystem::SendLifebarStatus(short iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].RoomFree == FALSE)
    	{
    		for(short u = 0; u < MAX_DUEL_SEPARATORS; u++)
    		{
    			if(this->g_DuelRooms[iRoom].szSeparators[u] != NULL)
    			{
    				this->SendLifebarStatus(this->g_DuelRooms[iRoom].szSeparators[u], iRoom);
    			}
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## показываем хп сепараторам функция;
    void cDuelSystem::SendLifebarStatus(LPOBJ lpObj, int iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_LIFEBAR_REFILL pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode  = 0x05;
    	// ----
    	pMsg.btObjId01H = HIBYTE(this->g_DuelRooms[iRoom].szlpObjOne->m_Index);
    	pMsg.btObjId01L = LOBYTE(this->g_DuelRooms[iRoom].szlpObjOne->m_Index);
    	// ----
    	pMsg.btObjId02H = HIBYTE(this->g_DuelRooms[iRoom].szlpObjTy->m_Index);
    	pMsg.btObjId02L = LOBYTE(this->g_DuelRooms[iRoom].szlpObjTy->m_Index);
    	// ----
    	pMsg.btLife01 = (int)(this->g_DuelRooms[iRoom].szlpObjOne->Life / ((this->g_DuelRooms[iRoom].szlpObjOne->MaxLife + this->g_DuelRooms[iRoom].szlpObjOne->AddLife) / 100));
    	pMsg.btLife02 = (int)(this->g_DuelRooms[iRoom].szlpObjTy->Life / ((this->g_DuelRooms[iRoom].szlpObjTy->MaxLife + this->g_DuelRooms[iRoom].szlpObjTy->AddLife) / 100));
    	// ----
    	pMsg.btShield01 = this->g_DuelRooms[iRoom].szlpObjOne->iShield / ((this->g_DuelRooms[iRoom].szlpObjOne->iMaxShield + this->g_DuelRooms[iRoom].szlpObjOne->iAddShield) / 100);
    	pMsg.btShield02 = this->g_DuelRooms[iRoom].szlpObjTy->iShield / ((this->g_DuelRooms[iRoom].szlpObjTy->iMaxShield + this->g_DuelRooms[iRoom].szlpObjTy->iAddShield) / 100);
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    
    
    }
    
    
    // ----------------------------------------------------------------------------------------------------------------
    //## показываем хп сепараторам функция;
    void cDuelSystem::SendLifebarInit(LPOBJ lpObj, int iRoom)
    {
    	if(iRoom < 0 || iRoom >= MAX_DUEL_ROOMS)
    	{
    		return;
    	}
    	// ----
    	if(this->g_DuelRooms[iRoom].szlpObjOne == NULL || this->g_DuelRooms[iRoom].szlpObjTy == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_LIFEBAR_NAME pMsg2;
    	// ----
    	pMsg2.h.c		 = 0xC1;
    	pMsg2.h.size	 = sizeof(pMsg2);
    	pMsg2.h.headcode = 0xAA;
    	pMsg2.h.subcode  = 0x07;
    	pMsg2.Type		 = 0x00;
    	// ----
    	memcpy(pMsg2.szName1, this->g_DuelRooms[iRoom].szlpObjOne->Name, 10);
    	memcpy(pMsg2.szName2, this->g_DuelRooms[iRoom].szlpObjTy->Name, 10);
    	// ----
    	pMsg2.btObjId1H = HIBYTE(this->g_DuelRooms[iRoom].szlpObjOne->m_Index);
    	pMsg2.btObjId1L = LOBYTE(this->g_DuelRooms[iRoom].szlpObjOne->m_Index);
    	// ----
    	pMsg2.btObjId2H = HIBYTE(this->g_DuelRooms[iRoom].szlpObjTy->m_Index);
    	pMsg2.btObjId2L = LOBYTE(this->g_DuelRooms[iRoom].szlpObjTy->m_Index);
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg2, pMsg2.h.size);
    	// ----
    	PMSG_DUEL_LIFEBAR_INIT pMsg;
    	// ----
    	pMsg.h.c		= 0xC1;
    	pMsg.h.size		= sizeof(pMsg);
    	pMsg.h.headcode = 0xAA;
    	pMsg.h.subcode  = 0x0D;
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsg, pMsg.h.size);
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Процесс убиства игрока
    void cDuelSystem::KillUserProc(LPOBJ lpObj, LPOBJ lpTarget)
    { 
    	if(!this->DuelCheck(lpObj, lpTarget))
    	{
    		return;
    	}
    	// ----
    	int iDuelRoom = this->GetUserDuelRoom(lpObj);
    	// ----
    	if(iDuelRoom == -1)
    	{
    		return;
    	}
    	// ----
    	lpTarget->KillerType = 3;
    	// ----
    	int Points = ((lpObj == this->g_DuelRooms[iDuelRoom].szlpObjOne) ? this->g_DuelRooms[iDuelRoom].szPointsOne : this->g_DuelRooms[iDuelRoom].szPointsTy);
    	// ----
    	if(Points >= MAX_DUEL_WIN_POINTS)
    	{
    		this->g_DuelRooms[iDuelRoom].szWinner = TRUE;
    		// ----
    		this->SendEndDuel(lpTarget);
    		this->SendEndDuel(lpObj);
    		// ----
    		this->SendEndDuelNotification(lpTarget, lpObj->Name, lpTarget->Name);
    		this->SendEndDuelNotification(lpObj, lpObj->Name, lpTarget->Name);
    		// ----
    		char Buff[256];
    		// ----
    		wsprintf(Buff,"You emerge triumphant over %s!", lpTarget->Name);
    		GCServerMsgStringSend(Buff,lpObj->m_Index,1);
    		// ----
    		wsprintf(Buff,"%s has defeated you!",lpObj->Name);
    		GCServerMsgStringSend(Buff,lpTarget->m_Index,1);
    		// ----
    		PMSG_SERVERCMD ServerCmd;
    		// ----
    		PHeadSubSetB((LPBYTE)&ServerCmd, 0xF3, 0x40, sizeof(ServerCmd));
    		// ----
    		ServerCmd.CmdType = 0;
    		ServerCmd.X		  = (int)lpObj->X;
    		ServerCmd.Y		  = (int)lpObj->Y;
    		// ----
    		MsgSendV2(lpObj, (unsigned char *)&ServerCmd, sizeof(ServerCmd));
    		DataSend(lpObj->m_Index, (unsigned char *)&ServerCmd, sizeof(ServerCmd));
    		// ----
    		WinnerBuff(lpObj);
    		// ----
    		this->g_DuelRooms[iDuelRoom].dwTicketCount = GetTickCount() + 10000;
    		// ----
    		Chat.MessageAll(0, 0, NULL, "Duel: %s Won, %s Lose.", lpObj->Name, lpTarget->Name);
    		Log.ConsoleOutPut(1, c_Blue,t_Duel,"[Duel System] [%s][%s] Has Won Duel, Looser [%s][%s] Room [%d]",
    			lpObj->AccountID, lpObj->Name, lpTarget->AccountID, lpTarget->Name, iDuelRoom+1);
    	}
    }
    
    
    // ----------------------------------------------------------------------------------------------------------------
    //## Протокол Дуэль системы
    void cDuelSystem::DuelProtocolCore(LPOBJ lpObj, unsigned char * lpPacket)
    {
    	PMSG_DEFAULT2* pMsg = (PMSG_DEFAULT2*)lpPacket;
    	// ----
    	switch(pMsg->subcode)
    	{
    	case 0x01:
    		{
    			this->RecvDuelRequest(lpObj, (PMSG_DUEL_REQUEST_START*)lpPacket);
    		}
    		break;
    		// ----
    	case 0x02:
    		{
    			this->RecvDuelAnswer(lpObj, (PMSG_DUEL_ANSWER_START*)lpPacket);
    		}
    		break;
    		// ----
    	case 0x07:
    		{
    			this->RecvWatchRequest(lpObj, (PMSG_DUEL_REQUEST_WATCH*)lpPacket);
    		}
    		break;
    		// ----
    	case 0x09:
    		{
    			if(lpObj->MapNumber == 0x40)
    			{
    				gObjMoveGate(lpObj->m_Index, DuelSystem.Config.DuelGate);
    			}
    		}
    		break;
    		// ----
    		Run();
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## функция сепаратора для протокола
    void cDuelSystem::RecvWatchRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_WATCH* lpMsg)
    {
    	if(lpObj->m_IfState.use == 0 || lpObj->m_IfState.type != 20) 
    	{
    		return;
    	}
    	// ----
    	lpObj->m_IfState.use  = 0;
    	lpObj->m_IfState.type = 0;
    	// ----
    	if(lpMsg->btRoomIndex < MAX_DUEL_ROOMS)
    	{
    		if(this->g_DuelRooms[lpMsg->btRoomIndex].RoomFree == TRUE) 
    		{
    			GCServerMsgStringSend("Sorry, but this room is free!", lpObj->m_Index, 1);
    			return;
    		}
    		// ----
    		for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    		{
    			if(this->g_DuelRooms[lpMsg->btRoomIndex].szSeparators[i] == NULL)
    			{
    				if(gObjMoveGate(lpObj->m_Index, g_DuelGates[lpMsg->btRoomIndex].SeparatorGate))
    				{
    					this->g_DuelRooms[lpMsg->btRoomIndex].szSeparators[i] = lpObj;
    					// ----
    					this->SendSpectatorList(lpObj, lpMsg->btRoomIndex);
    					// ----
    					this->SendSpectatorList(lpMsg->btRoomIndex);
    					// ----
    					this->SendSpectatorAdd(i, lpMsg->btRoomIndex);
    					// ----
    					GCServerMsgStringSend("Please sit down and watch this duel. Have fun.", lpObj->m_Index, 1);
    					// ----
    					if(Config.Logging)
    					{
    						Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System][%s][%s] Spectator join to room: [%d]", 
    							lpObj->AccountID, lpObj->Name, lpMsg->btRoomIndex + 1);
    					}
    					// ----
    					GCStateInfoSendg(lpObj, 1, 98);
    					// ----
    					this->SendLifebarInit(lpObj, lpMsg->btRoomIndex);
    					// ----
    					this->SendLifebarStatus(lpObj, lpMsg->btRoomIndex);
    					// ----
    					this->UpdateDuelScore(lpMsg->btRoomIndex);
    					// ----
    					AddTab[lpObj->m_Index].DUEL_SpecVisible = 1;
    					// ----
    					return;
    				}
    				GCServerMsgStringSend("Failed to move to Duel Room!", lpObj->m_Index, 1);
    				return;
    			}
    		}
    		GCServerMsgStringSend("Sorry, but this room is full!", lpObj->m_Index, 1);
    		return;
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Функция для вызывания дуэли;
    void cDuelSystem::RecvDuelAnswer(LPOBJ lpObj, PMSG_DUEL_ANSWER_START* lpMsg)
    {
    	int iDuelIndex = -1;
    	// ----
    	int aIndex = lpObj->m_Index;
    	// ----
    	int iDuelRoom = AddTab[aIndex].DUEL_Room;
    	// ----
    	PMSG_DUEL_START pMsgSend;
    	// ----
    	pMsgSend.h.c		= 0xC1;
    	pMsgSend.h.headcode = 0xAA;
    	pMsgSend.h.subcode  = 0x01;
    	pMsgSend.bDuelStart = 0;
    	pMsgSend.h.size		= sizeof(pMsgSend);
    	// ----
    	LPOBJ gObjg    = (LPOBJ)OBJECT_POINTER(aIndex);
    	// ----
    	if(iDuelRoom < 0 || iDuelRoom > MAX_DUEL_ROOMS - 1) 
    	{
    		return;
    	}
    	// ----
    	if(gObjg->CloseType != -1)
    	{
    		return;
    	}
    	// ----
    	iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL); // aIndex Packet C1 XX AA
    	// ----
    	OBJECTSTRUCT *gObjs = (OBJECTSTRUCT*)OBJECT_POINTER(iDuelIndex);
    	// ----
    	if(iDuelIndex <= 7999 || lpObj->m_Index <= 7999)
    	{
    		return;
    	}
    	// ----
    	if(OBJECT_MAXRANGE(iDuelIndex))
    	{
    		if(!Utilits.gObjIsConnected(iDuelIndex))
    		{
    			return;
    		}
    		// ----
    		if(gObjs->Type == OBJECT_MONSTER)
    		{
    			return;
    		}
    		// ----
    		if(gObjs->CloseCount >= 0)
    		{
    			return;
    		}
    		// ----
    		if(lpMsg->bDuelOK)
    		{
    			if((gObjs->MapNumber >= 11 && gObjs->MapNumber <= 17) || gObjs->MapNumber == 52  || (gObjs->MapNumber >= 18 &&
    				gObjs->MapNumber <= 23) || gObjs->MapNumber == 53 ||  gObjs->MapNumber == 9 || gObjs->MapNumber == 32 || 
    				(gObjs->MapNumber >= 45 && gObjs->MapNumber <= 50))
    			{
    				GCServerMsgStringSend("Duels are not allowed in event maps.", lpObj->m_Index, 1);
    				// ----
    				this->RoomReset(iDuelRoom, true, true);
    				// ----
    				memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));
    				// ----
    				DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    				// ----
    				return;
    			}
    		}
    		// ----
    		if(OBJECT_MAXRANGE(lpObj->m_iDuelUser))
    		{
    			GCServerMsgStringSend("You are already in a Duel.", lpObj->m_Index, 1);
    			GCServerMsgStringSend("In order to issue a Duel, cancel the previous request.", lpObj->m_Index, 1);
    			// ----
    			this->RoomReset(iDuelRoom, true, true);
    			// ----
    			memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));
    			// ----
    			DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    			// ----
    			return;
    		}
    		// ----
    		if(OBJECT_MAXRANGE(lpObj->m_iDuelUserReserved))
    		{
    			GCServerMsgStringSend("You are already issuing a Duel challenge.", lpObj->m_Index, 1);
    			// ----
    			this->RoomReset(iDuelRoom, true, true);
    			// ----
    			memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));
    			// ----
    			DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    			// ----
    			return;
    		}
    		if(gObjs->m_iDuelUserReserved == lpObj->m_Index)
    		{
    			char szDuelName[MAX_ACCOUNT_LEN + 1]  = {0};
    			char szDuelName2[MAX_ACCOUNT_LEN + 1] = {0};
    			// ----
    			memcpy(szDuelName, gObjs->Name, MAX_ACCOUNT_LEN);
    			// ----
    			szDuelName[MAX_ACCOUNT_LEN] = 0;
    			// ----
    			memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);
    			// ----
    			szDuelName2[MAX_ACCOUNT_LEN] = 0;
    			// ----
    			if(!strcmp(szDuelName, szDuelName2))
    			{
    				if(lpMsg->bDuelOK == false)
    				{
    					this->RoomReset(iDuelRoom, true, true);
    					// ----
    					pMsgSend.bDuelStart = 0x0F;
    					// ----
    					memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));
    					// ----
    					DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    				}
    				// ----
    				else if (lpMsg->bDuelOK == true)
    				{
    					if(gObjMoveGate(lpObj->m_Index, g_DuelGates[iDuelRoom].Gate01) == false)
    					{
    						this->RoomReset(iDuelRoom, true, true);
    						return;
    					}
    					// ----
    					if(gObjMoveGate(iDuelIndex, g_DuelGates[iDuelRoom].Gate02) == false)
    					{
    						this->RoomReset(iDuelRoom, true, true);
    						return;
    					}
    					// ----
    					gObjs->m_iDuelUserReserved	= -1;
    					gObjs->m_btDuelScore		= 0;
    					gObjs->m_iDuelUser			= lpObj->m_Index;
    					gObjs->m_iDuelTickCount		= GetTickCount();
    					// ----
    					this->g_DuelRooms[iDuelRoom].dwStartTime	= GetTickCount();
    					this->g_DuelRooms[iDuelRoom].dwTicketCount  = GetTickCount() + (MAX_DUEL_TIME * 60000);
    					// ----
    					lpObj->m_iDuelUserRequested = -1;
    					lpObj->m_iDuelUserReserved  = -1;
    					lpObj->m_btDuelScore		= 0;
    					lpObj->m_iDuelUser			= iDuelIndex;
    					lpObj->m_iDuelTickCount		= GetTickCount();
    					// ----
    					this->g_DuelRooms[iDuelRoom].RoomFree		= FALSE;
    					this->g_DuelRooms[iDuelRoom].DuelWaiting	= FALSE;
    					this->g_DuelRooms[iDuelRoom].szWinner		= FALSE;
    					// ----
    					pMsgSend.bDuelStart		= 0;
    					pMsgSend.NumberH		= SET_NUMBERH(iDuelIndex);
    					pMsgSend.NumberL		= SET_NUMBERL(iDuelIndex);
    					// ----
    					memcpy(pMsgSend.szName, szDuelName, sizeof(pMsgSend.szName));
    					// ----
    					DataSend(lpObj->m_Index, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    					// ----
    					pMsgSend.NumberH		= SET_NUMBERH(lpObj->m_Index);
    					pMsgSend.NumberL		= SET_NUMBERL(lpObj->m_Index);
    					// ----
    					memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));
    					// ----
    					DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    					// ----
    					this->UpdateDuelScore(iDuelRoom);
    					// ----
    					Chat.MessageAllLog(0, 0, c_Cyan, t_Duel, lpObj, "Duel %s VS %s in %d Room", lpObj->Name, gObjs->Name, iDuelRoom + 1);
    
    
    					Log.ConsoleOutPut(1, c_Blue,t_Duel,"[Duel System] Duel Started [%s][%s] VS [%s][%s] on Room[%d]",
    						lpObj->AccountID, lpObj->Name, gObjs->AccountID, gObjs->Name, iDuelRoom + 1);
    				}
    			}
    			else
    			{
    				this->RoomReset(iDuelRoom);
    				DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    				return;
    			}
    		}
    		else
    		{
    			this->RoomReset(iDuelRoom);
    			DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
    			return;
    		}
    	}
    }
    
    
    // ----------------------------------------------------------------------------------------------------------------
    //## Функция Сервера для дуэль системы для клиента;
    void cDuelSystem::RecvDuelRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_START* lpMsg)
    {
    	int iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
    	// ----
    	OBJECTSTRUCT *gObjs = (OBJECTSTRUCT*)OBJECT_POINTER(iDuelIndex);
    	// ----
    	if(!OBJECT_MAXRANGE(iDuelIndex))
    	{
    		Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] [%s][%s] Try duel with NO_PLAYER object!", lpObj->AccountID, lpObj->Name);
    		return;
    	}
    	// ----
    	if(iDuelIndex == lpObj->m_Index)
    	{
    		return;
    	}
    	// ----
    	if(iDuelIndex <= 7999 || lpObj->m_Index <= 7999)
    	{
    		return;
    	}
    	// ----
    	char Buff[256];
    	// ----
    	if(lpObj->CloseType != -1)
    	{
    		return;
    	}
    	// ----
    	if(GetPrivateProfileInt("GameServerInfo", "NonPK", 0 , GS_CONFIG_FILE) == 1)
    	{
    		GCServerMsgStringSend("Dueling is not allowed in NON-PK servers.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(GetPrivateProfileInt("GameServerInfo","PkLimitFree", 1, GS_CONFIG_FILE) == 0)
    	{
    		if(lpObj->m_PK_Level >= 6)
    		{
    			GCServerMsgStringSend("An outlaw can't issue a Duel challenge.", lpObj->m_Index, 1);
    			return;
    		}
    		// ----
    		if(gObjs->m_PK_Level >= 6)
    		{
    			GCServerMsgStringSend("You cannot Duel with an Outlaw.", lpObj->m_Index, 1);
    			return;
    		}
    	}
    	// ----
    	if(OBJECT_MAXRANGE(lpObj->m_iDuelUser))
    	{
    		GCServerMsgStringSend("You are already in a Duel.", lpObj->m_Index, 1);
    		GCServerMsgStringSend("In order to issue a Duel, cancel the previous request.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(gObjs->MapNumber == 9 || gObjs->MapNumber == 32)
    	{
    		GCServerMsgStringSend("A duel is not allowed in Devil Square.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if((gObjs->MapNumber >= 11 && gObjs->MapNumber <= 17) || gObjs->MapNumber == 52)
    	{
    		GCServerMsgStringSend("You cannot Duel inside Blood Castle.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if((gObjs->MapNumber >= 18 && gObjs->MapNumber <= 23) || gObjs->MapNumber == 53)
    	{
    		GCServerMsgStringSend("Duels are not allowed within Chaos Castle.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if((gObjs->MapNumber >= 45 && gObjs->MapNumber <= 50))
    	{
    		GCServerMsgStringSend("Duels are not allowed in Illusion Temple", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(lpObj->Level < 30 || gObjs->Level < 30)
    	{
    		PMSG_DUEL_START pMsgSend;
    		// ----
    		pMsgSend.h.c		= 0xC1;
    		pMsgSend.h.headcode = 0xAA;
    		pMsgSend.h.subcode  = 0x01;
    		pMsgSend.bDuelStart = 0x0C;
    		pMsgSend.h.size		= sizeof(pMsgSend);
    		// ----
    		DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);
    		// ----
    		return;
    	}
    	// ----
    	if(lpObj->Money < 30000 || gObjs->Money < 30000)
    	{
    		PMSG_DUEL_START pMsgSend;
    		// ----
    		pMsgSend.h.c		= 0xC1;
    		pMsgSend.h.headcode = 0xAA;
    		pMsgSend.h.subcode  = 0x01;
    		pMsgSend.bDuelStart = 0x1e;
    		pMsgSend.h.size		= sizeof(pMsgSend);
    		// ----
    		DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);
    		// ----
    		return;
    	}
    	// ----
    	int iDuelRoom = this->GetFreeRoomIndex();
    	// ----
    	if(iDuelRoom == -1)
    	{
    		PMSG_DUEL_START pMsgSend;
    		// ----
    		pMsgSend.h.c		= 0xC1;
    		pMsgSend.h.headcode = 0xAA;
    		pMsgSend.h.subcode  = 0x01;
    		pMsgSend.bDuelStart = 0x10;
    		pMsgSend.h.size		= sizeof(pMsgSend);
    		// ----
    		DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);
    		// ----
    		return;
    	}
    	// ----
    	if((GetTickCount() - gObjs->m_PacketCheckTime) < 300)
    	{
    		return;
    	}
    	// ----
    	lpObj->m_PacketCheckTime = GetTickCount();
    	// ----
    	char szDuelName[MAX_ACCOUNT_LEN + 1]  = {0};
    	char szDuelName2[MAX_ACCOUNT_LEN + 1] = {0};
    	// ----
    	memcpy(szDuelName, gObjs->Name, MAX_ACCOUNT_LEN);
    	// ----
    	szDuelName[MAX_ACCOUNT_LEN]  = 0;
    	// ----
    	memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);
    	// ----
    	szDuelName2[MAX_ACCOUNT_LEN] = 0;
    	// ----
    	if(strcmp(szDuelName, szDuelName2) != 0)
    	{
    		return;
    	}
    	// ----
    	if(this->IsDuelEnable(iDuelIndex) == FALSE)
    	{
    		GCServerMsgStringSend("Your challenge to Duel has been refused.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(lpObj->lpGuild && lpObj->lpGuild->WarState == 1)
    	{
    		GCServerMsgStringSend("You cannot challenge someone to a duel while in a guild war.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(gObjs->lpGuild && gObjs->lpGuild->WarState == 1)
    	{
    		GCServerMsgStringSend("Your opponent cannot duel while in a guild war.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(Utilits.gObjIsConnected(iDuelIndex) == FALSE)
    	{
    		return;
    	}
    	// ----
    	if(gObjs->Type == OBJECT_MONSTER)
    	{
    		return;
    	}
    	// ----
    	if(gObjs->CloseCount >= 0)
    	{
    		return;
    	}
    	// ----
    	for(int n = 0; n < 5; n++)
    	{
    		if(lpObj->SelfDefense[n] >= 0 || gObjs->SelfDefense[n] >= 0)
    		{
    			GCServerMsgStringSend("Self-defense is active. You cannot Duel.", lpObj->m_Index, 1);
    			return;
    		}
    	}
    	// ----
    	if(lpObj->m_IfState.use > 0)
    	{
    		GCServerMsgStringSend("You cannot Duel while trading.", lpObj->m_Index, 1);
    		return;
    	}
    	// ----
    	if(gObjs->m_IfState.use > 0)
    	{
    		wsprintf(Buff, "%s is trading an item.", gObjs->Name);
    		// ----
    		GCServerMsgStringSend(Buff, lpObj->m_Index, 1);
    		// ----
    		return;
    	}
    	// ----
    	if(OBJECT_MAXRANGE(gObjs->m_iDuelUserRequested))
    	{
    		wsprintf(Buff,"%s has already accepted a challenge to Duel.", gObjs->Name);
    		// ----
    		GCServerMsgStringSend(Buff, lpObj->m_Index, 1);
    		// ----
    		return;
    	}
    	// ----
    	if(OBJECT_MAXRANGE(gObjs->m_iDuelUserReserved))
    	{
    		wsprintf(Buff, "%s issues a Duel challenge.", gObjs->Name);
    		// ----
    		GCServerMsgStringSend(Buff, lpObj->m_Index, 1);
    		// ----
    		return;
    	}
    	// ----
    	if(OBJECT_MAXRANGE(gObjs->m_iDuelUser))
    	{
    		wsprintf(Buff, "%s is in a Duel.", gObjs->Name);
    		// ----
    		GCServerMsgStringSend(Buff, lpObj->m_Index, 1);
    		// ----
    		return;
    	}
    	// ----
    	lpObj->m_iDuelUser						 = -1;
    	lpObj->m_iDuelUserReserved				 = iDuelIndex;
    	gObjs->m_iDuelUserRequested				 = lpObj->m_Index;
    	int aIndex								 = lpObj->m_Index;
    	// ----
    	AddTab[aIndex].DUEL_Room	 = iDuelRoom;
    	int uIndex								 = gObjs->m_Index;
    	AddTab[uIndex].DUEL_Room	 = iDuelRoom;
    	// ----
    	this->g_DuelRooms[iDuelRoom].szlpObjOne  = lpObj;
    	this->g_DuelRooms[iDuelRoom].szlpObjTy   = gObjs;
    	this->g_DuelRooms[iDuelRoom].DuelWaiting = TRUE;
    	// ----
    	PMSG_DUEL_QUESTION_START pMsg;
    	// ----
    	pMsg.h.c			= 0xC1;
    	pMsg.h.headcode		= 0xAA;
    	pMsg.h.subcode		= 0x02;
    	pMsg.h.size			= sizeof(pMsg);
    	pMsg.NumberH		= SET_NUMBERH(lpObj->m_Index);
    	pMsg.NumberL		= SET_NUMBERL(lpObj->m_Index);
    	// ----
    	memcpy(pMsg.szName, lpObj->Name, sizeof(pMsg.szName));
    	// ----
    	DataSend(iDuelIndex, (LPBYTE)&pMsg, pMsg.h.size);
    	// ----
    	wsprintf(Buff, "Challenged %s to a Duel.", gObjs->Name);
    	// ----
    	GCServerMsgStringSend(Buff, lpObj->m_Index, 1);
    	// ----
    	if(Config.Logging)
    	{
    		Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System][%s][%s] Requested to Start Duel to [%s][%s] on Room [%d]",
    			lpObj->AccountID, lpObj->Name, gObjs->AccountID, gObjs->Name, iDuelRoom + 1);
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Смотрим если дуэль в рабочем виде;
    bool cDuelSystem::IsDuelEnable(int aIndex)
    {
    	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
    	// -----
    	if(OBJECT_MAXRANGE(aIndex) == FALSE)
    	{
    		return false;
    	}
    	// ----
    	if(Utilits.gObjIsConnected(aIndex) == TRUE)
    	{
    		if((gObj->m_Option & 2) == 2)
    		{
    			return true;
    		}
    	}
    	// ----
    	return false;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Добовляем опции;
    void cDuelSystem::SetDuelOption(int lpObj, BOOL bState)
    {
    	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(lpObj);
    	// ----
    	if(Utilits.gObjIsConnected(lpObj) == TRUE)
    	{
    		if(bState == 0)
    		{
    			gObj->m_Option = 0;
    		}
    		// ----
    		else
    		{
    			gObj->m_Option |= 2;
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Проверяем если в дуэли
    bool cDuelSystem::IsOnDuel(int lpObj)
    {
    	bool bResult = false;
    	// ----
    	for(short i = 0; i < MAX_DUEL_ROOMS; i++)
    	{
    		DUEL_ROOM room = this->g_DuelRooms[i];
    
    
    		if ((room.szlpObjOne != NULL && room.szlpObjOne->m_Index == lpObj) 
    			|| (room.szlpObjTy != NULL && room.szlpObjTy->m_Index == lpObj))
    		{
    			if(!room.DuelWaiting)
    				bResult = true;
    			// ----
    			break;
    		}
    	}
    	// ----
    	return bResult;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Проверяем если в дуэли 2
    bool cDuelSystem::IsOnDuel2(int lpObj, int lpObj2)
    {
    	for(short i = 0; i < MAX_DUEL_ROOMS; i++)
    	{
    		DUEL_ROOM room = this->g_DuelRooms[i];
    		// ----
    		if(!room.RoomFree)
    		{
    			if (room.szlpObjOne != NULL && room.szlpObjOne->m_Index == lpObj)
    			{
    				if (room.szlpObjTy != NULL && room.szlpObjTy->m_Index == lpObj2)
    				{
    					return true;
    				}
    			}
    
    
    			if (room.szlpObjOne != NULL && room.szlpObjOne->m_Index == lpObj2)
    			{
    				if (room.szlpObjTy != NULL && room.szlpObjTy->m_Index == lpObj)
    				{
    					return true;
    				}
    			}
    		}
    	}
    
    
    	return false;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Добовляем баф винеру;
    void cDuelSystem::WinnerBuff(LPOBJ lpObj)
    {
    	if(Utilits.gObjIsConnected(lpObj->m_Index))
    	{
    		AddBuff(lpObj, 103, 20, 10, 0, 0, 3600);
    		// ----
    		if(Config.Logging)
    		{
    			Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Winner : [%s][%s] received a Gladiator Glory Buff",
    				lpObj->AccountID, lpObj->Name);
    		}
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## для выхода сепараторов;
    bool cDuelSystem::IsSpectacor(short Index)
    {
    	for(short a = 0; a < MAX_DUEL_ROOMS; a++)
    	{
    		// ----
    		for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    		{
    			// ----
    			if(this->g_DuelRooms[a].RoomFree == FALSE)
    			{
    				if(this->g_DuelRooms[a].szSeparators[i] != NULL)
    				{
    					if(this->g_DuelRooms[a].szSeparators[i]->m_Index == Index)
    					{
    						return true;
    					}
    				}
    			}
    			// ----
    		}
    	}
    	return false;
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## проверка для появления;
    void cDuelSystem::RespawnDuelers(LPOBJ lpObj, LPOBJ lpTargetObj)
    {
    	if(lpObj->MapNumber != 0x40 && lpTargetObj->MapNumber != 0x40)
    	{
    		return;
    	}
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## результат проверки дуэля;
    bool cDuelSystem::DuelCheck(LPOBJ lpObj)
    { 
    	return this->IsOnDuel(lpObj->m_Index); 
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## Результат проверки дуэля 2;
    bool cDuelSystem::DuelCheck(LPOBJ lpObj, LPOBJ lpObj2) 
    { 
    	return this->IsOnDuel2(lpObj->m_Index, lpObj2->m_Index); 
    }
    // ----------------------------------------------------------------------------------------------------------------
    //## отменя дуэля;
    void cDuelSystem::SendRefuseDuel(LPOBJ lpObj)
    { 
    	if(lpObj == NULL)
    	{
    		return;
    	}
    	// ----
    	PMSG_DUEL_START pMsgSend;
    	// ----
    	pMsgSend.h.c	= 0xC1;
    	pMsgSend.h.headcode = 0xAA;
    	pMsgSend.h.subcode = 0x01;
    	pMsgSend.bDuelStart = 0x0F;
    	pMsgSend.h.size = sizeof(pMsgSend);
    	// ----
    	DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);
    }
    // ----------------------------------------------------------------------------------------------------------------
    
    
    bool HookSetDuelOption(int lpObj, BOOL bState)
    {
    	DuelSystem.SetDuelOption(lpObj, bState);
    	return true;
    }
    // --------------------------------------------------------------------------------------------
    bool HookIsDuelEnable(int aIndex)
    {
    	if(!DuelSystem.IsDuelEnable(aIndex))
    	{
    		return false;
    	}
    	else 
    	{
    		return true;
    	}
    }
    // --------------------------------------------------------------------------------------------
    
    
    bool HookIsOnDuel(int lpObj, int lpObj2) 
    {
    	if(!DuelSystem.IsOnDuel2(lpObj, lpObj2))
    	{
    		return false;
    	}
    	else 
    	{
    		return true;
    	}
    }
    // --------------------------------------------------------------------------------------------
    
    
    bool HookDuelCheck1(LPOBJ lpObj)
    { 
    	bool bResult = false;
    	// ----
    	if(lpObj->Type == OBJECT_USER)
    	{                                   
    		if(DuelSystem.DuelCheck(lpObj)) 
    			bResult = true;
    		else
    			bResult = goBjHoookLoad1(lpObj);
    	}                
    	return bResult;
    }
    // --------------------------------------------------------------------------------------------
    
    
    bool HookDuelCheck2(LPOBJ lpObj, LPOBJ lpTargetObj)
    {
    	bool cResult = false;
    	// ----
    	if(lpObj->Type == OBJECT_USER || lpTargetObj->Type == OBJECT_USER)
    	{													
    		if(DuelSystem.DuelCheck(lpObj, lpTargetObj))
    			cResult = true;
    		else
    			goBjHoookLoad2(lpObj, lpTargetObj);
    	}							
    	return cResult;
    }
    // --------------------------------------------------------------------------------------------
    
    
    void GSgObjUserDie(OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpTargetObj)
    {
    	if(lpObj->Type == OBJECT_USER && lpTargetObj->Type == OBJECT_USER ) 
    	{
    		if(DuelSystem.DuelCheck(lpObj, lpTargetObj))
    		{
    			int aIndex = lpObj->m_Index;
    			int DuelRoom = AddTab[aIndex].DUEL_Room;
    			DuelSystem.PlayerScore(lpTargetObj);
    			DuelSystem.KillUserProc(lpTargetObj,lpObj);
    			return;
    		}
    	}						  
    	gObjUserDie(lpObj, lpTargetObj);
    }
    // --------------------------------------------------------------------------------------------
    
    
    // --------------------------------------------------------------------------------------------
    // This Function For Set Duel Info in Game;
    void cDuelSystem::DuelSetInfo( LPOBJ lpObj, int DuelWins, int DuelLoses )
    {
    	int All = DuelWins + DuelLoses;
    	AddTab[lpObj->m_Index].DUEL_Wins = DuelWins;
    	AddTab[lpObj->m_Index].DUEL_Lose = DuelLoses;
    	AddTab[lpObj->m_Index].DUEL_AllDuels = All;
    }
    // --------------------------------------------------------------------------------------------
    
    
    void cDuelSystem::SaveDuel(char FirstAcc[11], char FirstName[11], char SecondAcc[11], char SecondName[11], int Point1, int Point2)
    {
    	MuOnlineQuery.ExecQuery("UPDATE Character SET DuelWins=DuelWins+1, DuelsTotal = DuelsTotal+1 WHERE AccountID = '%s' AND Name = '%s'", FirstAcc, FirstName);
    	MuOnlineQuery.Fetch();
    	MuOnlineQuery.Close();
    	MuOnlineQuery.ExecQuery("UPDATE Character SET DuelLoses=DuelLoses+1, DuelsTotal = DuelsTotal+1 WHERE AccountID = '%s' AND Name = '%s'", SecondAcc, SecondName);
    	MuOnlineQuery.Fetch();
    	MuOnlineQuery.Close();
    }
    #endif
    Duel.h
    Code:
    // ================================================== //
    // #			GameServer 1.00.90					# //
    // #			Imagination Arts					# //
    // #			Julia Project 1.1.x					# //
    // ================================================== //
    // #	http://imaginationarts.net/forum/			# //
    // #	http://mu.raklion.ru/						# //
    // ================================================== //
    
    
    #ifdef _GS
    #ifndef DUELSYSTEM_H
    #define DUELSYSTEM_H
    #include "Prodef.h"
    #include "User.h"
    // ----------------------------------------------------------------------------------------------------------------
    #define MAX_DUEL_WIN_POINTS	10
    #define MAX_DUEL_ROOMS	    4
    #define MAX_DUEL_SEPARATORS	10
    #define MAX_DUEL_TIME		30
    // ----------------------------------------------------------------------------------------------------------------
    // ## Structures;
    #pragma pack(1)
    // CLIENT -> SERVER
    struct PMSG_DUEL_ANSWER_START
    {
    	PBMSG_HEAD2 h;
    	bool bDuelOK;
    	BYTE NumberH;
    	BYTE NumberL;
    	char szName[10];
    };
    
    
    // ----------------------------------------------------------------------------------------------------------------
    // CLIENT -> SERVER
    struct PMSG_DUEL_START
    {
    	PBMSG_HEAD2 h;	// C1:AA
    	BYTE bDuelStart;	// 3
    	BYTE NumberH;	// 4
    	BYTE NumberL;	// 5
    	char szName[10];	// 6
    };
    // ----------------------------------------------------------------------------------------------------------------
    // CLIENT -> SERVER
    struct PMSG_DUEL_REQUEST_END
    {
    	PBMSG_HEAD2 h;
    	BYTE NumberH;	// 3
    	BYTE NumberL;	// 4
    	char szName[10];	// 6
    };
    // ----------------------------------------------------------------------------------------------------------------
    // CLIENT -> SERVER
    struct PMSG_DUEL_REQUEST_WATCH // 0x07
    {
    	PBMSG_HEAD2 h;
    	BYTE btRoomIndex;
    	BYTE btRandomValue;
    };
    
    
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_QUESTION_START // 0x01
    {
    	PBMSG_HEAD2 h;
    	BYTE NumberH;
    	BYTE NumberL;
    	BYTE szName[10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_REQUEST_START // 0x02
    {
    	PBMSG_HEAD2 h;
    	BYTE NumberH;	// 3
    	BYTE NumberL;	// 4
    	char szName[10];	// 5
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_END // 0x03
    {
    	PBMSG_HEAD2 h;
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_SCORE // 0x04
    {
    	PBMSG_HEAD2 h;	
    	BYTE NumberH1;	
    	BYTE NumberL1;	
    	BYTE NumberH2;	
    	BYTE NumberL2;	
    	BYTE btDuelScore1;	
    	BYTE btDuelScore2;	
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_LIFEBAR_REFILL // 0x05
    {
    	PBMSG_HEAD2 h;
    	BYTE btObjId01H;
    	BYTE btObjId01L;
    	BYTE btObjId02H;
    	BYTE btObjId02L;
    	BYTE btLife01;
    	BYTE btLife02;
    	BYTE btShield01;
    	BYTE btShield02;
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_ROOMSTATUS // 0x06
    {
    	BYTE szName1[10];
    	BYTE szName2[10];
    	BYTE btDuelRunning;
    	BYTE btDuelOpen;
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_STATUS // 0x06
    {
    	PBMSG_HEAD2 h;
    	PMSG_DUEL_ROOMSTATUS pRoomStatus[MAX_DUEL_ROOMS];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_LIFEBAR_NAME // 0x07 
    {
    	PBMSG_HEAD2 h;
    	WORD Type; // 4
    	BYTE szName1[10]; // 5
    	BYTE szName2[10]; // f
    	BYTE btObjId1H;
    	BYTE btObjId1L;
    	BYTE btObjId2H;
    	BYTE btObjId2L;
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_SPEC_ADD // 0x08
    {
    	PBMSG_HEAD2 h;
    	BYTE szName[10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_SPEC_DELEX // 0x09
    {
    	PBMSG_HEAD2 h;
    	BYTE szName[10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_SPEC_DEL // 0x0A
    {
    	PBMSG_HEAD2 h;
    	BYTE szName[10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_SPEC_LIST // 0x0B
    {
    	PBMSG_HEAD2 h;
    	BYTE btCount;
    	BYTE szName[MAX_DUEL_SEPARATORS][10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    /* Moved to ProdejNew
    // SERVER -> CLIENT
    struct PMSG_SERVERCMD
    {
    	PBMSG_HEAD2 h;
    	BYTE subcode;	// 3
    	BYTE CmdType;	// 4
    	BYTE X;	// 5
    	BYTE Y;	// 6
    };
    */
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_FINISH // 0x0C
    {
    	PBMSG_HEAD2 h;
    	BYTE szWinner[10];
    	BYTE szLooser[10];
    };
    // ----------------------------------------------------------------------------------------------------------------
    // SERVER -> CLIENT
    struct PMSG_DUEL_LIFEBAR_INIT // 0x0D
    {
    	PBMSG_HEAD2 h;
    	BYTE Unknow00;
    };
    // ----------------------------------------------------------------------------------------------------------------
    #pragma pack()
    // ----------------------------------------------------------------------------------------------------------------
    // ## Structure;
    struct DUEL_ROOM
    {
    
    
    	BOOL	RoomFree;
    	BOOL	DuelWaiting;
    	// ----
    	LPOBJ	szlpObjOne;
    	BYTE	szPointsOne;
    	// ----
    	LPOBJ	szlpObjTy;
    	BYTE	szPointsTy;
    	// ----
    	LPOBJ	szSeparators[MAX_DUEL_SEPARATORS];
    	// ----
    	DWORD	dwTicketCount;
    	DWORD	dwStartTime;
    	// ----
    	BOOL	szWinner;
    
    
    };
    // ----------------------------------------------------------------------------------------------------------------
    //##Structure;
    static const struct DUEL_RESPAWN_RECTS
    {
    	int LowX;
    	int LowY;
    	int HighX;
    	int HighY;
    }
    // ----------------------------------------------------------------------------------------------------------------
    g_DuelRespawns [MAX_DUEL_ROOMS] = 
    {
    	{89, 62, 110, 81},
    	{89, 113, 110, 130},
    	{141, 63, 163, 82},
    	{142, 111, 163, 131	}
    };
    // ----------------------------------------------------------------------------------------------------------------
    //## Class;
    class cDuelSystem
    {
    	// ----
    private:
    	DWORD UpdateTickCount;
    	DWORD UpdateLifebarTime;
    	// ----
    public:
    	DUEL_ROOM	g_DuelRooms[MAX_DUEL_ROOMS];
    	// ----
    	cDuelSystem(void);
    	~cDuelSystem(void);
    	// ----
    	struct sConfig
    	{
    		int Enabled;
    		int Ranking;
    		int Logging;
    		int DuelGate;
    	}Config;
    
    
    	void Load();
    	void Run();
    	void DuelProtocolCore(LPOBJ lpObj, unsigned char * lpPacket);
    	void KillUserProc ( LPOBJ lpObj, LPOBJ lpTarget);
    	int GetUserDuelRoom(LPOBJ lpObj);
    	int GetFreeRoomIndex();
    	DWORD _DuelThread(void *param);
    	// ----
    	static void RunThread(LPVOID param)
    	{
    		while(true)
    		{
    			cDuelSystem* This = (cDuelSystem*)param;
    			// ----
    			This->Run();
    			// ----
    			Sleep(1000);
    		}
    	}
    	// ----
    	void DuelCreateThread()
    	{
    		DWORD ThreadID;
    		// ----
    		HANDLE dThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)RunThread, (LPVOID)this, 0, &ThreadID); /*False	2	92	V513	Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions.	IA Julia 1.x.x	duelmanager.h	283	False*/
    		// ----
    		if(!dThread)
    		{
    			MessageBoxA(0, "Cannot start Duel System", "Error", MB_OK | MB_ICONERROR);
    			exit(0);
    		}
    
    
    	}
    	// ----
    	bool IsDuelEnable(int aIndex);
    	bool DuelCheck(LPOBJ lpObj);
    	bool DuelCheck(LPOBJ lpObj, LPOBJ lpObj2);
    	void UserDuelInfoReset(LPOBJ lpObj);
    	void RoomReset(short iRoom, bool dontMove = false, bool dontSendEnd = false);
    	void RemoveUser(LPOBJ lpObj);
    	void SetDuelOption(int lpObj, BOOL bState);
    	bool IsOnDuel(int lpObj);
    	bool IsOnDuel2(int lpObj, int lpObj2);
    	void PlayerScore(LPOBJ lpObj);
    	int GetSpectatorCount(short iRoom);
    	void SendDuelStatus(LPOBJ lpObj);
    	void UpdateDuelScore(short iRoom);
    	void WinnerBuff(LPOBJ lpObj);
    	void DeletePotion(LPOBJ lpObj);
    	bool IsSpectacor(short index);
    	// ----
    	void RecvDuelRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_START* lpMsg);
    	void RecvDuelAnswer(LPOBJ lpObj, PMSG_DUEL_ANSWER_START* lpMsg);
    	void RecvWatchRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_WATCH* lpMsg);
    	void RespawnDuelers(LPOBJ lpObj, LPOBJ lpTargetObj);
    	void SendRefuseDuel(LPOBJ lpObj);
    	// ----
    
    
    	static void TimerThreadEP(void * pThis) 
    	{ 
    		cDuelSystem * pt = (cDuelSystem*)pThis; 
    	}
    	// ----
    	void SendEndDuel(LPOBJ lpObj);
    	void SendEndDuelNotification(LPOBJ lpObj, char* Winner, char* Looser);
    	void SendLifebarStatus(short iRoom);
    	void SendLifebarStatus(LPOBJ lpObj, int iRoom);
    	void SendLifebarInit(LPOBJ lpObj, int iRoom);
    	void SendSpectatorList(short iRoom);
    	void SendSpectatorList(LPOBJ lpObj, int iRoom);
    	void SendSpectatorAdd(short iSpecIndex, int iRoom);
    	void SendSpectatorRemove(short iSpecIndex, int iRoom);
    
    
    	void DuelSetInfo(LPOBJ lpObj, int DuelWins, int DuelLoses);
    	void SaveDuel(char FirstAcc[11], char FirstName[11], char SecondAcc[11], char SecondName[11], int Point1, int Point2);
    };
    // ----------------------------------------------------------------------------------------------------------------
    extern cDuelSystem DuelSystem;
    
    
    	bool HookSetDuelOption(int lpObj, BOOL bState);
    	bool HookIsDuelEnable(int aIndex);
    	bool HookIsOnDuel(int lpObj, int lpObj2);
    	bool HookDuelCheck1(LPOBJ lpObj);
    	bool HookDuelCheck2(LPOBJ lpObj, LPOBJ lpTargetObj);
    	void GSgObjUserDie(OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpTargetObj);
    // ----------------------------------------------------------------------------------------------------------------
    #endif
    // ----------------------------------------------------------------------------------------------------------------
    #endif

  25. #3600
    Enthusiast erikgaston is offline
    MemberRank
    Jul 2015 Join Date
    35Posts

    re: [Release] Repack IA Julia 1.1.0.298 Season 4.6 ENG + Improvements + Fixes + Source

    kantru3 problem event.
    when I'm in, I disconnected.It says nothing in gs.



Advertisement