Regelt
Code:
######## Channel Switcher #######
######## Script Copyright by Yoshix3 @ Poseidon2 #######
import ui
import net
import constInfo
class ChannelBoard(ui.BoardWithTitleBar):
def __init__(self):
ui.BoardWithTitleBar.__init__(self)
self.SetSize(150, 180)
self.SetCenterPosition()
self.AddFlag("movable")
self.AddFlag("float")
self.SetTitleName("Channelswitcher")
self.SetCloseEvent(self.__clo__)
self.Hide()
pos = [[30,40],[30,70],[30,100],[30,130]]
self.Buttons = {}
for line in xrange(4):
self.Buttons["Btn"+str(line)] = ui.Button()
self.Buttons["Btn"+str(line)].SetParent(self)
self.Buttons["Btn"+str(line)].SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
self.Buttons["Btn"+str(line)].SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
self.Buttons["Btn"+str(line)].SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
self.Buttons["Btn"+str(line)].SetText("Wechsle in Channel "+str(line+1))
self.Buttons["Btn"+str(line)].SetPosition(pos[line][0],pos[line][1])
self.Buttons["Btn"+str(line)].Show()
self.Buttons["Btn0"].SetEvent(lambda: self.ChangeChannel(1))
self.Buttons["Btn1"].SetEvent(lambda: self.ChangeChannel(2))
self.Buttons["Btn2"].SetEvent(lambda: self.ChangeChannel(3))
self.Buttons["Btn3"].SetEvent(lambda: self.ChangeChannel(4))
def ChangeChannel(self, channel):
if str(channel) == net.GetServerInfo().split("Channel ")[1]:
import chat
chat.AppendChat(chat.CHAT_TYPE_INFO, "Du bist bereits in diesem Channel aktiv.")
else:
# slot = int(self.stream.GetCharacterSlot())
slot = 0
self.SetChannel(channel,constInfo.ID,constInfo.PWD,slot)
def OnPressEscapeKey(self):
self.Hide()
return TRUE
def SetChannel(self, channel,id, pwd,slot):
channelport = ['13001','13002','13007','13013']
port = int(channel)-1
# constInfo.IS_CHANGE = str(channel)
# constInfo.Slot = str(slot)
net.Disconnect()
net.SetLoginInfo(id, pwd)
net.SetServerInfo("Poseidon2 - Channel "+str(channel))
net.ConnectToAccountServer("metin2.poseidon2.eu", int(channelport[port]), "metin2.poseidon2.eu", 11002)
net.DirectEnter(0)
# net.DirectEnter(slot)
net.SendSelectCharacterPacket(0)
net.SendEnterGamePacket()
def __del__(self):
self.Hide()
ui.BoardWithTitleBar.__del__(self)
def __clo__(self):
self.Hide()
def _Open(self):
if self.IsShow():
self.Hide()
else:
self.Show()
def Destroy(self):
self.__del__()
return TRUE