Depo açıkken sağ tık ile envanterde ki itemlerinizi depoya, depodaki itemleri sağ tık ile envanterinize alabilirsiniz.
Kodların paste hali:
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
interfacemodule.py Aç
Kod:
def GetInventoryPageIndex(self):
Kod:
def AttachItemFromSafebox(self, slotIndex, itemIndex): if self.wndInventory and self.wndInventory.IsShow(): self.wndInventory.AttachItemFromSafebox(slotIndex, itemIndex) return True def AttachInvenItemToOtherWindowSlot(self, slotWindow, slotIndex): if self.wndSafebox and self.wndSafebox.IsShow(): return self.wndSafebox.AttachItemFromInventory(slotWindow, slotIndex) return False
uiinventory.py Aç
Kod:
def __UseItem(self, slotIndex):
Kod:
def __GetCurrentItemGrid(self): itemGrid = [[False for slot in xrange(player.INVENTORY_PAGE_SIZE)] for page in xrange(player.INVENTORY_PAGE_COUNT)] for page in xrange(player.INVENTORY_PAGE_COUNT): for slot in xrange(player.INVENTORY_PAGE_SIZE): itemVnum = player.GetItemIndex(slot + page * player.INVENTORY_PAGE_SIZE) if itemVnum <> 0: (w, h) = item.GetItemSize(item.SelectItem(itemVnum)) for i in xrange(h): itemGrid[page][slot + i * 5] = True return itemGrid def __FindEmptyCellForSize(self, itemGrid, size): for page in xrange(player.INVENTORY_PAGE_COUNT): for slot in xrange(player.INVENTORY_PAGE_SIZE): if itemGrid[page][slot] == False: possible = True for i in xrange(size): p = slot + (i * 5) try: if itemGrid[page][p] == True: possible = False break except IndexError: possible = False break if possible: return slot + page * player.INVENTORY_PAGE_SIZE return -1 def AttachItemFromSafebox(self, slotIndex, itemIndex): itemGrid = self.__GetCurrentItemGrid() if item.GetItemType(item.SelectItem(itemIndex)) == item.ITEM_TYPE_DS: return emptySlotIndex = self.__FindEmptyCellForSize(itemGrid, item.GetItemSize()[1]) if emptySlotIndex <> -1: net.SendSafeboxCheckoutPacket(slotIndex, player.INVENTORY, emptySlotIndex) return True
Kod:
def __UseItem(self, slotIndex): ItemVNum = player.GetItemIndex(slotIndex) item.SelectItem(ItemVNum)
Kod:
def __UseItem(self, slotIndex): if self.interface and self.interface.AttachInvenItemToOtherWindowSlot(player.INVENTORY, slotIndex): return ItemVNum = player.GetItemIndex(slotIndex) item.SelectItem(ItemVNum)
uisafebox.py Aç
İmportlarda item yoksa ekle
Kod:
class SafeboxWindow(ui.ScriptWindow):
Kod:
def UseItemSlot(self, slotIndex):
Kod:
def __GetCurrentItemGrid(self): itemGrid = [[False for cell in xrange(safebox.SAFEBOX_PAGE_SIZE)] for page in xrange(self.pagecount)] for page in xrange(self.pagecount): for slot in xrange(safebox.SAFEBOX_PAGE_SIZE): itemVnum = safebox.GetItemID(slot + page * safebox.SAFEBOX_PAGE_SIZE) if itemVnum <> 0: item.SelectItem(itemVnum) (w, h) = item.GetItemSize() for i in xrange(h): itemGrid[page][slot + i * safebox.SAFEBOX_SLOT_X_COUNT] = True return itemGrid def __FindEmptyCellForSize(self, itemGrid, size): for page in xrange(self.pagecount): for slot in xrange(safebox.SAFEBOX_PAGE_SIZE): if itemGrid[page][slot] == False: possible = True for i in xrange(size): p = slot + safebox.SAFEBOX_SLOT_X_COUNT * i try: if itemGrid[page][p] == True: possible = False break except IndexError: possible = False break if possible: return slot + page * safebox.SAFEBOX_PAGE_SIZE return -1 def AttachItemFromInventory(self, slotWindow, slotIndex): attachedItemID = player.GetItemIndex(slotWindow, slotIndex) item.SelectItem(attachedItemID) if item.IsAntiFlag(item.ITEM_ANTIFLAG_SAFEBOX): return False itemGrid = self.__GetCurrentItemGrid() item.SelectItem(attachedItemID) emptySafeboxSlot = self.__FindEmptyCellForSize(itemGrid, item.GetItemSize()[1]) if emptySafeboxSlot == -1 or item.GetItemType() == item.ITEM_TYPE_ELK: return False net.SendSafeboxCheckinPacket(slotWindow, slotIndex, emptySafeboxSlot) return True def UseItemSlot(self, slotIndex): if mouseModule.mouseController.isAttached(): mouseModule.mouseController.DeattachObject() if self.interface: globalSlotIndex = self.__LocalPosToGlobalPos(slotIndex) self.interface.AttachItemFromSafebox(globalSlotIndex, safebox.GetItemID(globalSlotIndex))
İyi kullanımlar iyi forumlar..
not: eğer pagecount ile ilgili sysser alıyorsanız verdiğim kodlarda ki self.pagecount kısmını self.pageCount olarak değiştirin.
Metin2'de Python Kullanımı: Depo ve Envanter Sistemleri Arasında Veri Transferi
Python, Metin2 özel sunucu geliştirme sürecinde özellikle GUI ve backend süreçlerinde büyük kolaylık sağlar. Bu yazıda, Depo ile Envanter arasında veri aktarımını sağlayan Python tabanlı sistemlerden bahsedeceğiz. Bu sistemler; py GUI, uiscript, py root gibi yapılarla entegre çalışarak oyuncu deneyimini zenginleştirir.
Metin2 Sunucu Mimarisi ve Python Entegrasyonu
Metin2 özel sunucularında genellikle C++ tabanlı server src ve client src kullanılır. Ancak arayüz geliştirme ve bazı dinamik işlemler için Python tercih edilir. Özellikle game server programming sırasında, veritabanı (db) işlemleri, kullanıcı arayüzü (GUI), envanter yönetimi gibi işlemlerde Python’un sunduğu esneklik büyük avantaj sağlar.
Depo ve Envanter Nedir?
Envanter, oyuncunun elinde tuttuğu eşyaları barındıran alandır. Depo ise oyuncunun uzun süreli sakladığı eşyaların bulunduğu bölümdür. Bu iki alan arasındaki veri transferi, hem güvenlik hem de deneyim açısından önemlidir. Martysama ve diğer metin2dev projelerinde bu işlemler genellikle Python yardımıyla daha stabil hale getirilir.
Python ile Depo-Envanter Entegrasyonu
Python sayesinde uiscript üzerinden GUI arayüzüyle oyuncu istekleri karşılanabilir. Örneğin, bir butona basıldığında depodan envantere eşya geçişi şu şekilde sağlanabilir:
- Oyuncu GUI üzerinden bir eşyayı seçer.
- Python betiği, py root üzerinden veritabanına erişerek eşyanın sahipliğini kontrol eder.
- Eğer eşya depoda mevcutsa, game tarafına aktarım komutu gönderilir.
- Eşya başarıyla envantere taşınır.
Python GUI ile Kullanıcı Deneyimi
Modern py GUI sistemleri sayesinde kullanıcı dostu arayüzler oluşturulabilir. Bu sistemler, Metin2’nin eski yapısını güncellemek ve PvP sistemlerinde daha hızlı işlem yapabilmek için idealdir. Özellikle pack ve compile işlemleri sırasında Python, source edit süreçlerini hızlandırır.
Veritabanı ve Sunucu Arası İletişim
Auth ve game server yapıları, eşya geçişlerini güvenli bir şekilde yönetmelidir. Python bu süreçte db core ve game core ile entegre çalışarak eşya takibi ve envanter güncellemesi sağlar. Bu, core sistemlerin daha kararlı ve güvenli çalışmasını sağlar.
Sonuç
Metin2 özel sunucularında Python kullanımı, özellikle envanter ve depolar arasında veri aktarımı gibi kritik süreçlerde büyük fayda sağlar. Py GUI, uiscript, py root gibi yapılar sayesinde hem kullanıcı dostu arayüzler hem de verimli backend süreçleri oluşturulabilir. Metin2lobby olarak bu tür sistemlerin geliştirilmesi ve paylaşılması bizim önceliğimizdir.
Using Python in Metin2: Data Transfer Between Storage and Inventory Systems
Python provides significant convenience in custom Metin2 server development, especially for GUI and backend processes. In this article, we will discuss Python-based systems that facilitate data transfer between Storage and Inventory. These systems integrate with structures like py GUI, uiscript, and py root to enhance the player experience.
Metin2 Server Architecture and Python Integration
In Metin2 private servers, C++-based server src and client src are commonly used. However, for interface development and certain dynamic operations, Python is preferred. During game server programming, Python's flexibility is particularly useful for database (db) operations, user interfaces (GUI), and inventory management.
What Are Storage and Inventory?
Inventory holds items currently in the player’s possession. Storage, on the other hand, stores long-term items. Transferring data between these two areas is critical for both security and gameplay. In projects like Martysama and other metin2dev initiatives, Python helps make these operations more stable.
Integrating Storage and Inventory with Python
With Python, GUI interfaces can respond to player requests via uiscript. For example, moving an item from storage to inventory can be done as follows:
- Player selects an item through the GUI.
- The Python script accesses the database via py root to check item ownership.
- If the item exists in storage, a command is sent to the game side to initiate the transfer.
- Item is successfully moved into the inventory.
User Experience with Python GUI
Modern py GUI systems allow for user-friendly interfaces. These systems are ideal for updating Metin2's older structure and enabling faster actions within PvP systems. Python also speeds up source edit processes during pack and compile operations.
Communication Between Database and Server
Auth and game server structures must securely manage item transfers. Python works alongside db core and game core to provide item tracking and inventory updates, ensuring the core systems operate reliably and safely.
Conclusion
Using Python in Metin2 private servers significantly benefits critical processes like transferring items between inventory and storage. With tools like Py GUI, uiscript, and py root, both user-friendly interfaces and efficient backend processes can be created. At Metin2lobby, developing and sharing such systems is one of our main priorities.
