DeYaN. 29 Posted May 4, 2017 Share Posted May 4, 2017 (edited) 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++ ? Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Honorable Member xP3NG3Rx 19638 Posted May 4, 2017 Honorable Member Share Posted May 4, 2017 ## 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() 1 Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted May 5, 2017 Author Share Posted May 5, 2017 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 More sharing options...
DeYaN. 29 Posted May 9, 2017 Author Share Posted May 9, 2017 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 More sharing options...
Premium TAUMP 825 Posted May 9, 2017 Premium Share Posted May 9, 2017 14 minutes ago, DeYaN. said: Upp ? anyone know the solve ? Stop copy full code, only what he changes. Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted May 9, 2017 Premium Share Posted May 9, 2017 Dude, check tabs at the given line, the hardest part of this error is searching "expected an indented block" on google Link to comment Share on other sites More sharing options...
Honorable Member xP3NG3Rx 19638 Posted May 9, 2017 Honorable Member Share Posted May 9, 2017 Fix the tabs, make fit to your client and a colon is missing from IsEq line. if not player.IsEquipmentSlot(attachedSlotPos):########################################## m2net.SendSafeboxCheckinPacket(attachedInvenType, attachedSlotPos, selectedSlotPos) Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted May 12, 2017 Author Share Posted May 12, 2017 (edited) Something is not right , and i dont belive the tabs. Spoiler 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 August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted May 13, 2017 Author Share Posted May 13, 2017 upp Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted May 30, 2017 Author Share Posted May 30, 2017 upp //... Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted May 31, 2017 Premium Share Posted May 31, 2017 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 Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted May 31, 2017 Author Share Posted May 31, 2017 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 Ohh good , thx you man! This is the solve ! <3 1 Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted May 31, 2017 Premium Share Posted May 31, 2017 You're welcome ! Link to comment Share on other sites More sharing options...
DeYaN. 29 Posted June 7, 2017 Author Share Posted June 7, 2017 (edited) La 31.05.2017 la 21:36, Galet a spus: You're welcome ! Hmm but now another problem :)) Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Ken 903 Posted June 7, 2017 Share Posted June 7, 2017 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 1 Do not be sorry, be better. Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted June 7, 2017 Premium Share Posted June 7, 2017 Indeed, I was forgetting about the null_ptr in my code, my bad :c Link to comment Share on other sites More sharing options...
Ashok.N 4 Posted June 7, 2017 Share Posted June 7, 2017 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 More sharing options...
Ken 903 Posted June 7, 2017 Share Posted June 7, 2017 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 1 Do not be sorry, be better. Link to comment Share on other sites More sharing options...
Ashok.N 4 Posted June 7, 2017 Share Posted June 7, 2017 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 More sharing options...
Ken 903 Posted June 7, 2017 Share Posted June 7, 2017 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now