Bitte melden Sie sich an, um dieses Medienelement zu sehen.
Code:
Code
- ACMD(do_item_new) // Nowa funkcja by: Muchomor
- {
- char arg1[256], arg2[256], arg3[256];
- three_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2), arg3, sizeof(arg3));
- if (!*arg1)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "Usage: item <item vnum> <item count> <times to spawn>");
- return;
- }
- int iCount = 1;
- int iTimes = 1;
- if (*arg2)
- {
- str_to_number(iCount, arg2);
- iCount = MINMAX(1, iCount, g_bItemCountLimit);
- }
- if (*arg3)
- {
- str_to_number(iTimes, arg3);
- iTimes = MAX(1, iTimes);
- }
- DWORD dwVnum;
- std::pair<DWORD, DWORD> vnumRange;
- std::vector<std::string> v_range;
- std::string sRange(arg1);
- boost::split(v_range, sRange, boost::is_any_of("-"));
- if (v_range.size() < 2)
- {
- if (isnhdigit(*arg1))
- {
- str_to_number(dwVnum, arg1);
- if (!ITEM_MANAGER::instance().GetTable_NEW(dwVnum))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "#%u item does not exist by that vnum.", dwVnum);
- return;
- }
- else
- {
- vnumRange = std::make_pair(dwVnum, dwVnum);
- }
- }
- else
- {
- if (!ITEM_MANAGER::instance().GetVnum(arg1, dwVnum))
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "#%u item does not exist by that vnum(%s).", dwVnum, arg1);
- return;
- }
- else
- {
- vnumRange = std::make_pair(dwVnum, dwVnum);
- }
- }
- }
- else
- {
- try
- {
- vnumRange = std::make_pair(std::stoul(v_range[0], NULL, 10), std::stoul(v_range[1], NULL, 10));
- if (vnumRange.first > vnumRange.second)
- {
- std::swap(vnumRange.first, vnumRange.second);
- }
- }
- catch (...)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "Invalid range! To use range feature type following syntax: ID-ID.");
- return;
- }
- }
- for (unsigned int i = vnumRange.first; i <= vnumRange.second; i++)
- {
- for (int j = 0; j < iTimes; j++)
- {
- LPITEM item = ITEM_MANAGER::instance().CreateItem(i, iCount, 0, true);
- if (item)
- {
- 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, "ŔÎşĄŔĚ Č°ĽşČ µÇÁö ľĘŔ˝.");
- }
- else
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space.");
- }
- }
- }
- 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.");
- }
- }
- }
- else
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "#%u item does not exist by that vnum.", dwVnum);
- }
- }
- }
- }