Jump to content

Extended /i command


Valki

Recommended Posts

  • Active Member

Hello!

I was testing something on my server and I had to use /i a tons, so I just extended it instead. With this extension you can get as many items as you want (of course with limitation of your max inventory space.)

For this we will working in only one file, called "cmd_gm.cpp".

 

So, in cmd_gm.cpp fine ACMD(do_item) and edit the following things in the function.

Be careful, because there's a chance that you don't use "g_bItemCountLimit" but "MAX_ITEM_COUNT" (or something like that) instead.

//Find this:
	if (*arg2)
	{
		str_to_number(iCount, arg2);
		iCount = MINMAX(1, iCount, g_bItemCountLimit);
	}
//And comment out iCount limitations like this:
	if (*arg2)
	{
		str_to_number(iCount, arg2);
		//iCount = MINMAX(1, iCount, g_bItemCountLimit);
	}

//Find this:
  if (item->IsDragonSoul())
  {
      [...]
  }

//and after that add this:

		else if (!item->IsStackable())
		{
			M2_DESTROY_ITEM(item);
			for (int i = 0; i < iCount; i++)
			{
				LPITEM newItem = ITEM_MANAGER::instance().CreateItem(dwVnum, 1);
				int iEmptyPos = ch->GetEmptyInventory(newItem->GetSize());

				if (iEmptyPos != -1)
				{
					newItem->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
					LogManager::instance().ItemLog(ch, newItem, "GM", item->GetName());
				}
				else
				{
					M2_DESTROY_ITEM(item);
					ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space.");
					break;
				}
			}
		}
		else if (item->IsStackable() && iCount > g_bItemCountLimit)
		{
			M2_DESTROY_ITEM(item);
			while (iCount != 0)
			{
				LPITEM newItem;
				if (iCount >= g_bItemCountLimit)
				{
					newItem = ITEM_MANAGER::instance().CreateItem(dwVnum, g_bItemCountLimit);
					iCount -= g_bItemCountLimit;
				}
				else
				{
					newItem = ITEM_MANAGER::instance().CreateItem(dwVnum, iCount);
					iCount -= iCount;
				}

				int iEmptyPos = ch->GetEmptyInventory(newItem->GetSize());

				if (iEmptyPos != -1)
				{
					newItem->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
					LogManager::instance().ItemLog(ch, newItem, "GM", item->GetName());
				}
				else
				{
					M2_DESTROY_ITEM(newItem);
					ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space.");
					break;
				}
			}
		}
Edited by Valki
  • Metin2 Dev 1
  • Love 1
Link to comment
Share on other sites



×
×
  • 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.