Jump to content
  • Announcements

    • .Kori

      M2tec Event   02/28/18

      Hello M2tec Users,    M2tec present a new donate Event.      Premium Event :
      Premium Pack 1 : 5€ /2 month + 1 month free 
      Premium Pack 2 : 7€ / 4 month + 2 month free 
      Premium Pack 3 : 9€ / 6 month + 2 month free *
      Premium Pack 4: 15€ /  1 year + 4 month free *   Source Pack :  Source Light Pack : 15€ Source full Pack : 20€ *   Advertisements Packs :  Little Pack : 5€ Middle Pack : 10€ Big Pack : 15€ *   All packets with * become after buy a donator rank for the Support on M2tec.    The M2tec Team.   

Recommended Posts

// 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

 

 

Description :

Hidden Content

    Give reaction to this post to see the hidden content.

 

Edited by Elijah
  • Like 13
  • Thanks 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×