no entiendo tengo que remplazar este codigo por el otro como es puedes esplicar
bool CCustomStore::OnPShopBuyItemRecv(PMSG_PSHOP_BUY_ITEM_RECV* lpMsg,int aIndex) // OK
{
LPOBJ lpObj = &gObj[aIndex];
if(gObjIsConnectedGP(aIndex) == 0)
{
return 1;
}
int bIndex = MAKE_NUMBERW(lpMsg->index[0],lpMsg->index[1]);
if(gObjIsConnectedGP(bIndex) == 0)
{
return 1;
}
LPOBJ lpTarget = &gObj[bIndex];
if(lpObj->PShopActiveIBuy == 1) //By Narvu ( Anti wCoins Dupe in PersonalShop CustomStore )
{
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,"Process Stopped, avoid spaming when buying an items.");
gNotice.GCNoticeSend(lpTarget->Index,1,0,0,0,0,0,"Character [%s] was spaming item buy in your store",lpObj->Name);
gLog.Output(LOG_TRADE,"[SellPesonalShopItem Process Stopped ] Item Seller: [%s][%s] -> Item Buyer: [%s][%s] Detected that user was spaming item buy in store.",lpTarget->Account,lpTarget->Name,lpObj->Account,lpObj->Name);
lpObj->PShopActiveIBuy = 0;
return 1;
}
lpObj->PShopActiveIBuy = 1;
if(lpTarget->PShopOpen == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,3);
return 1;
}
if(lpTarget->PShopCustom == 0)
{
lpObj->PShopActiveIBuy = 0;
return 0;
}
if(lpTarget->PShopTransaction != 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,4);
return 1;
}
if(INVENTORY_SHOP_RANGE(lpMsg->slot) == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,5);
return 1;
}
gObjFixInventoryPointer(aIndex);
if(lpObj->Transaction == 1)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,6);
return 1;
}
char name[11] = {0};
memcpy(name,lpMsg->name,sizeof(lpMsg->name));
if(strcmp(name,lpTarget->Name) != 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,6);
return 1;
}
if(lpTarget->Inventory[lpMsg->slot].IsItem() == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,6);
return 1;
}
if(lpTarget->Inventory[lpMsg->slot].m_PShopValue <= 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,6);
return 1;
}
#if(GAMESERVER_UPDATE>=501)
if(lpTarget->PShopCustomType == 3 || lpTarget->PShopCustomType == 4 || lpTarget->PShopCustomType == 5)
{
gCashShop.GDCashShopRecievePointSend(aIndex,(DWORD)&CCustomStore::OnPShopBuyItemCallbackRecv,(DWORD)&gObj[bIndex],lpMsg->slot);
lpObj->PShopActiveIBuy = 0;
return 1;
}
#else
if(lpTarget->PShopCustomType == 3 || lpTarget->PShopCustomType == 4 || lpTarget->PShopCustomType == 5)
{
gPcPoint.GDPcPointRecievePointSend(aIndex,(DWORD)&CCustomStore::OnPShopBuyItemCallbackRecv,(DWORD)&gObj[bIndex],lpMsg->slot);
lpObj->PShopActiveIBuy = 0;
return 1;
}
#endif
int PShopJoBValue = ((lpTarget->PShopCustomType==0)?lpTarget->Inventory[lpMsg->slot].m_PShopValue:0);
int PShopJoSValue = ((lpTarget->PShopCustomType==1)?lpTarget->Inventory[lpMsg->slot].m_PShopValue:0);
int PShopJoCValue = ((lpTarget->PShopCustomType==2)?lpTarget->Inventory[lpMsg->slot].m_PShopValue:0);
int RequireJewelCount[3] = {0};
int PaymentJewelCount[3] = {0};
int RequireJewelTable[3][4] = {0};
int PaymentJewelTable[3][4] = {0};
gPersonalShop.GetRequireJewelCount(lpObj,&RequireJewelCount[0],RequireJewelTable[0],0,PShopJoBValue);
gPersonalShop.GetRequireJewelCount(lpObj,&RequireJewelCount[1],RequireJewelTable[1],1,PShopJoSValue);
gPersonalShop.GetRequireJewelCount(lpObj,&RequireJewelCount[2],RequireJewelTable[2],2,PShopJoCValue);
gPersonalShop.GetPaymentJewelCount(lpTarget,&PaymentJewelCount[0],PaymentJewelTable[0],0,PShopJoBValue);
gPersonalShop.GetPaymentJewelCount(lpTarget,&PaymentJewelCount[1],PaymentJewelTable[1],1,PShopJoSValue);
gPersonalShop.GetPaymentJewelCount(lpTarget,&PaymentJewelCount[2],PaymentJewelTable[2],2,PShopJoCValue);
if(RequireJewelCount[0] < PShopJoBValue)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(RequireJewelCount[1] < PShopJoSValue)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(RequireJewelCount[2] < PShopJoCValue)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(PShopJoBValue > 0 && RequireJewelTable[0][0] == 0 && RequireJewelTable[0][1] == 0 && RequireJewelTable[0][2] == 0 && RequireJewelTable[0][3] == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(PShopJoSValue > 0 && RequireJewelTable[1][0] == 0 && RequireJewelTable[1][1] == 0 && RequireJewelTable[1][2] == 0 && RequireJewelTable[1][3] == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(PShopJoCValue > 0 && RequireJewelTable[2][0] == 0 && RequireJewelTable[2][1] == 0 && RequireJewelTable[2][2] == 0 && RequireJewelTable[2][3] == 0)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
if(gItemManager.GetInventoryEmptySlotCount(lpTarget) < (PaymentJewelCount[0]+PaymentJewelCount[1]+PaymentJewelCount[2]))
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,7);
return 1;
}
lpTarget->PShopTransaction = 1;
BYTE result = gItemManager.InventoryInsertItem(aIndex,lpTarget->Inventory[lpMsg->slot]);
if(result == 0xFF)
{
lpObj->PShopActiveIBuy = 0;
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,0,8);
return 1;
}
gLog.Output(LOG_TRADE,"[SellPesonalShopItem][%s][%s] - (Account: %s, Name: %s, Value: %d, JoBValue: %d, JoSValue: %d, JoCValue: %d, Index: %04d, Level: %02d, Serial: %08X, Option1: %01d, Option2: %01d, Option3: %01d, NewOption: %03d, JewelOfHarmonyOption: %03d, ItemOptionEx: %03d, SocketOption: %03d, %03d, %03d, %03d, %03d)",lpTarget->Account,lpTarget->Name,lpObj->Account,lpObj->Name,0,PShopJoBValue,PShopJoSValue,PShopJoCValue,lpTarget->Inventory[lpMsg->slot].m_Index,lpTarget->Inventory[lpMsg->slot].m_Level,lpTarget->Inventory[lpMsg->slot].m_Serial,lpTarget->Inventory[lpMsg->slot].m_Option1,lpTarget->Inventory[lpMsg->slot].m_Option2,lpTarget->Inventory[lpMsg->slot].m_Option3,lpTarget->Inventory[lpMsg->slot].m_NewOption,lpTarget->Inventory[lpMsg->slot].m_JewelOfHarmonyOption,lpTarget->Inventory[lpMsg->slot].m_ItemOptionEx,lpTarget->Inventory[lpMsg->slot].m_SocketOption[0],lpTarget->Inventory[lpMsg->slot].m_SocketOption[1],lpTarget->Inventory[lpMsg->slot].m_SocketOption[2],lpTarget->Inventory[lpMsg->slot].m_SocketOption[3],lpTarget->Inventory[lpMsg->slot].m_SocketOption[4]);
gPersonalShop.SetRequireJewelCount(lpObj,RequireJewelTable[0],0);
gPersonalShop.SetRequireJewelCount(lpObj,RequireJewelTable[1],1);
gPersonalShop.SetRequireJewelCount(lpObj,RequireJewelTable[2],2);
gPersonalShop.GCPShopBuyItemSend(aIndex,bIndex,result,1);
GDCharacterInfoSaveSend(aIndex);
gPersonalShop.SetPaymentJewelCount(lpTarget,PaymentJewelTable[0],0);
gPersonalShop.SetPaymentJewelCount(lpTarget,PaymentJewelTable[1],1);
gPersonalShop.SetPaymentJewelCount(lpTarget,PaymentJewelTable[2],2);
gPersonalShop.GCPShopSellItemSend(bIndex,aIndex,lpMsg->slot);
gItemManager.InventoryDelItem(bIndex,lpMsg->slot);
gItemManager.GCItemDeleteSend(bIndex,lpMsg->slot,1);
GDCharacterInfoSaveSend(bIndex);
if(gPersonalShop.CheckPersonalShop(bIndex) == 0)
{
lpTarget->PShopItemChange = 1;
}
else
{
lpTarget->PShopOpen = 0;
memset(lpTarget->PShopText,0,sizeof(lpTarget->PShopText));
gPersonalShop.GCPShopCloseSend(bIndex,1);
this->OnPShopClose(lpTarget);
}
lpTarget->PShopTransaction = 0;
lpObj->PShopActiveIBuy = 0;
return 1;
}