Jump to content

Unequipe item automtically with time is 0


Recommended Posts

Hello I would like to make sure that this item automatically unequips when the time reaches 0.

i have try this code in char_item.cpp but not succes

	case ITEM_RING:
            {    
                LPITEM item;
                const time_t current = get_global_time();
                
                if (item->IsEquipped())
                {
                    if (item->GetSocket(0) < current)
                    {
                        UnequipItem(item);
                    }
                }
                
                if (!item->IsEquipped())
                    EquipItem(item);
                else
                    UnequipItem(item);        
            }
            break;
	

help me please

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

i use this fonction in item.cpp now

	EVENTFUNC(real_time_expire_event)
{
    const item_vid_event_info* info = reinterpret_cast<const item_vid_event_info*>(event->info);
    
    //LPCHARACTER pOwner = GetOwner();
    //m_pOwner = ch;
    
    int Cell;
    
    if (NULL == info)
        return 0;
	    const LPITEM item = ITEM_MANAGER::instance().FindByVID( info->item_vid );
	    if (NULL == item)
        return 0;
	    const time_t current = get_global_time();
    
    if (current > item->GetSocket(0))
    {
        switch (item->GetVnum())
        {
            if(item->IsNewMountItem())
            {
                if (item->GetSocket(2) != 0)
                    item->ClearMountAttributeAndAffect();
            }
            break;
        }
	        if (item->GetType() == ITEM_RING)
        {
            item->Unequip();
        }
        else if (item->GetType() != ITEM_RING)
        {
            ITEM_MANAGER::instance().RemoveItem(item, "REAL_TIME_EXPIRE");
        }
        
        return 0;
    }
	    return PASSES_PER_SEC(1);
}
	

item has desequipe but is invisible in inventory, I am forced to reboot the server to make it appear

Link to comment
Share on other sites

i have try this fonction in item_manageur,

	bool ITEM_MANAGER::AddItem(LPITEM item)
{
    LPCHARACTER owner = funcFindOwnership.owner;
    int pos;
	    if (item->GetWindow() == EQUIPMENT)
    {
        item->RemoveFromCharacter();
        item->AddToCharacter(owner, TItemPos(INVENTORY, pos));
    }
	    return true;
}
	

but game.core  with this error :

	#0  CItem::AddToCharacter (this=0x2c4bd000, ch=0x2c4bd000, Cell={window_type = 1 '\001', cell = 0}) at item.h:47
47                      const char *    GetName()               { return m_pProto ? m_pProto->szLocaleName : NULL; }
[New LWP 100580]
(gdb) bt full
#0  CItem::AddToCharacter (this=0x2940d090, ch=0x28d62198, Cell={window_type = 0 '\0', cell = 0}) at item.h:47
        pos = 35803
        window_type = 0 '\0'
        __FUNCTION__ = "AddToCharacter"
#1  0x28c5dbe6 in basename_r () from /usr/lib32/libc.so.7
No symbol table info available.
#2  0x083a9d3e in CSemaphore::Wait ()
No symbol table info available.
#3  0x083a8fad in CAsyncSQL::ChildLoop ()
No symbol table info available.
#4  0x083a980e in AsyncSQLThread ()
No symbol table info available.
#5  0x287abbbc in pthread_condattr_init () from /usr/lib32/libthr.so.3
No symbol table info available.
#6  0x00000000 in ?? ()

Link to comment
Share on other sites

// item.cpp
// void CItem::StartUniqueExpireEvent()
// Under
bool CItem::IsItemUsedTime()
{
	return m_pkRealTimeExpireEvent != nullptr;
}

// item.h
// void StartRealTimeExpireEvent(); 
// Under
	bool IsItemUsedTime();

 

	case ITEM_RING:
	{
		if (item->IsItemUsedTime() and item->IsEquipped())
		{
			UnequipItem(item);
		}
	}
	break;

Not tested

Link to comment
Share on other sites

is normal but wuth type item ring reaches time 7 day is not normal automatically unequip

my code in char_item

	case ITEM_RING:
            if (!item->IsEquipped())
            {
                EquipItem(item);
            }
            if (item->IsItemUsedTime() and item->IsEquipped())
            {
                UnequipItem(item);
            }
            break;

 

my code in item.cpp

	bool CItem::IsItemUsedTime()
{
    return m_pkRealTimeExpireEvent != NULL;
}

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 28

      Experimental Renderer

    2. 80

      Ship Defense (Hydra Dungeon)

    3. 11

      Loyal Metin2 Homepage

    4. 0

      Metin2Hyperion PvM 120 easy

    5. 29

      Shiva.international | Finest Oldschool | Official Start 16.09.2022

    6. 3

      Auto Potion refill event

    7. 0

      Different Staff Wanted!!

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.