Jump to content

Recommended Posts

using this https://metin2hub.com/threads/c-fast-stack-items.633/

marty 5.8,

if i try to use faststack to stack a item in belt inventory it causes the core to crash.

how i include the beltinventory?

 

#ifdef FAST_ITEM_AUTOSTACK
bool CHARACTER::FastStack(TItemPos originPos)
{
	if (!IsValidItemPosition(originPos))
		return false;

	if (!CanHandleItem())
		return false;

	LPITEM item = GetItem(originPos);

	if (item == nullptr)
		return false;

	if (item->GetCount() >= ITEM_MAX_COUNT)
	{
		ChatPacket(CHAT_TYPE_INFO, "ITEM MAX");
		return false;
	}

	int currentPos = originPos.cell + 1;

	while (item->GetCount() < ITEM_MAX_COUNT && (originPos.cell != currentPos))
	{
		LPITEM item2 = GetInventoryItem(currentPos);
		if (item2)
		{
			if (item2->GetVnum() == item->GetVnum())
			{
				if (item2->GetCount() < ITEM_MAX_COUNT)
				{
					int itemCount = item->GetCount();
					int item2Count = item2->GetCount();

					if (itemCount + item2Count > ITEM_MAX_COUNT)
					{
						int requiredCountToMax = (ITEM_MAX_COUNT - itemCount);
						
						MoveItem(TItemPos(INVENTORY, item2->GetCell()), originPos, requiredCountToMax);
					}
					else
					{
						MoveItem(TItemPos(INVENTORY, item2->GetCell()), originPos, item2->GetCount());
					}
				}
			}
		}

		currentPos++;

		if (currentPos >= ITEM_MAX_COUNT)
		{
			currentPos = 0;
		}
	}

	return true;
}
#endif

 

Edited by specks97
Link to comment
https://metin2.dev/topic/32783-faststack-system/
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.