Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

channel problem

Status
Not open for further replies.
Newbie Spellweaver
Joined
Apr 9, 2014
Messages
38
Reaction score
1
How can I fix unauthorized members can not change the channel?


My Code:
Code:
using GameServer.Networking;using GameServer.Networking.Packets;
using GameServer.Virtual_Objects.User;
using System;


namespace GameServer.Networking.Handlers
{
	internal class HANDLE_CHANNEL_SWITCH : PacketHandler
	{
		public HANDLE_CHANNEL_SWITCH()
		{
		}


		public override void Handle(virtualUser User)
		{
			bool flag;
			try
			{
				int num = int.Parse(base.getNextBlock());
				flag = (num == 1 || User.Rank > 2 ? false : num != 4);
				if (flag)
				{
					User.Channel = 1;
					User.Page = 0;
					User.send(new PACKET_CHANGE_CHANNEL(User));
					User.send(new PACKET_ROOM_LIST(User, User.Page));
					if (num != -1)
					{
						User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Room_ToAll, "SYSTEM >> This Channel is not avaible yet!", (long)999, "NULL"));
					}
				}
				else
				{
					User.Channel = num;
					User.Page = 0;
					User.send(new PACKET_CHANGE_CHANNEL(User));
					User.send(new PACKET_ROOM_LIST(User, User.Page));
				}
			}
			catch
			{
			}
		}
	}
}
 
Newbie Spellweaver
Joined
Oct 6, 2013
Messages
53
Reaction score
18
Because your question is already answered for some server sources :)

Anyway, just change the flag value
Code:
flag = (num == 1 || User.Rank > 2 ? false : num != 4);

to make it always true by deleting the User.Rank check or just leaving it like this

EDIT: I messed up a bit for rushing:

Code:
flag = ( num == 1 ? true : false);
 
Last edited:
Newbie Spellweaver
Joined
Oct 6, 2013
Messages
53
Reaction score
18
Sigh... Just kill the condition. I don think you want to do that though. The channels are locked for regular users because they arent fully coded.

Code:
    try{                                    User.Channel = num;
					User.Page = 0;
					User.send(new PACKET_CHANGE_CHANNEL(User));
					User.send(new PACKET_ROOM_LIST(User, User.Page));}
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
Code:
    try{                                    User.Channel = num;
                    User.Page = 0;
                    User.send(new PACKET_CHANGE_CHANNEL(User));
                    User.send(new PACKET_ROOM_LIST(User, User.Page));}

Why would you put a try & catch on a block that will never trigger an exception?

The fix for this problem:

Solution:
Code:
flag = (num > 4 || num < 1);

The reason why:
if the flag is true then the code will send the user to the first channel (CQC with id 1).
if the flag is false then the code will send you the the provided channel id.

with this line it will allow you to go to the other channels but it will not allow you to have 'fake' channel numbers, if it's a fake one then it will just send you to channel 1 (CQC).

This is basic programming logic people...
 
Last edited:
Newbie Spellweaver
Joined
Oct 6, 2013
Messages
53
Reaction score
18
Thanks for your reply CodeDragon. Indeed, I tend to respect too much the original code and logic, that´s why I left the try{}. Next time I´ll post a better answer.
 
Status
Not open for further replies.
Back
Top