Jump to content

Recommended Posts

Hello , if i have an item equipped like weapon and i try to transfer directly in safebox is working :(

I think normal is to undressing items from equipament and after that to transfer the item(weapon in this case) from inventory in the safebox.

WHO can help me for block this in c++ ?

0504_122400.jpg

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Honorable Member
	## Slot Event
	def SelectEmptySlot(self, selectedSlotPos):
		selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos)
		if mouseModule.mouseController.isAttached():
			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			if player.SLOT_TYPE_SAFEBOX == attachedSlotType:
				m2net.SendSafeboxItemMovePacket(attachedSlotPos, selectedSlotPos, 0)
				#snd.PlaySound("sound/ui/drop.wav")
			else:
				attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
				if player.RESERVED_WINDOW == attachedInvenType:
					return

				if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
					#m2net.SendSafeboxDepositMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
					snd.PlaySound("sound/ui/money.wav")
				else:
					if not player.IsEquipmentSlot(attachedSlotPos)##########################################
						m2net.SendSafeboxCheckinPacket(attachedInvenType, attachedSlotPos, selectedSlotPos)
					#snd.PlaySound("sound/ui/drop.wav")

			mouseModule.mouseController.DeattachObject()

 

  • Love 1
Link to comment
Share on other sites

La 04.05.2017 la 12:42, xP3NG3Rx a spus:

	## Slot Event
	def SelectEmptySlot(self, selectedSlotPos):
		selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos)
		if mouseModule.mouseController.isAttached():
			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			if player.SLOT_TYPE_SAFEBOX == attachedSlotType:
				m2net.SendSafeboxItemMovePacket(attachedSlotPos, selectedSlotPos, 0)
				#snd.PlaySound("sound/ui/drop.wav")
			else:
				attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
				if player.RESERVED_WINDOW == attachedInvenType:
					return

				if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
					#m2net.SendSafeboxDepositMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
					snd.PlaySound("sound/ui/money.wav")
				else:
					if not player.IsEquipmentSlot(attachedSlotPos)##########################################
						m2net.SendSafeboxCheckinPacket(attachedInvenType, attachedSlotPos, selectedSlotPos)
					#snd.PlaySound("sound/ui/drop.wav")

			mouseModule.mouseController.DeattachObject()

 

Great man , thx you for reply but it`s problem with new line " if not player.IsEquipmentSlot(attachedSlotPos) "

Spoiler

networkModule.SetSelectCharacterPhase - <type 'exceptions.IndentationError'>:expected an indented block (uiSafebox.py, line 438)

0505 12:04:06915 :: ============================================================================================================
0505 12:04:06915 :: Abort!!!!

 

Link to comment
Share on other sites

La 05.05.2017 la 12:08, DeYaN. a spus:

Great man , thx you for reply but it`s problem with new line " if not player.IsEquipmentSlot(attachedSlotPos) "

  Reafișează conținuturi ascunse

networkModule.SetSelectCharacterPhase - <type 'exceptions.IndentationError'>:expected an indented block (uiSafebox.py, line 438)

0505 12:04:06915 :: ============================================================================================================
0505 12:04:06915 :: Abort!!!!

 

 

Upp ? anyone know the solve :( ?

Link to comment
Share on other sites

Something is not right , and i dont belive the tabs.

Spoiler

Untitled.jpg

This is my changed safebox with the new line :

 

I`m test with the full code ## Slot Event of xP3NG3Rx  and same problem with the new line:

Spoiler

if not player.IsEquipmentSlot(attachedSlotPos):##########################################

If i remove this line from my code or xP3NG3Rx code, the game is working.

It`s something wrong ? or i need to add something extra ?

I dont know the python ...

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 3 weeks later...
  • Premium

If you want to "fix" it, here's the C++ "fix". Take in consideration that it's neither a bug nor creating any bug. Except if the item is a belt and your belt inventory is not empty. Which in that case can lead to a usebug.

In input_main.cpp in

void CInputMain::SafeboxCheckin(LPCHARACTER ch, const char * c_pData)

Add this :

LPITEM pkItem = ch->GetItem(p->ItemPos);

if (true == pkItem->IsEquipped())
{
    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
		return;
}

under this :

CSafebox * pkSafebox = ch->GetSafebox();

 

It's tested and everything is working fine :P

Link to comment
Share on other sites

Acum 3 ore, Galet a spus:

If you want to "fix" it, here's the C++ "fix". Take in consideration that it's neither a bug nor creating any bug. Except if the item is a belt and your belt inventory is not empty. Which in that case can lead to a usebug.

In input_main.cpp in


void CInputMain::SafeboxCheckin(LPCHARACTER ch, const char * c_pData)

Add this :


LPITEM pkItem = ch->GetItem(p->ItemPos);

if (true == pkItem->IsEquipped())
{
    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
		return;
}

under this :


CSafebox * pkSafebox = ch->GetSafebox();

 

It's tested and everything is working fine :P

Ohh good , thx you man! This is the solve ! <3

  • Love 1
Link to comment
Share on other sites

LPITEM pkItem = ch->GetItem(p->ItemPos);

// Make sure pkItem is not null pointer. Without that condition, the channel might down.
if (pkItem && true == pkItem->IsEquipped())
{
    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
		return;
}

Best Regards

Ken

  • Love 1

Do not be sorry, be better.

Link to comment
Share on other sites

3 hours ago, Ken said:

LPITEM pkItem = ch->GetItem(p->ItemPos);

// Make sure pkItem is not null pointer. Without that condition, the channel might down.
if (pkItem && true == pkItem->IsEquipped())
{
    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
		return;
}

Best Regards

Ken

true ==  useless

Link to comment
Share on other sites

3 minutes ago, Ashok.N said:

true ==  useless

It depends on you. In my case, pkItem is useless if you're just using that for a condition.

if (ch->GetItem(p->ItemPos) && ch->GetItem(p->ItemPos)->IsEquipped())
{
	ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
	return;
}

I think, it's much better now ^_^

Best Regards

Ken

  • Love 1

Do not be sorry, be better.

Link to comment
Share on other sites

30 minutes ago, Ken said:

It depends on you. In my case, pkItem is useless if you're just using that for a condition.


if (ch->GetItem(p->ItemPos) && ch->GetItem(p->ItemPos)->IsEquipped())
{
	ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Storage> You can't store an equiped item."));
	return;
}

I think, it's much better now ^_^

Best Regards

Ken

No, it's not better. You should care more about readibiliy. It is correct to define variables as long as they are good to make the code more readable.  If the coding style used by ymir is old, we do not have to follow the same example. I mean  the pseudo-hungarian names like pkItem , hungarian naming was originally invented for assembly language. Just use logical names..

It was perfectly fine how it was before , just true == is a bad practice.

 

Regards

Link to comment
Share on other sites

16 minutes ago, Ashok.N said:

No, it's not better. You should care more about readibiliy. It is correct to define variables as long as they are good to make the code more readable.  If the coding style used by ymir is old, we do not have to follow the same example. I mean  the pseudo-hungarian names like pkItem , hungarian naming was originally invented for assembly language. Just use logical names..

I agree with you about that. You don't have to follow what exactly ymir did until now. (Except a few things). About code's readability, you can use comment line for that. About naming variables, you're right.

16 minutes ago, Ashok.N said:

It was perfectly fine how it was before , just true == is a bad practice.

It still depends on you. You can use it or not. 

Best Regards

Ken

Do not be sorry, be better.

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



×
×
  • 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.