Jump to content

Block item swap when shopping or when exchanging


Go to solution Solved by VegaS™,

Recommended Posts

  • Active+ Member

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 by ReFresh

I'll be always helpful!  😉

  • Active Member

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 by HaiosMotan
  • Active Member

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)

  • Active+ Member

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 by ReFresh

I'll be always helpful!  😉

  • Former Staff
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.

  • Good 1
  • Active+ Member

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 by ReFresh

I'll be always helpful!  😉

  • Forum Moderator
  • Solution
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

Inside of:

This is the hidden content, please

Edited by VegaS™
  • Metin2 Dev 7
  • Eyes 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Guest
This topic is now closed to further replies.
×
×
  • 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.