Jump to content
Maintenance ×
×
×
  • Create New...
  • 0

how connect GUI panel bug


dadas82

Question

 

fix please

 

Spoiler

import ui
import net
import app
import chat
import math
import wndMgr
import serverInfo
import background
import ServerStateChecker
import uichat

class ChannelChanger(ui.ScriptWindow):
    def __init__(self):
        ui.ScriptWindow.__init__(self)

        self.__MakeWindow()
        self.__MakeBoard()
        self.__Fill_Up_ChannelList()

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

    def Destroy(self):
        self.Hide()
        return TRUE

    def __MakeWindow(self):
        ServerStateChecker.Create(self)
        self.SetSize(150, 190)
        self.SetPosition(
            (wndMgr.GetScreenWidth() / 2) - int(math.floor(self.GetWidth() / 2.)),
            (wndMgr.GetScreenHeight() / 2) - int(math.floor(self.GetHeight() / 2.))
        )
        #self.AddFlag("movable")
        self.AddFlag("float")
        self.Show()

    def __MakeBoard(self):
        self.Board = ui.Board()
        self.Board.SetParent(self)
        self.Board.SetSize(self.GetWidth(), self.GetHeight())
        self.Board.SetPosition(0, 0)
        #self.Board.AddFlag("movable")
        self.Board.AddFlag("float")
        self.Board.Show()

        self.TitleBar = ui.TitleBar()
        self.TitleBar.SetParent(self.Board)
        self.TitleBar.SetPosition(7, 7)
        self.TitleBar.MakeTitleBar(self.GetWidth() - 2 * 7, 'red')
        self.TitleBar.SetCloseEvent(self.Close)
        self.TitleBar.Show()

        self.RefreshButton = ui.Button()
        self.RefreshButton.SetParent(self.TitleBar)
        self.RefreshButton.SetPosition(3, 3)
        self.RefreshButton.SetUpVisual("d:/ymir work/ui/game/guild/refresh_button_01.sub")
        self.RefreshButton.SetOverVisual("d:/ymir work/ui/game/guild/refresh_button_02.sub")
        self.RefreshButton.SetDownVisual("d:/ymir work/ui/game/guild/refresh_button_03.sub")
        self.RefreshButton.SetToolTipText("Yenile", 0, - 23)
        self.RefreshButton.SetEvent(lambda : self.__Fill_Up_ChannelList())
        self.RefreshButton.Show()

        self.TitleText = ui.TextLine()
        self.TitleText.SetParent(self.TitleBar)
        self.TitleText.SetPosition(0, 4)
        self.TitleText.SetText("Kanal seç")
        self.TitleText.SetWindowHorizontalAlignCenter()
        self.TitleText.SetHorizontalAlignCenter()
        self.TitleText.Show()

        self.ServerName = ui.TextLine()
        self.ServerName.SetParent(self.TitleBar)
        self.ServerName.SetPosition(0, self.TitleBar.GetHeight())
        self.ServerName.SetText(str(net.GetServerInfo()).split(",")[0])
        self.ServerName.SetWindowHorizontalAlignCenter()
        self.ServerName.SetHorizontalAlignCenter()
        self.ServerName.Show()

        self.ChannelListBase = ui.SlotBar()
        self.ChannelListBase.SetParent(self.Board)
        self.ChannelListBase.SetSize(self.Board.GetWidth() - 2 * 16, 5 * 18 - 4+20)
        self.ChannelListBase.SetPosition(16 , 7 + self.TitleBar.GetHeight() + 6 + 10)
        self.ChannelListBase.Show()

        self.ChannelList = ui.ListBox()
        self.ChannelList.SetParent(self.ChannelListBase)
        self.ChannelList.SetSize(self.ChannelListBase.GetWidth()- 20, self.ChannelListBase.GetHeight())
        self.ChannelList.SetPosition(0, 0)
        self.ChannelList.SetEvent(ui.__mem_func__(self.__OnSelectChannel))
        self.ChannelList.Show()

        self.ChangeButton = ui.Button()
        self.ChangeButton.SetParent(self.Board)
        self.ChangeButton.SetPosition(self.Board.GetWidth() / 2 - 44, self.Board.GetHeight() - 32)
        self.ChangeButton.SetUpVisual('d:/ymir work/ui/public/Large_button_01.sub')
        self.ChangeButton.SetOverVisual('d:/ymir work/ui/public/Large_button_02.sub')
        self.ChangeButton.SetDownVisual('d:/ymir work/ui/public/Large_button_03.sub')
        self.ChangeButton.SetEvent(lambda : self.__OnClickConnectButton())
        self.ChangeButton.SetText("Değiştir")
        self.ChangeButton.Show()
        self.DisableChangeButton()

    def DisableChangeButton(self):
            
        self.ChangeButton.Disable()
        self.ChangeButton.Down()
        self.ChangeButton.ButtonText.SetFontColor(0.4, 0.4, 0.4)

    def EnableChangeButton(self):
            
        self.ChangeButton.Enable()
        self.ChangeButton.SetUp()
        self.ChangeButton.ButtonText.SetFontColor(1, 1, 1)

    def __GetRegionID(self):
        return 0

    def __GetServerID(self):
        regionID = self.__GetRegionID()
        for i in serverInfo.REGION_DICT[regionID].keys():
            if serverInfo.REGION_DICT[regionID]["name"] == net.GetServerInfo().split(",")[0]:
                serverID = int(i)
                break

        return serverID

    def __Fill_Up_ChannelList(self):
        self.__RequestServerStateList()
        self.__RefreshServerStateList()
        #self.ChannelList.SelectItem(0)

    def __RequestServerStateList(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            return
        ServerStateChecker.Initialize(self)
        for id, channelDataDict in channelDict.items():
            key=channelDataDict["key"]
            ip=channelDataDict["ip"]
            udp_port=channelDataDict["udp_port"]
            ServerStateChecker.AddChannel(key, ip, udp_port)
        ServerStateChecker.Request()

    def __RefreshServerStateList(self):
        regionID = self.__GetRegionID()
        serverID = self.__GetServerID()
        bakChannelID = self.ChannelList.GetSelectedItem()

        self.ChannelList.ClearItem()

        try:
            channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
        except:
            return

        for channelID, channelDataDict in channelDict.items():
            channelName = channelDataDict["name"]
            channelState = channelDataDict["state"]
            self.ChannelList.InsertItem(channelID, "%s %s" % (channelName, channelState))

        self.ChannelList.SelectItem(bakChannelID-1)

    def NotifyChannelState(self, addrKey, state):
        try:
            stateName = serverInfo.STATE_DICT[state]
        except:
            stateName = serverInfo.STATE_NONE

        regionID  = int(addrKey / 1000)
        serverID  = int(addrKey / 10) % 100
        channelID = addrKey % 10

        try:
            serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["state"] = stateName
            self.__RefreshChannelStateList()
        except:
            pass

    def __IsSpecialMap(self):
        dis_maps = [
            "season1/metin2_map_oxevent",
            "season2/metin2_map_guild_inside01",
            "season2/metin2_map_empirewar01",
            "season2/metin2_map_empirewar02",
            "season2/metin2_map_empirewar03",
            "metin2_map_dragon_timeattack_01",
            "metin2_map_dragon_timeattack_02",
            "metin2_map_dragon_timeattack_03",
            "metin2_map_skipia_dungeon_boss",
            "metin2_map_skipia_dungeon_boss2",
            "metin2_map_devilsCatacomb",
            "metin2_map_deviltower1",
            "metin2_map_t1",
            "metin2_map_t2",
            "metin2_map_t3",
            "metin2_map_t4",
            "metin2_map_t5",
            "metin2_map_wedding_01",
            "metin2_map_duel",
            "metin2_map_orclabyrinth",
            "metin2_map_n_flame_dungeon_01",
            "metin2_map_n_snow_dungeon_01"
        ]
        if str(background.GetCurrentMapName()) in dis_maps:
            return TRUE
        return FALSE

    def __OnSelectChannel(self):
        if self.ChangeButton.IsDown():
            self.EnableChangeButton()

    def __OnClickConnectButton(self):

        ServerStateChecker.Update()
        channelID = self.ChannelList.GetSelectedItem()
        if not channelID:
            return
        if net.GetServerInfo().strip().split(", ")[1] == self.ChannelList.textDict[self.ChannelList.selectedLine].strip().split(" ")[0]:
            chat.AppendChat(1, "Kanal değiştiremezsin. Zaten bu kanaldasın.")
            return
        elif self.__IsSpecialMap():
            chat.AppendChat(1, "Burada haritada kanal değiştiremezsin.")
            return
        net.SetServerInfo(net.GetServerInfo()[:-1] + str(channelID))
        self.Close()
        net.SendChatPacket("/channel "+str(channelID))

    def DirectConnect(self, ChannelIP, ChannelPort, AuthServerIP, AuthServerPort):
        net.SetLoginInfo(decode_string(net.ACCOUNT_ID), decode_string(net.ACCOUNT_PW))
        net.ConnectToAccountServer(ChannelIP, ChannelPort, AuthServerIP, AuthServerPort)
        net.DirectEnter(0)
        net.SendSelectCharacterPacket(0)
        net.SendEnterGamePacket()

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

    def Close(self):
        ServerStateChecker.Initialize(self)
        self.Hide()


    def OnPressEscapeKey(self):
        self.Close()
        return TRUE

    def OnUpdate(self):
        ServerStateChecker.Update()
 

 

Link to comment
Share on other sites

  • Answers 4
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

4 answers to this question

Recommended Posts

  • 0

well you have to add a pcket with timer in game source and client.So he can change channel,teleport after 10 seccond after opening shop.

ecause if u change just client side it wont help it can get bypassed.Is source problem.

Link to comment
Share on other sites

  • 0
3 hours ago, Root said:

well you have to add a pcket with timer in game source and client.So he can change channel,teleport after 10 seccond after opening shop.

ecause if u change just client side it wont help it can get bypassed.Is source problem.

I give it five second. It is bug again when you are done :(

 

Spoiler

EVENTFUNC(channel_event)
{
    TimedEventInfo * info = dynamic_cast<TimedEventInfo *>( event->info );
    
    if ( info == NULL )
    {
        sys_err( "timed_event> <Factor> Null pointer" );
        return 0;
    }

    LPCHARACTER    ch = info->ch;
    if (ch == NULL) { // <Factor>
        return 0;
    }
    LPDESC d = ch->GetDesc();

    if (info->left_second <= 0)
    {
        ch->m_pkTimedEvent = NULL;

        TPacketNeedLoginLogInfo acc_info;
        acc_info.dwPlayerID = ch->GetDesc()->GetAccountTable().id;

        db_clientdesc->DBPacket( HEADER_GD_VALID_LOGOUT, 0, &acc_info, sizeof(acc_info) );

        LogManager::instance().DetailLoginLog( false, ch );

        ch->ChannelSwitch(new_ch);

        return 0;
    }
    else
    {
        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d초 남았습니다."), info->left_second);
        --info->left_second;
    }

    return PASSES_PER_SEC(1);
}

ACMD(do_move_channel)
{
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));

    if (!*arg1)
        return;

    str_to_number(new_ch, arg1);

    if( new_ch < 1 || new_ch > 4)
        return;
    
    if (new_ch == g_bChannel)
        {
            ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel_Move_ch"));
            return;
        }

    if (!ch->IsPC())
        return;

    ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel_Move"));

    int nExitLimitTime = 10;

    if (ch->IsHack(false, true, nExitLimitTime) && false == CThreeWayWar::instance().IsSungZiMapIndex(ch->GetMapIndex()) && (!ch->GetWarMap() || ch->GetWarMap()->GetType() == GUILD_WAR_TYPE_FLAG))
        return;

    TimedEventInfo* info = AllocEventInfo<TimedEventInfo>();

    {
        if (ch->IsPosition(POS_FIGHTING))
            info->left_second = 10;
        else
            info->left_second = 5;
    }

    info->ch = ch;
    info->subcmd = subcmd;
    strlcpy(info->szReason, argument, sizeof(info->szReason));

    ch->m_pkTimedEvent    = event_create(channel_event, info, 1);
}

 

Link to comment
Share on other sites

  • 0
  • Premium

Dude you should go into the Offline shop creation and put there the check for the channel changer event, if someone uses the channel changer with the shop open return and print the error.
Same thing for the channel changer but you already have all the things you need in the source, just search for them

Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 1

      Metin2 TitleBar Move Frezze

    2. 1

      Metin2 TitleBar Move Frezze

    3. 0

      Navicat "Trial" Reset

    4. 13

      Item ToolTip Width Fix

    5. 0

      Guild icon wrong position

    6. 3

      Monster health

    7. 4

      Luffy Pet

    8. 38

      Core X → Top Metin2 & Metin2 Download → Changelogs

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.