Active Member ReFresh 2340 Posted July 6, 2022 Active Member Share Posted July 6, 2022 (edited) Hey guys, someone know how can I block item swap when shopping or when exchanging and can help me with that? Probably something should be edited in PythonNetworkStreamPhaseGameItem.cpp or it should be edited in server? Spoiler Thanks for possible answers! Sincerely, ReFresh Edited July 6, 2022 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
HaiosMotan 402 Posted July 6, 2022 Share Posted July 6, 2022 (edited) uiinventory.py def UseItemSlot(self, slotIndex): find at the bottom self.__UseItem(slotIndex) mouseModule.mouseController.DeattachObject() self.OverOutItem() add above if exchange.isTrading(): chat.AppendChat(1, "[Exchange]You can't do this while exchanging.") return if shop.IsOpen(): chat.AppendChat(1, "[Shop]You can't do this while shoping.") return be sure you have import exchgange import shop Edited July 6, 2022 by HaiosMotan Link to comment Share on other sites More sharing options...
HaiosMotan 402 Posted July 6, 2022 Share Posted July 6, 2022 there is one check here bool CPythonNetworkStream::SendItemUsePacket(TItemPos pos) { if (!__CanActMainInstance()) return true; if (__IsEquipItemInSlot(pos)) { if (CPythonExchange::Instance().isTrading()) { PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_AppendNotifyMessage", Py_BuildValue("(s)", "CANNOT_EQUIP_EXCHANGE")); return true; } if (CPythonShop::Instance().IsOpen()) { PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_AppendNotifyMessage", Py_BuildValue("(s)", "CANNOT_EQUIP_SHOP")); return true; } if (__IsPlayerAttacking()) return true; } but as you can see it's only for when you right click on an equiped item,you can delete that check " if (__IsEquipItemInSlot(pos)) " and it will be for all. (i think) Link to comment Share on other sites More sharing options...
Active Member ReFresh 2340 Posted July 6, 2022 Author Active Member Share Posted July 6, 2022 (edited) Two more methods: char_item.cpp: Spoiler bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver) { if (GetMyShop() || GetShop() || GetExchange()) return false; } uiinventory.py: Spoiler def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop() or exchange.isTrading() or shop.IsOpen(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos) def __SendUseItemPacket(self, slotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop() or exchange.isTrading() or shop.IsOpen(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return net.SendItemUsePacket(slotPos) Edited July 6, 2022 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
Management AZICKO 7349 Posted July 6, 2022 Management Share Posted July 6, 2022 5 minutes ago, ReFresh said: Two more methods: char_item.cpp: Hide contents bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver) { if (GetMyShop() || GetShop() || GetExchange()) return false; } uiinventory.py: Hide contents def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop() or exchange.isTrading() or shop.IsOpen(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos) def __SendUseItemPacket(self, slotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop() or exchange.isTrading() or shop.IsOpen(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return net.SendItemUsePacket(slotPos) I had suggested the first method, then deleted my answer. With the first method, I can no longer sell items to an NPC. 1 Scamming ? Reselling ? metin2.download | metin2.dev | fr.metin2.dev | metin2dev.org | metin2.top | top-metin2.org Link to comment Share on other sites More sharing options...
Active Member ReFresh 2340 Posted July 6, 2022 Author Active Member Share Posted July 6, 2022 (edited) But it still isn't what I'm searching. In ItemData.cpp (Client) exist this (this is blocking item unequip when shopping or exchanging): Spoiler BOOL CItemData::IsEquipment() const { switch (GetType()) { //BLOCK ITEM UNEQUIP WHEN SHOPPING case ITEM_TYPE_WEAPON: case ITEM_TYPE_ARMOR: return TRUE; break; } return FALSE; } I need to find the same function, but for equipping the specific item types. Edited July 6, 2022 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
Forum Moderator Solution VegaS™ 10275 Posted July 6, 2022 Forum Moderator Solution Share Posted July 6, 2022 (edited) On 7/6/2022 at 11:59 PM, ReFresh said: But it still isn't what I'm searching. In ItemData.cpp (Client) exist this (this is blocking item unequip when shopping or exchanging): Hide contents BOOL CItemData::IsEquipment() const { switch (GetType()) { //BLOCK ITEM UNEQUIP WHEN SHOPPING case ITEM_TYPE_WEAPON: case ITEM_TYPE_ARMOR: return TRUE; break; } return FALSE; } I need to find the same function, but for equipping the specific item types. I don't really understand what you're trying to do, but you should do it on the server side if you want to be safe. char_item.cpp Use the following code: This is the hidden content, please Sign In or Sign Up Inside of: This is the hidden content, please Sign In or Sign Up Edited July 14, 2022 by VegaS™ 4 1 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Recommended Posts