Jump to content

Channel Changer GF Like


Recommended Posts

  • Premium

M2 Download Center

This is the hidden content, please
( Internal )

Hey,

 

Move Channel System with countdown (same as logout, change character and quit), similar to gf.

command: /move_channel number

 

Files to edit char.cpp, char.h, cmd.cpp, cmd.h, cmd_general.cpp

char.cpp

Spoiler

find



void CHARACTER::StartWarpNPCEvent()

add above



// MOVE_CHANNEL
void CHARACTER::MoveChannel(int iNewChannel)
{
	long lAddr, lMapIndex;
	WORD wPort;

	long x = GetX();
	long y = GetY();

	if (!CMapLocation::Instance().Get(x, y, lMapIndex, lAddr, wPort))
		return;

	std::map<WORD, BYTE> ChannelsPorts;
	for (BYTE i = 0; i < 6; i++) //replace with maximum channels
	{
		//core1
		ChannelsPorts[13 * 1000 + i] = i + 1; // 1300i - channel port 
		//core2
		//ChannelsPorts[13 * 1000 + 50 + i] = i + 1; // 1305i - channel port
		//etc.
	}

	int iChannel = ChannelsPorts.find(wPort) != ChannelsPorts.end() ? ChannelsPorts[wPort] : 0;

	Stop();
	Save();

	if (GetSectree())
	{
		GetSectree()->RemoveEntity(this);
		ViewCleanup();
		EncodeRemovePacket(this);
	}

	TPacketGCWarp p;
	p.bHeader = HEADER_GC_WARP;
	p.lX = x;
	p.lY = y;
	p.lAddr = lAddr;
	p.wPort = (wPort - (iChannel - 1) + (iNewChannel - 1));

	GetDesc()->Packet(&p, sizeof(TPacketGCWarp));
}
// END_OF_MOVE_CHANNEL

 

char.h

Spoiler

find



		void				StartWarpNPCEvent();

add bellow



		// MOVE_CHANNEL
		void                MoveChannel(int new_ch);
		// END_OF_MOVE_CHANNEL

 

cmd.cpp

Spoiler

find



	{ "mall_close",	do_mall_close,		0,			POS_DEAD,	GM_PLAYER	},

add bellow



	// MOVE_CHANNEL
	{ "move_channel", do_cmd, SCMD_MOVE_CHANNEL, POS_DEAD, GM_PLAYER },
	// END_OF_MOVE_CHANNEL

 

cmd.h

Spoiler

find



struct command_info

add above



// MOVE_CHANNEL
extern int channel_index;
// END_OF_MOVE_CHANNEL

 

cmd_general.cpp

Spoiler

1) find



extern int g_server_id;

1) add above



// MOVE_CHANNEL
#include "map_location.h"
// END_OF_MOVE_CHANNEL

2) find



			switch (info->subcmd)
			{
				case SCMD_LOGOUT:
				case SCMD_QUIT:
				case SCMD_PHASE_SELECT:

2) add bellow



				// MOVE_CHANNEL
				case SCMD_MOVE_CHANNEL:
				// END_OF_MOVE_CHANNEL

3) find



			case SCMD_PHASE_SELECT:
				{
					ch->Disconnect("timed_event - SCMD_PHASE_SELECT");

					if (d)
					{
						d->SetPhase(PHASE_SELECT);
					}
				}
				break;

3) add bellow



			// MOVE_CHANNEL
			case SCMD_MOVE_CHANNEL:
				ch->MoveChannel(channel_index);
				break;
			// END_OF_MOVE_CHANNEL

4) find



		case SCMD_PHASE_SELECT:
			ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Äł¸ŻĹ͸¦ ŔüČŻ ÇŐ´Ď´Ů. Ŕá˝Ă¸¸ ±â´Ů¸®ĽĽżä."));
			break;

4) add bellow



		// MOVE_CHANNEL
		case SCMD_MOVE_CHANNEL:
			//ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SCMD_MOVE_CHANNEL"));
			char arg1[256];
			one_argument(argument, arg1, sizeof(arg1));
			if (!*arg1)
				return;

			int new_ch;
			str_to_number(new_ch, arg1);
			if (new_ch < 1 || new_ch > 6)   // replace with your channel count
				return;
			if (!ch->IsPC())
				return;
			channel_index = new_ch;
			break;
		// END_OF_MOVE_CHANNEL

5) find



		case SCMD_LOGOUT:
		case SCMD_QUIT:
		case SCMD_PHASE_SELECT:
		{
			TimedEventInfo* info = AllocEventInfo<TimedEventInfo>();

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

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

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

5) add bellow



		// MOVE_CHANNEL
		case SCMD_MOVE_CHANNEL:
		{
			int lMapArray[] = { 66, 113, 207 }; // disallowed map index

			long lAddr, lMapIndex;
			WORD wPort;

			long x = ch->GetX();
			long y = ch->GetY();

			if (!CMapLocation::Instance().Get(x, y, lMapIndex, lAddr, wPort))
			{
				sys_err("Can not find map location index[%ld] x[%ld] y[%ld] name[%s]", lMapIndex, x, y, ch->GetName());
				return;
			}

			if (lMapIndex >= 10000)
			{
				sys_err("Map index higher or equal to 10000");
				return;
			}

			for (int i = 0; i < _countof(lMapArray); i++)
			{
				if (lMapIndex == lMapArray[i])
				{
					ch->ChatPacket(CHAT_TYPE_INFO, "You can't change channel while you're inside this location");
					return;
				}
			}
			

			std::map<WORD, BYTE> ChannelsPorts;
			for (BYTE i = 0; i < 6; i++) //replace with maximum channels
			{
				//core1
				ChannelsPorts[13 * 1000 + i] = i + 1; // channel port
				//core2
				//ChannelsPorts[13 * 1000 + 50 + i] = i + 1; // channel port
				//etc.
			}

			int iChannel = ChannelsPorts.find(wPort) != ChannelsPorts.end() ? ChannelsPorts[wPort] : 0;

			if (iChannel == 0)
			{
				ch->ChatPacket(CHAT_TYPE_INFO, "This port is not available! (%d)", wPort);
				return;
			}

			if (wPort == (wPort - (iChannel - 1) + (channel_index - 1)))
			{
				ch->ChatPacket(CHAT_TYPE_INFO, "You're on this channel, select another one!");
				return;
			}

			TimedEventInfo* info = AllocEventInfo<TimedEventInfo>();

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

			ch->ChatPacket(CHAT_TYPE_INFO, "Please wait a moment. Changing channel...");

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

			ch->m_pkTimedEvent = event_create(timed_event, info, 1);
		}
		break;
		// END_OF_MOVE_CHANNEL

 

 

CALCULATE YOUR PORTS HERE

https://repl.it/@Nevisor/ChannelPortCalculator

  • Metin2 Dev 70
  • Eyes 1
  • Think 2
  • Scream 2
  • Lmao 1
  • Good 28
  • Love 3
  • Love 45
Link to comment
Share on other sites

  • Bronze

This is the hidden content, please

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

d:/ymir work/ui/game/myshop_deco/select_btn_01.sub

...

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 25
  • Not Good 1
  • Good 6
  • Love 13
Link to comment
Share on other sites

and ui python part?

vor 1 Stunde schrieb Abel(Tiger):

This is the hidden content, please

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

d:/ymir work/ui/game/myshop_deco/select_btn_01.sub

...

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 4
  • Love 1
Link to comment
Share on other sites

  • 6 months later...
9 hours ago, Nevisor said:

There is part in my game.py that is doing that as I remember

Ok.. it is solved now but there is another bug:
when I am shopping and try to change channel (click on "OK"), after teleport it will refresh on chosen channel instead of staying, because I cant change channel while shopping..

If I helped you, do not forget to press "Thanks" button! 

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...
  • 2 weeks later...
  • 2 months later...
  • 1 year later...
  • 11 months later...

When changing the channel, the game returns to the login page after 3 seconds.

Can anyone explain how to configure the ports? More exactly this part: p.wPort = (wPort - 100*(g_bChannel-1) + 100*(channelId-1));

For exemple: I have ch1_core1: 30000
For exemple: I have ch1_core2: 30001

For exemple: I have ch2_core1: 30002
For exemple: I have ch2_core2: 30003

How it works? What is the logic ? Thank you very much.

Link to comment
Share on other sites

  • 8 months later...
  • 7 months later...

cmd.h


enum SCMD_CMD
{
    SCMD_LOGOUT,
    SCMD_QUIT,
    SCMD_PHASE_SELECT,
    SCMD_SHUTDOWN,

// MOVE_CHANNEL

    SCMD_MOVE_CHANNEL,

// END_OF_MOVE_CHANNEL
};

 

 

cmd.h

 

delete

// MOVE_CHANNEL

extern int channel_index;

// END_OF_MOVE_CHANNEL

 

 

cmd_general.cpp

 

add under includes

 

// MOVE_CHANNEL

int channel_index;

// END_OF_MOVE_CHANNEL

Edited by Giecu
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

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.