Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

Equipchanger problem?!


pimmelfranz

Question

Good evening everyone,

 

today i found an equipmentchanger on an other forum.

 

Here the script:

import os
import ui
import app
import ime
import grp
import net
import snd
import item
import chat
import player
import locale
import grpText
import uiRefine
import constInfo
import uiToolTip
import mouseModule
import uiAttachMetin
import uiScriptLocale

class changeequip(ui.ScriptWindow):
	def __init__(self):
		import exception
		ui.ScriptWindow.__init__(self)
		self.wndEquip = None
		self.tokens = None
		self.tooltipItem = uiToolTip.ItemToolTip()
		self.tooltipItem.Hide()
		if constInfo.FAST_PAGE == 1:
			self.saveName = "lib/FastEquipPage1.pyc"
		elif constInfo.FAST_PAGE == 2:
			self.saveName = "lib/FastEquipPage2.pyc"
		elif constInfo.FAST_PAGE == 3:
			self.saveName = "lib/FastEquipPage3.pyc"
		elif constInfo.FAST_PAGE == 4:
			self.saveName = "lib/FastEquipPage4.pyc"

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def Show(self):
		self.__LoadWindow()
		ui.ScriptWindow.Show(self)

	def Close(self):
		constInfo.FAST_EQUIP = 0
		snd.PlaySound("sound/ui/click.wav")
		self.Hide()

	def __LoadWindow(self):
		try:			
			pyScrLoader = ui.PythonScriptLoader()
			pyScrLoader.LoadScriptFile(self, "uiscript/fastequip_window.py")
		except:
			import exception
			exception.Abort("CostumeWindow.LoadWindow.LoadObject")
		
		self.wndEquip = self.GetChild("equipslot")
		self.bottone_change = self.GetChild("change_button")
		self.clear_button = self.GetChild("clear_button")
		self.TitleBar = self.GetChild("TitleBar")
		self.pag1_button = self.GetChild("page1_button")
		self.pag2_button = self.GetChild("page2_button")
		self.pag3_button = self.GetChild("page3_button")
		self.pag4_button = self.GetChild("page4_button")
		
		self.TitleBar.SetCloseEvent(ui.__mem_func__(self.Close))
		self.wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectItemSlot))
		self.wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
		self.wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
		self.wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
		self.bottone_change.SetEvent(ui.__mem_func__(self.__change_button))
		self.clear_button.SetEvent(ui.__mem_func__(self.__clear_button))
		self.pag1_button.SAFE_SetEvent(self.__pag1_button)
		self.pag2_button.SetEvent(ui.__mem_func__(self.__pag2_button))
		self.pag3_button.SetEvent(ui.__mem_func__(self.__pag3_button))
		self.pag4_button.SetEvent(ui.__mem_func__(self.__pag4_button))
		
		if os.path.exists(self.saveName):
			self.tokens = open(self.saveName, "r").read().split()
		else:
			open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")
		
		button = self.GetChild("page1_button")
		button.Down()

	def __clear_button(self):
		if constInfo.FAST_PAGE == 1:
			self.saveName = "lib/FastEquipPage1.pyc"
			if os.path.exists(self.saveName):
				os.remove(self.saveName)
				open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")
		elif constInfo.FAST_PAGE == 2:
			self.saveName = "lib/FastEquipPage2.pyc"
			if os.path.exists(self.saveName):
				os.remove(self.saveName)
				open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")
		elif constInfo.FAST_PAGE == 3:
			self.saveName = "lib/FastEquipPage3.pyc"
			if os.path.exists(self.saveName):
				os.remove(self.saveName)
				open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")
		elif constInfo.FAST_PAGE == 4:
			self.saveName = "lib/FastEquipPage4.pyc"
			if os.path.exists(self.saveName):
				os.remove(self.saveName)
				open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")

	def __pag1_button(self):
		constInfo.FAST_PAGE = 1
		button2 = self.GetChild("page2_button")
		button3 = self.GetChild("page3_button")
		button4 = self.GetChild("page4_button")
		button2.SetUp()
		button3.SetUp()
		button4.SetUp()
		
		self.saveName = "lib/FastEquipPage1.pyc"
		if os.path.exists(self.saveName):
			open(self.saveName, "r").read().split()
		else:
			open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")

	def __pag2_button(self):
		constInfo.FAST_PAGE = 2
		button1 = self.GetChild("page1_button")
		button3 = self.GetChild("page3_button")
		button4 = self.GetChild("page4_button")
		button1.SetUp()
		button3.SetUp()
		button4.SetUp()
		
		self.saveName = "lib/FastEquipPage2.pyc"
		if os.path.exists(self.saveName):
			open(self.saveName, "r").read().split()
		else:
			open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")

	def __pag3_button(self):
		constInfo.FAST_PAGE = 3
		button1 = self.GetChild("page1_button")
		button2 = self.GetChild("page2_button")
		button4 = self.GetChild("page4_button")
		button1.SetUp()
		button2.SetUp()
		button4.SetUp()
		
		self.saveName = "lib/FastEquipPage3.pyc"
		if os.path.exists(self.saveName):
			open(self.saveName, "r").read().split()
		else:
			open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")

	def __pag4_button(self):
		constInfo.FAST_PAGE = 4
		button1 = self.GetChild("page1_button")
		button2 = self.GetChild("page2_button")
		button3 = self.GetChild("page3_button")
		button1.SetUp()
		button2.SetUp()
		button3.SetUp()
		
		self.saveName = "lib/FastEquipPage4.pyc"
		if os.path.exists(self.saveName):
			open(self.saveName, "r").read().split()
		else:
			open(self.saveName, "w").write("@[email protected]@[email protected]@[email protected]@[email protected]@")

	def __change_button(self):
		for i in range(1,10):
			if self.tokens[i-1] != "@":
				net.SendItemUsePacket(int(self.tokens[i-1]))	

	def OverInItem(self, slotNumber):
		if self.tooltipItem:
			self.tooltipItem.SetInventoryItem(int(self.tokens[slotNumber-1]))

	def OnOverOutItem(self):
		if self.tooltipItem:
			self.tooltipItem.HideToolTip()

	def SelectItemSlot(self, itemSlotIndex):
		isAttached = mouseModule.mouseController.isAttached()
		if isAttached:
			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
			itemIndex = player.GetItemIndex(attachedSlotPos)
			itemCount = player.GetItemCount(attachedSlotPos)
			item.SelectItem(itemIndex)
			itemType = item.GetItemType()
			itemSubType = item.GetItemSubType()
			
			if item.IsWearableFlag(item.WEARABLE_BODY):
				self.tokens[1-1] = attachedSlotPos
				snd.PlaySound("sound/ui/equip_metal_armor.wav")
			elif item.IsWearableFlag(item.WEARABLE_HEAD):
				self.tokens[2-1] = attachedSlotPos
				snd.PlaySound("sound/ui/drop.wav")
			elif item.IsWearableFlag(item.WEARABLE_FOOTS):
				self.tokens[3-1] = attachedSlotPos
				snd.PlaySound("sound/ui/drop.wav")
			elif item.IsWearableFlag(item.WEARABLE_WRIST):
				self.tokens[4-1] = attachedSlotPos
				snd.PlaySound("sound/ui/drop.wav")
			elif item.IsWearableFlag(item.WEARABLE_WEAPON):
				self.tokens[5-1] = attachedSlotPos
				if itemSubType == 2:
					snd.PlaySound("sound/ui/equip_bow.wav")
				else:
					snd.PlaySound("sound/ui/equip_metal_weapon.wav")
			elif item.IsWearableFlag(item.WEARABLE_NECK):
				self.tokens[6-1] = attachedSlotPos
				snd.PlaySound("sound/ui/equip_ring_amulet.wav")
			elif item.IsWearableFlag(item.WEARABLE_EAR):
				self.tokens[7-1] = attachedSlotPos
				snd.PlaySound("sound/ui/equip_ring_amulet.wav")
			elif item.IsWearableFlag(item.WEARABLE_SHIELD):
				self.tokens[8-1] = attachedSlotPos
				snd.PlaySound("sound/ui/drop.wav")
			elif item.IsWearableFlag(item.WEARABLE_ARROW):
				self.tokens[9-1] = attachedSlotPos
				snd.PlaySound("sound/ui/drop.wav")
			else:
				return
			
			open(self.saveName, "w").write("%st%st%st%st%st%st%st%st%s" % tuple(self.tokens))	
			mouseModule.mouseController.DeattachObject()

	def OnUpdate(self):	
		tokens = open(self.saveName, "r").read().split()		
		self.tokens = tokens
		for i in range(1,10):	
			if tokens[i-1] == "@":
				self.wndEquip.SetItemSlot(i, 0, 0)
			else:
				itemIndex = player.GetItemIndex(int(tokens[i-1]))
				if itemIndex != 0:
					item.SelectItem(itemIndex)
					if i == 1 and item.IsWearableFlag(item.WEARABLE_BODY):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 2 and item.IsWearableFlag(item.WEARABLE_HEAD):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 3 and item.IsWearableFlag(item.WEARABLE_FOOTS):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 4 and item.IsWearableFlag(item.WEARABLE_WRIST):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 5 and item.IsWearableFlag(item.WEARABLE_WEAPON):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 6 and item.IsWearableFlag(item.WEARABLE_NECK):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 7 and item.IsWearableFlag(item.WEARABLE_EAR):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 8 and item.IsWearableFlag(item.WEARABLE_SHIELD):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					elif i == 9 and item.IsWearableFlag(item.WEARABLE_ARROW):
						self.wndEquip.SetItemSlot(i, itemIndex, 0)
					else:
						self.wndEquip.SetItemSlot(i, 0, 0)
						self.tokens[i-1] = "@"
						open(self.saveName, "w").write("%st%st%st%st%st%st%st%st%s" % tuple(self.tokens))
						continue
				else:
					self.wndEquip.SetItemSlot(i, 0, 0)				

	def OnPressEscapeKey(self):
		self.Close()
		snd.PlaySound("sound/ui/click.wav")
		return TRUE

 

So i tryed to run it on an client.

 

What i added to the game.py:

 

def ToggleFastEquipWindow(self):
		import uifastequip
		uifastequip.changeequip().Show()

 

and i connect it with the button F6:

onPressKeyDict[app.DIK_F6]    = lambda : self.__ToggleFastEquipWindow()

Client starts normalie, no problems but when i press F6 ingame nothing happens.

 

My syserr after pressing the button:

1104 15:50:18446 :: Traceback (most recent call last):

1104 15:50:18446 ::   File "game.py", line 1188, in OnKeyDown

1104 15:50:18446 ::   File "game.py", line 332, in <lambda>

1104 15:50:18446 :: AttributeError
1104 15:50:18446 :: : 
1104 15:50:18446 :: 'GameWindow' object has no attribute '_GameWindow__ToggleFastEquipWindow'
1104 15:50:18446 :: 

1104 15:50:18446 :: Traceback (most recent call last):

1104 15:50:18446 ::   File "game.py", line 1188, in OnKeyDown

1104 15:50:18446 ::   File "game.py", line 332, in <lambda>

1104 15:50:18446 :: AttributeError
1104 15:50:18446 :: : 
1104 15:50:18446 :: 'GameWindow' object has no attribute '_GameWindow__ToggleFastEquipWindow'
1104 15:50:18446 :: 

 

so... i dont think that i did something wrong, did i?

 

are you got any idea whats the problem?

 

 

king regards

 

 

 

Link to comment
  • Answers 3
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

3 answers to this question

Recommended Posts

  • 0

[TAB]def   __ToggleFastEquipWindow(self):
[TAB][TAB]import uiequipchanger

[TAB][TAB]self.equip = uiequipchanger.changeequip()

[TAB][TAB]self.equip.Show()

 

script name change uiequipchanger.py

no tested..

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 1

      Halloween 2021 Ninja M V2

    2. 0

      Visual Studio 2010 Ultimate

    3. 1

      Reduce server memory usage

    4. 31

      Metin2 Project - How to create à Metin2 private server on virtual machine

    5. 1

      Use BeltInventory slots without Belt

  • Recently Browsing

    • No registered users viewing this page.

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.