GMs can use the /i command to create items. Normally, when you use the command /i 27992, it produces 1 White Pearl, and using /i 27992 10 produces 10 White Pearls.
With this update, using /i 27992 10 10 will produce 10 stacks of 10 White Pearls each (i.e., 100 in total).
For non-stackable items, an example command is: /i 19 0 10 (creates 10 units of +9 swords).
ACMD(do_item)
{
char arg1[256], arg2[256], arg3[256];
one_argument(two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3));
DWORD dwVnum = 0;
int iCount = 1;
int loop_count = 1;
if (!*arg1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: item <item vnum>");
return;
}
if (isnhdigit(*arg1))
str_to_number(dwVnum, arg1);
else
{
if (!ITEM_MANAGER::instance().GetVnum(arg1, dwVnum))
{
ch->ChatPacket(CHAT_TYPE_INFO, "#%u item not exist by that vnum.", dwVnum);
return;
}
}
if (*arg2)
{
str_to_number(iCount, arg2);
iCount = MINMAX(1, iCount, ITEM_MAX_COUNT);
}
if (*arg3)
{
str_to_number(loop_count, arg3);
loop_count = MINMAX(1, loop_count, 20); // I didn't create a constant like ITEM_MAX_COUNT; you can modify this. Note: 20 is the limit, do not increase it too much.
}
for (int i = 0; i < loop_count; ++i)
{
LPITEM item = ITEM_MANAGER::instance().CreateItem(dwVnum, iCount, 0, true);
if (!item)
{
ch->ChatPacket(CHAT_TYPE_INFO, "#%u item not exist by that vnum.", dwVnum);
break; // if the item doesn't exist, exit the loop
}
if (item->IsDragonSoul())
{
int iEmptyPos = ch->GetEmptyDragonSoulInventory(item);
if (iEmptyPos != -1)
{
item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos));
LogManager::instance().ItemLog(ch, item, "GM", item->GetName());
}
else
{
M2_DESTROY_ITEM(item);
if (!ch->DragonSoul_IsQualified())
{
ch->ChatPacket(CHAT_TYPE_INFO, "Inventory is not activated.");
}
else
{
ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space.");
}
break; // if there is no space in inventory, exit the loop
}
}
else
{
int iEmptyPos = ch->GetEmptyInventory(item->GetSize());
if (iEmptyPos != -1)
{
item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
LogManager::instance().ItemLog(ch, item, "GM", item->GetName());
}
else
{
M2_DESTROY_ITEM(item);
ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space.");
break; // if there is no space in inventory, exit the loop
}
}
}
}