bool cChat::SetPKCommand(LPOBJ gObj, char *Msg, int Index)
{								 			
	if(CheckCommand(gObj, Configs.Commands.IsSetPK, GmSystem.cSetPK, 0, 0, 0, Index, "SetPK", "[Name] /setpk <pklvl>", Msg))
		return true;

	int SetLevel;
	sscanf(Msg,"%d", &SetLevel);		

	if(SetLevel < 0 || SetLevel > 100)
	{
		TNotice.MessageLog(1,  gObj, "[SetPK] PK lvl can't be less than 0 and more than 100!");
		return true;
	}			 

	OBJECTSTRUCT *tObj = (OBJECTSTRUCT*)OBJECT_POINTER(Index);

	tObj->m_PK_Level = SetLevel;
	if(SetLevel >= 3)
		tObj->m_PK_Count = SetLevel - 3;
	GCPkLevelSend(tObj->m_Index,SetLevel);	 

	if (gObj == tObj)
		TNotice.MessageLog(1,tObj, "[SetPK] Your pk was changed to %d.", SetLevel);
	else
	{
		TNotice.MessageLog(1,gObj, "[SetPK] You successfully changed %s pk to %d.", tObj->Name, SetLevel);
		TNotice.MessageLog(1,tObj, "[SetPK] Your pk was changed to %d by %s.", SetLevel, gObj->Name);
	}
	return true;
}
bool cChat::PKClearCommand(LPOBJ gObj, char *Msg, int Index)
{
	if(CheckCommand(gObj, PkClear.ClearCommand.Enabled, GmSystem.NONE, 0, 0, 0, Index, "PKClear", "/pkclear", Msg))
		return true;

	if(GmSystem.IsCommand(GmSystem.cPkClear, gObj->Name))
	{
		OBJECTSTRUCT *tObj = (OBJECTSTRUCT*)OBJECT_POINTER(Index);

		if (tObj->m_PK_Level <=3)
		{												
			TNotice.SendNotice(Index,1,"[PkClear] %s is not pk!", tObj->Name);			
			return true;
		}	 				   

		tObj->m_PK_Level = 3;
		tObj->m_PK_Count = 0;
		GCPkLevelSend(tObj->m_Index, 3);	 					

		if (tObj == gObj)
		{
			TNotice.SendNotice(Index,1,"[PkClear] Your pk was cleared.");	
		}
		else
		{
			TNotice.SendNotice(Index,1, "[PkClear] You successfully clear %s pk.", tObj->Name);
			TNotice.SendNotice(Index,1, "[PkClear] Your pk was cleared by %s.", gObj->Name);	
		}
	}
	else if(!PkClear.ClearCommand.OnlyForGm)
	{
		int PriceZen;
		switch(PkClear.ClearCommand.Type)
		{	   
		case 1:	
			PriceZen = (PkClear.ClearCommand.PriceZen * gObj->m_PK_Count); 		 
			break;
		case 2:	
			PriceZen = PkClear.ClearCommand.PriceZenForAll;			 
			break;
		case 0: 
			PriceZen = 0;					 
			break;
		}

		if (gObj->m_PK_Level <=3)
		{												
			TNotice.SendNotice(Index,1,"[PkClear] Your are not pk!");			
			return true;
		}			
		if(CheckCommand(gObj, PkClear.ClearCommand.Enabled, GmSystem.NONE, PriceZen, PkClear.ClearCommand.LevelReq, 0, 0, "PKClear", "/pkclear", Msg))
			return true;

		TakeCommand(gObj, PriceZen,"PKClear");	
		gObj->m_PK_Level = 3;
		gObj->m_PK_Count = 0;
		GCPkLevelSend(gObj->m_Index, 3);	 
		TNotice.SendNotice(Index,1,"[PkClear] Your Pk successfully cleared!");
	}
	return true;				
}
Exemple #3
0
void CPKSystem::PKDownTime(LPOBJ lpObj, int TargetLevel)
{
	if(lpObj->m_PK_Level == 3)
	{
		return;
	}

	unsigned int dwtime = ((GetTickCount() - lpObj->m_dwPKTimer) / 1000) * gPKSystem.PKTime;

	if(dwtime > 5)
	{
		dwtime = 2;
		lpObj->m_dwPKTimer = GetTickCount();
	}
	else
	{
		lpObj->m_dwPKTimer = dwtime * 1000;
	}

	if(TargetLevel < 2)
	{
		lpObj->m_PK_Time += dwtime;
	}
	else
	{
		lpObj->m_PK_Time += TargetLevel;
	}

	if(lpObj->m_PK_Level < 3)
	{
		if(lpObj->m_PK_Time > 3600)
		{
			lpObj->m_PK_Time = 0;
			lpObj->m_PK_Count += 1;

			if(lpObj->m_PK_Count > 100)
			{
				lpObj->m_PK_Count = 100;
			}

			lpObj->m_PK_Level += 1;

			GCPkLevelSend(lpObj->m_Index,lpObj->m_PK_Level);
		}
	}
	else if(lpObj->m_PK_Level > 3)
	{
		if(lpObj->m_PK_Count > 3)
		{
			if(lpObj->m_PK_Time > 3600)
			{
				lpObj->m_PK_Time = 0;
				lpObj->m_PK_Count -= 1;

				if(lpObj->m_PK_Count <= 0)
				{
					lpObj->m_PK_Count = 0;
					lpObj->m_PK_Level = 3;
				}
				else if(lpObj->m_PK_Count == 2)
				{
					lpObj->m_PK_Level = 5;
				}
				else if(lpObj->m_PK_Count == 1)
				{
					lpObj->m_PK_Level = 4;
				}

				if(lpObj->m_PK_Level <= 5)
				{
					GCPkLevelSend(lpObj->m_Index,lpObj->m_PK_Level);
				}

				if(lpObj->m_PK_Level == 4)
				{
					//GCServerMsgStringSend(lMsg.Get(1137),lpObj->m_Index,1);
				}
			}
		}
		else if(lpObj->m_PK_Time > 10800)
		{
			lpObj->m_PK_Time = 0;
			lpObj->m_PK_Count -= 1;

			if(lpObj->m_PK_Count <= 0)
			{
				lpObj->m_PK_Count = 0;
				lpObj->m_PK_Level = 3;
			}
			else if(lpObj->m_PK_Count == 2)
			{
				lpObj->m_PK_Level = 5;
			}
			else if(lpObj->m_PK_Count == 1)
			{
				lpObj->m_PK_Level = 4;
			}

			if(lpObj->m_PK_Level <= 5)
			{
				GCPkLevelSend(lpObj->m_Index,lpObj->m_PK_Level);
			}

			if(lpObj->m_PK_Level == 4)
			{
				//GCServerMsgStringSend(lMsg.Get(1137),lpObj->m_Index,1);
			}
		}
	}
}
void cProtoFunc::PkClear(LPOBJ gObj, LPOBJ NpcObj)
{							   			
	if (gObj->m_PK_Level < 4)
	{										 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You are good player. God bless your soul.");
		return;
	}	

	int PriceZen;
	int PricePcPoint;
	int PriceWCoin;
	switch(Config.ClearNpc.Type)
	{	   
	case 1:	
		PriceZen = (Config.ClearNpc.PriceZen * gObj->m_PK_Count); 		 
		PricePcPoint = (Config.ClearNpc.PricePcPoints * gObj->m_PK_Count);
		PriceWCoin = (Config.ClearNpc.PriceWCoins * gObj->m_PK_Count);
		break;
	case 2:	
		PriceZen = Config.ClearNpc.PriceZenForAll;			 
		PricePcPoint = Config.ClearNpc.PricePcPoints;
		PriceWCoin = Config.ClearNpc.PriceWCoins;
		break;
	case 0: 
		PriceZen = 0;					 
		PricePcPoint = 0;
		PriceWCoin = 0;
		break;
	}

	if(gObj->Money < PriceZen)
	{
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough Zen, you need %d more!", PriceZen - gObj->Money);
		return;
	}	   
	if(gObj->m_wCashPoint < PriceWCoin)
	{	 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough WCoin, you need %d more!", PriceWCoin - gObj->m_wCashPoint);
		return;
	}
	if(AddTab[gObj->m_Index].PC_PlayerPoints < PricePcPoint)
	{	 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough PcPoint, you need %d more!", PricePcPoint - AddTab[gObj->m_Index].PC_PlayerPoints);
		return;
	}
	if (PricePcPoint > 0)
	{
//		PointShop.DecreasePoints(gObj->m_Index, PricePcPoint);	  
		Chat.MessageLog(1, c_Blue, t_PCPOINT, gObj,"[Guard] You pay %d PcPoints", PricePcPoint);
		//MySQL.Execute("UPDATE Character SET %s = %s - %d WHERE Name= '%s'", Config.PCPointsColumn, Config.PCPointsColumn, PricePcPoint, gObj->Name);
	}

	if (PriceWCoin > 0)
	{										
		gObj->m_wCashPoint -= PriceWCoin;
		Chat.MessageLog(1, c_Blue, t_PCPOINT, gObj,"[Guard] You pay %d WCoin", PriceWCoin);
		//MySQL.Execute("UPDATE MEMB_INFO SET %s = %s - %d WHERE memb___id = '%s'", Config.WCoinsColumn, Config.WCoinsColumn, PriceWCoin, gObj->AccountID);
	}

	if (PriceZen > 0)
	{															 
		gObj->Money -= PriceZen; 
		GCMoneySend (gObj->m_Index, gObj->Money);
		Chat.MessageLog(1, c_Blue ,t_PCPOINT, gObj, "[Guard] You pay %d Zen", PriceZen);
	}

	Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] Cleaned %d kills. Don't tell anyone!", gObj->m_PK_Count); 

	gObj->m_PK_Level = 3;
	gObj->m_PK_Count = 0;

	GCPkLevelSend (gObj->m_Index,3);
}