Tallywa 35 Posted June 20, 2018 Share Posted June 20, 2018 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 More sharing options...
Premium WeedHex 635 Posted June 20, 2018 Premium Share Posted June 20, 2018 When you want to do it? In what moment? Link to comment Share on other sites More sharing options...
Tallywa 35 Posted June 21, 2018 Author Share Posted June 21, 2018 Well, I would like to have the item disappear when the time is 0, that the one if it unequip automate. Link to comment Share on other sites More sharing options...
Tallywa 35 Posted June 21, 2018 Author Share Posted June 21, 2018 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 More sharing options...
Tallywa 35 Posted June 22, 2018 Author Share Posted June 22, 2018 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 More sharing options...
Tallywa 35 Posted June 23, 2018 Author Share Posted June 23, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted June 24, 2018 Author Share Posted June 24, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted June 26, 2018 Author Share Posted June 26, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted June 29, 2018 Author Share Posted June 29, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 2, 2018 Author Share Posted July 2, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 8, 2018 Author Share Posted July 8, 2018 bump Link to comment Share on other sites More sharing options...
ridetpro 116 Posted July 8, 2018 Share Posted July 8, 2018 So if you have an equipped item that has a time limit, do you want that item to automatically unequip when time reaches 0? Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 8, 2018 Author Share Posted July 8, 2018 yes ! exactelly i want Link to comment Share on other sites More sharing options...
ridetpro 116 Posted July 9, 2018 Share Posted July 9, 2018 // 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 More sharing options...
Tallywa 35 Posted July 9, 2018 Author Share Posted July 9, 2018 !now i cant equip because i unequip automatic Link to comment Share on other sites More sharing options...
ridetpro 116 Posted July 9, 2018 Share Posted July 9, 2018 1 oră în urmă, Tallywa a spus: !now i cant equip because i unequip automatic Is not that normal? When an item with type ITEM_RING reaches 0, it automatically unequip. If you want a good answer, ask a good question. Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 9, 2018 Author Share Posted July 9, 2018 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 More sharing options...
Tallywa 35 Posted July 10, 2018 Author Share Posted July 10, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 16, 2018 Author Share Posted July 16, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 18, 2018 Author Share Posted July 18, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 24, 2018 Author Share Posted July 24, 2018 bump Link to comment Share on other sites More sharing options...
Tallywa 35 Posted July 29, 2018 Author Share Posted July 29, 2018 bump Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now