void cProtoFunc::PlayerConnect(LPOBJ gObj)
{	
	LoginMsg(gObj);
	RingSkin(gObj);
	PCPoint.InitPCPointForPlayer(gObj); 
	MySQL.Execute("SELECT %s FROM Character WHERE Name = '%s'", Config.ResetColumn, gObj->Name);	 
	AddTab[gObj->m_Index].Resets = MySQL.GetInt();
	#ifdef _GS 
	if(Config.Duel.Enabled)
	{
		if(Config.Duel.Ranking)
		{
			g_DuelSystem.DuelSetInfo(gObj->m_Index);
		}
				
	if((!g_DuelSystem.IsOnDuel(gObj->m_Index)) && gObj->MapNumber == 64)
		{
			gObjMoveGate(gObj->m_Index, 294);
			Log.ConsoleOutPut(1, c_Blue ,t_Duel, "[Duel System][%s][%s] Spawn on duel map after duel is not allowed", gObj->AccountID, gObj->Name);
		}
		g_DuelSystem.UserDuelInfoReset(gObj);
	}
	#endif
}
void cProtoFunc::PlayerConnect(LPOBJ gObj)
{	    										
	AddTab[gObj->m_Index].AddValue = 0;	 
	AddTab[gObj->m_Index].ArcherObj = NULL;		 
	AddTab[gObj->m_Index].AFK_MapNumber = 0;  
	AddTab[gObj->m_Index].AFK_Timer = 0;
	AddTab[gObj->m_Index].AFK_X = 0;
	AddTab[gObj->m_Index].AFK_Y = 0;		
	AddTab[gObj->m_Index].PostDelay = 0;  
	AddTab[gObj->m_Index].ExType = -1;
	AddTab[gObj->m_Index].AddType = -1;		  
	AddTab[gObj->m_Index].MarryType = -1;	   	
	AddTab[gObj->m_Index].ResType = -1;		 

	MySQL.Execute("SELECT IsMarried FROM Character WHERE Name = '%s'", gObj->Name);	
	AddTab[gObj->m_Index].IsMarried = MySQL.GetInt();

	MySQL.Execute("SELECT MarryName FROM Character WHERE Name = '%s'", gObj->Name);
	MySQL.GetString(AddTab[gObj->m_Index].MarryName);	  										   

	MySQL.Execute("SELECT %s FROM Character WHERE Name = '%s'", Config.ResetColumn, gObj->Name);	 
	AddTab[gObj->m_Index].Resets = MySQL.GetInt();
	 
	LoginMsg(gObj);
	RingSkin(gObj);	
	g_PointShop.GetInfo(gObj->m_Index); 

	if(cProtection.CheckFeature(cProtection.VIPSystem))
	{ 			
	    if(Config.VIPServ.Enabled)
		{												 
			MySQL.Execute("SELECT %s FROM [%s].[dbo].[MEMB_INFO] WHERE memb___id='%s'",Config.VIPServ.Column,MySQL.szDatabase2,gObj->AccountID);
			AddTab[gObj->m_Index].IsVipServer = MySQL.GetInt();

			MySQL.Execute("SELECT %s FROM [%s].[dbo].[MEMB_INFO] WHERE memb___id='%s'",Config.VIPServ.ColumnDate,MySQL.szDatabase2,gObj->AccountID);
			AddTab[gObj->m_Index].VipMinutesServer = MySQL.GetInt();

			if(AddTab[gObj->m_Index].IsVipServer > 0)
			{											 
				DWORD ThreadID;
				HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)VipTickServer, (void*)gObj->m_Index, 0, &ThreadID);

				if ( hThread == 0 )
				{
					cLog.ConsoleOutPut(0, cLog.c_Red,cLog.t_NULL,"CreateThread() failed with error %d", GetLastError());
					return;
				}

				CloseHandle(hThread);
				Chat.MessageLog(1, cLog.c_Red, cLog.t_VIP, gObj, "[VIP] Left %d minutes of VIP Server.", AddTab[gObj->m_Index].VipMinutesServer);
			}
			else
			{
				Chat.MessageLog(1, cLog.c_Red, cLog.t_VIP, gObj, "[VIP] You are not vip user! Disconnected from the server.");
				CloseClient(gObj->m_Index);
			} 
		}

		if(!Config.VIPServ.Enabled && VIP.Enabled)
		{
			MySQL.Execute("SELECT %s FROM [%s].[dbo].[Character] WHERE Name='%s'",VIP.Column,MySQL.szDatabase,gObj->Name);
			AddTab[gObj->m_Index].IsVipInGame = MySQL.GetInt();

			MySQL.Execute("SELECT %s FROM [%s].[dbo].[Character] WHERE Name='%s'",VIP.ColumnDate,MySQL.szDatabase,gObj->Name);
			AddTab[gObj->m_Index].IsInGameVipMinutes = MySQL.GetInt();

			if(AddTab[gObj->m_Index].IsVipInGame > 0)
			{											 
				DWORD ThreadID;
				HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)VipInGameServer, (void*)gObj->m_Index, 0, &ThreadID);

				if ( hThread == 0 )
				{
					cLog.ConsoleOutPut(0, cLog.c_Red,cLog.t_NULL,"CreateThread() failed with error %d", GetLastError());
					return;
				}

				CloseHandle(hThread);
				Chat.MessageLog(1, cLog.c_Red, cLog.t_VIP, gObj, "[VIP] Left %d minutes of VIP.", AddTab[gObj->m_Index].IsInGameVipMinutes );
			}
		}
	
	}
	
	
#ifdef _GameServer_
	
	if(Config.Duel.Enabled)
	{
		if(Config.Duel.Ranking)
		{
			DuelSetInfo(gObj->m_Index);
		}
				
	if((!g_DuelSystem.IsOnDuel(gObj->m_Index)) && gObj->MapNumber == 64)
		{
			gObjMoveGate(gObj->m_Index, 294);
			cLog.ConsoleOutPut(1, cLog.c_Blue ,cLog.t_Duel, "[Duel System][%s][%s] Spawn on duel map after duel is not allowed", gObj->AccountID, gObj->Name);
		}
		g_DuelSystem.UserDuelInfoReset(gObj);
	}
#endif

}