Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // If you use my special storage, and ofc if you want add "ACMD(do_sort_special_storage);" too. ^
- //////////// CMD.CPP ////////////
- Search :
- ACMD(do_stun);
- Add after :
- #ifdef ENABLE_SORT_INVENTORY
- ACMD(do_sort_items);
- ACMD(do_sort_special_storage);
- #endif
- Search:
- { "notice", do_notice, 0, POS_DEAD, GM_LOW_WIZARD },
- Add after :
- #ifdef ENABLE_SORT_INVENTORY
- { "click_sort_items", do_sort_items, 0, POS_DEAD, GM_PLAYER },
- { "click_sort_special_storage", do_sort_special_storage, 0, POS_DEAD, GM_PLAYER },
- #endif
- //////////// CMD_GNERAL.CPP ////////////
- ADD THIS :
- #ifdef ENABLE_SORT_INVENTORY
- ACMD (do_sort_items)
- {
- if (ch->IsDead() || ch->GetExchange() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sort your inventory with those windows open."));
- return;
- }
- int lastSortInventoryPulse = ch->GetSortInventoryPulse();
- int currentPulse = thecore_pulse();
- if (lastSortInventoryPulse > currentPulse) {
- int deltaInSeconds = ((lastSortInventoryPulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
- int minutes = deltaInSeconds / 60;
- int seconds = (deltaInSeconds - (minutes * 60));
- return;
- }
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = ch->GetInventoryItem(i);
- if(!item)
- continue;
- if(item->isLocked())
- continue;
- if(item->GetCount() == g_bItemCountLimit)
- continue;
- if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- for (int j = i; j < INVENTORY_MAX_NUM; ++j)
- {
- LPITEM item2 = ch->GetInventoryItem(j);
- if(!item2)
- continue;
- if(item2->isLocked())
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- bool bStopSockets = false;
- for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
- {
- if (item2->GetSocket(k) != item->GetSocket(k))
- {
- bStopSockets = true;
- break;
- }
- }
- if(bStopSockets)
- continue;
- BYTE bAddCount = MIN(g_bItemCountLimit - item->GetCount(), item2->GetCount());
- item->SetCount(item->GetCount() + bAddCount);
- item2->SetCount(item2->GetCount() - bAddCount);
- continue;
- }
- }
- }
- }
- ch->SetNextSortInventoryPulse(thecore_pulse() + PASSES_PER_SEC(60));
- }
- ACMD (do_sort_special_storage)
- {
- if (ch->IsDead() || ch->GetExchange() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sort your inventory with those windows open."));
- return;
- }
- int lastSortSpecialStoragePulse = ch->GetSortSpecialStoragePulse();
- int currentPulse = thecore_pulse();
- if (lastSortSpecialStoragePulse > currentPulse) {
- int deltaInSeconds = ((lastSortSpecialStoragePulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
- int minutes = deltaInSeconds / 60;
- int seconds = (deltaInSeconds - (minutes * 60));
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can sort your inventory again in %02d seconds."), seconds);
- return;
- }
- for (int m = 0; m < 3; m++)
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item;
- switch(m)
- {
- case 0:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- case 1:
- item = ch->GetBookInventoryItem(i);
- break;
- case 2:
- item = ch->GetStoneInventoryItem(i);
- break;
- default:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- }
- if(!item)
- continue;
- if(item->isLocked())
- continue;
- if(item->GetCount() == g_bItemCountLimit)
- continue;
- if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- for (int j = i; j < SPECIAL_INVENTORY_MAX_NUM; ++j)
- {
- LPITEM item2;
- switch(m)
- {
- case 0:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- case 1:
- item2 = ch->GetBookInventoryItem(j);
- break;
- case 2:
- item2 = ch->GetStoneInventoryItem(j);
- break;
- default:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- }
- if(!item2)
- continue;
- if(item2->isLocked())
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- bool bStopSockets = false;
- for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
- {
- if (item2->GetSocket(k) != item->GetSocket(k))
- {
- bStopSockets = true;
- break;
- }
- }
- if(bStopSockets)
- continue;
- BYTE bAddCount = MIN(g_bItemCountLimit - item->GetCount(), item2->GetCount());
- item->SetCount(item->GetCount() + bAddCount);
- item2->SetCount(item2->GetCount() - bAddCount);
- continue;
- }
- }
- }
- }
- }
- ch->SetNextSortSpecialStoragePulse(thecore_pulse() + PASSES_PER_SEC(60));
- }
- #endif
- //////////// char.cpp ////////////
- Search :
- m_iSyncHackCount = 0;
- Add after:
- #ifdef ENABLE_SORT_INVENTORY
- m_sortInventoryPulse = 0;
- m_sortSpecialStoragePulse = 0;
- #endif
- //////////// char.h ////////////
- Search :
- void GiveGold(INT iAmount);
- Add after :
- #ifdef ENABLE_SORT_INVENTORY
- void SetNextSortInventoryPulse(int pulse) { m_sortInventoryPulse = pulse; }
- int GetSortInventoryPulse() { return m_sortInventoryPulse; }
- void SetNextSortSpecialStoragePulse(int pulse) { m_sortSpecialStoragePulse = pulse; }
- int GetSortSpecialStoragePulse() { return m_sortSpecialStoragePulse; }
- #endif
- Search :
- LPSHOP m_pkShop;
- LPSHOP m_pkMyShop;
- std::string m_stShopSign;
- LPCHARACTER m_pkChrShopOwner;
- Add after :
- #ifdef ENABLE_SORT_INVENTORY
- int m_sortInventoryPulse;
- int m_sortSpecialStoragePulse;
- #endif
- /////// Service.h ////////
- Add this :
- #define ENABLE_SORT_INVENTORY
Advertisement
Add Comment
Please, Sign In to add comment