Наследование: IGameClient, IDisposable
Пример #1
0
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			lock (this)
			{
				string dllName = packet.ReadString(16);
				packet.Position = 0x50;
				uint upTime = packet.ReadInt();
				string text = string.Format("Client crash ({0}) dll:{1} clientUptime:{2}sec", client.ToString(), dllName, upTime);
				if (log.IsInfoEnabled)
					log.Info(text);

				if (log.IsDebugEnabled)
				{
					log.Debug("Last client sent/received packets (from older to newer):");
					
					foreach (IPacket prevPak in client.PacketProcessor.GetLastPackets())
					{
						log.Info(prevPak.ToHumanReadable());
					}
				}
					
				//Eden
				if(client.Player!=null)
				{
					GamePlayer player = client.Player;
					client.Out.SendPlayerQuit(true);
					client.Player.SaveIntoDatabase();
					client.Player.Quit(true);
					client.Disconnect();
				}
			}
		}
Пример #2
0
		public void OnCommand(GameClient client, string[] args)
		{
			if (IsSpammingCommand(client.Player, "search"))
				return;

			GamePlayer player = client.Player;

			if (player == null)
				return;

			bool searched = false;

			foreach (AbstractQuest quest in player.QuestList)
			{
				if (quest.Command(player, AbstractQuest.eQuestCommand.Search))
				{
					searched = true;
					break;
				}
			}

			if (searched == false)
			{
				player.Out.SendMessage("You can't do that here!", DOL.GS.PacketHandler.eChatType.CT_Important, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow);
			}

		}
        public static void OnCharacterCreate(GameClient client, ClientHeroCreatePacket packet)
        {
            Logger.Instance.Info("Attempting to create hero with name {0}", packet.Name);
            bool heroExists;

            using (var context = new GameDatabaseContext())
            {
                // We try to load a hero with a similar name to see if they exist
                heroExists = context.Characters.Any(x => x.Name.ToUpper() == packet.Name.ToUpper());
            }

            if (heroExists)
            {
                client.Send(new ServerHeroCreateResponsePacket(HeroStatus.Invalid));
                return;
            }

            // Create a hero and attach it if it dosen't exist yet

            var hero = new UserHero(client.Account, 0, 0, 0, packet.Name);

            // Save our hero into the database
            using (var context = new GameDatabaseContext())
            {
                context.Accounts.Attach(client.Account);
                context.Entry(client.Account).Collection(a => a.Heroes).Load();
                client.Account.Heroes.Add(hero);
                context.SaveChanges();
            }

            client.Send(new ServerHeroCreateResponsePacket(HeroStatus.OK));

            SendHeroList(client);
        }
Пример #4
0
        public static void Logout(GameClient client)
        {
            if (client.Account == null)
                return;

            var account = client.Account;

            using (var context = new GameDatabaseContext())
            {
                context.Accounts.Attach(account);

                account.IsOnline = false;

                context.SaveChanges();
            }

            client.Account = null;

            if (client.Zone == null)
                return;

            if (client.Hero == null)
                return;

            client.Zone.OnClientLeave(client);
        }
        public static void OnCharacterCreate(GameClient client, ClientLoadingFinishedPacket packet)
        {
            var player = client.HeroEntity;
            var zone = player.Zone;

            zone.TryAndAddPlayer(player);
        }
Пример #6
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int user_id = packet.ReadInt();
            //PlayerInfo info = client.Player.PlayerCharacter;

            return 0;
        }
Пример #7
0
        public override void Execute(GameClient session, string[] pms)
        {
            var user = AzureEmulator.GetHabboForName(pms[0]);

            if (user == null)
            {
                session.SendWhisper(TextManager.GetText("user_not_found"));
                return;
            }
            if (user.Rank >= session.GetHabbo().Rank)
            {
                session.SendWhisper(TextManager.GetText("user_is_higher_rank"));
                return;
            }
            using (var adapter = AzureEmulator.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery("DELETE FROM users_bans WHERE value = @name");
                adapter.AddParameter("name", user.UserName);
                adapter.RunQuery();
                AzureEmulator.GetGame()
                    .GetModerationTool()
                    .LogStaffEntry(session.GetHabbo().UserName, user.UserName, "Unban",
                        string.Format("User has been Unbanned [{0}]", pms[0]));
                return;
            }
        }
Пример #8
0
 public void FetchChatInfo(GameClient client)
 {
     GSTask t = new GSTask();
     t.Type = (int)GSTask.GSTType.ChatBlockList_Fetch;
     t.Client = client;
     TaskProcessor.AddTask(t);
 }
Пример #9
0
		public void OnCommand(GameClient client, string[] args)
		{
			if (IsSpammingCommand(client.Player, "boot"))
				return;

            House house = client.Player.CurrentHouse;
			if (house == null)
			{
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Boot.InHouseError"));
				return;
			}

			// no permission to banish, return
			if (!house.CanBanish(client.Player))
			{
				DisplayMessage(client, "You do not have permissions to do that.");
				return;
			}

			// check each player, try and find player with the given name (lowercase cmp)
			foreach (GamePlayer player in house.GetAllPlayersInHouse())
			{
				if (player != client.Player && player.Name.ToLower() != args[1].ToLower())
				{
					ChatUtil.SendSystemMessage(client, "Scripts.Players.Boot.YouRemoved", client.Player.Name);
					player.LeaveHouse();

					return;
				}
			}

			ChatUtil.SendHelpMessage(client, "Scripts.Players.Boot.NoOneOnline", null);
		}
Пример #10
0
        public override void Execute(GameClient session, string[] pms)
        {
            var room = AzureEmulator.GetGame().GetRoomManager().GetRoom(session.GetHabbo().CurrentRoomId);
            if (room == null) return;

            var user2 = room.GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().LastSelectedUser);
            if (user2 == null)
            {
                session.SendWhisper(TextManager.GetText("user_not_found"));
                return;
            }

            var user = room.GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().UserName);
            if (PathFinder.GetDistance(user.X, user.Y, user2.X, user2.Y) > 1)
            {
                session.SendWhisper(TextManager.GetText("kil_command_error_1"));
                return;
            }
            if (user2.IsLyingDown || user2.IsSitting)
            {
                session.SendWhisper(TextManager.GetText("kil_command_error_2"));
                return;
            }
            if (!String.Equals(user2.GetUserName(), session.GetHabbo().UserName, StringComparison.CurrentCultureIgnoreCase))
            {
                user2.Statusses.Add("lay", "0.55");
                user2.IsLyingDown = true;
                user2.UpdateNeeded = true;
                user.Chat(user.GetClient(), TextManager.GetText("command.kill.user"), true, 0, 3);
                user2.Chat(user2.GetClient(), TextManager.GetText("command.kill.userdeath"), true, 0,
                    3);
                return;
            }
            user.Chat(session, "I am sad", false, 0, 0);
        }
Пример #11
0
        public override void Execute(GameClient session, string[] pms)
        {
            var user = AzureEmulator.GetGame().GetClientManager().GetClientByUserName(pms[0]);

            if (user == null)
            {
                session.SendWhisper(TextManager.GetText("user_not_found"));
                return;
            }
            if (user.GetHabbo().Rank >= session.GetHabbo().Rank)
            {
                session.SendWhisper(TextManager.GetText("user_is_higher_rank"));
                return;
            }
            try
            {
                var length = int.Parse(pms[1]);

                var message = pms.Length < 3 ? string.Empty : string.Join(" ", pms.Skip(2));
                if (string.IsNullOrWhiteSpace(message)) message = TextManager.GetText("command_ban_user_no_reason");

                ModerationTool.BanUser(session, user.GetHabbo().Id, length, message);
                AzureEmulator.GetGame()
                    .GetModerationTool()
                    .LogStaffEntry(session.GetHabbo().UserName, user.GetHabbo().UserName, "Ban",
                        string.Format("USER:{0} TIME:{1} REASON:{2}", pms[0], pms[1], message));
            }
            catch
            {

                // error handle
            }
        }
Пример #12
0
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			string name=packet.ReadString(30);
			//TODO do bad name checks here from some database with
			//bad names, this is just a temp testthing here
			bool bad = false;

			ArrayList names = GameServer.Instance.InvalidNames;

			foreach(string s in names)
			{
				if(name.ToLower().IndexOf(s) != -1)
				{
					bad = true;
					break;
				}
			}

			//if(bad)
			//DOLConsole.WriteLine(String.Format("Name {0} is bad!",name));
			//else
			//DOLConsole.WriteLine(String.Format("Name {0} seems to be a good name!",name));

			client.Out.SendBadNameCheckReply(name,bad);
		}
Пример #13
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (client.Player.Guild == null)
            {
                DisplayMessage(client, "You don't belong to a player guild.");
                return;
            }

            if (!client.Player.Guild.HasRank(client.Player, Guild.eRank.OcSpeak))
            {
                DisplayMessage(client, "You don't have permission to speak on the officer line.");
                return;
            }

            if (IsSpammingCommand(client.Player, "osend", 500))
            {
                DisplayMessage(client, "Slow down! Think before you say each word!");
                return;
            }

            string message = "[Officers] " + client.Player.Name + ": \"" + string.Join(" ", args, 1, args.Length - 1) + "\"";
            foreach (GamePlayer ply in client.Player.Guild.GetListOfOnlineMembers())
            {
                if (!client.Player.Guild.HasRank(ply, Guild.eRank.OcHear))
                {
                    continue;
                }
                ply.Out.SendMessage(message, eChatType.CT_Officer, eChatLoc.CL_ChatWindow);
            }
        }
Пример #14
0
        public static void Logout(GameClient client)
        {
            if (client.Account == null)
                return;

            UserAccount account = client.Account;

            using (var context = new GameDatabaseContext())
            {
                context.Accounts.Attach(account);

                account.IsOnline = false;

                context.SaveChanges();
            }

            client.Account = null;

            if (client.HeroEntity == null)
                return;

            PersistPlayer(client.HeroEntity);

            client.HeroEntity.Zone.RemoveEntity(client.HeroEntity);
        }
Пример #15
0
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			ushort keepId = packet.ReadShort();
			ushort wallId = packet.ReadShort();
			int hookpointID = packet.ReadShort();
            ushort itemslot = packet.ReadShort();
			int payType = packet.ReadByte();//gold RP BP contrat???
			int unk2 = packet.ReadByte();
			int unk3 = packet.ReadByte();
			int unk4 = packet.ReadByte();
//			client.Player.Out.SendMessage("x="+unk2+"y="+unk3+"z="+unk4,eChatType.CT_Say,eChatLoc.CL_SystemWindow);
			AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId);
			if (keep == null) return;
			GameKeepComponent component = keep.KeepComponents[wallId] as GameKeepComponent;
			if (component == null) return;
			/*GameKeepHookPoint hookpoint = component.HookPoints[hookpointID] as GameKeepHookPoint;
			if (hookpoint == null) return 1;
			*/
			HookPointInventory inventory = null;
			if(hookpointID > 0x80) inventory = HookPointInventory.YellowHPInventory; //oil
			else if(hookpointID > 0x60) inventory = HookPointInventory.GreenHPInventory;//big siege
			else if(hookpointID > 0x40) inventory = HookPointInventory.LightGreenHPInventory; //small siege
			else if (hookpointID > 0x20) inventory = HookPointInventory.BlueHPInventory;//npc
			else inventory = HookPointInventory.RedHPInventory;//guard

			if (inventory != null)
			{
				HookPointItem item = inventory.GetItem(itemslot);
				if (item != null)
					item.Invoke(client.Player, payType, component.HookPoints[hookpointID] as GameKeepHookPoint, component);
			}
		}
Пример #16
0
        public static void OnZoneChangeRequest(GameClient client, ClientZoneChangeRequestPacket packet)
        {
            // Check if leaving is legal
            var canLeave = client.HeroEntity.Zone.CanLeave(packet.Direction, client.HeroEntity);

            if (canLeave)
            {
                // Alert the console
                Logger.Instance.Info("{0} is changing zones...", client.HeroEntity.ToString());

                // Fetch the zone we'll be transferring to
                var zoneId = client.HeroEntity.Zone.ZoneExitPoints[(int)packet.Direction];
                var zone = ZoneManager.Instance.FindZone(zoneId);

                // Check for existence first before trying to transfer
                if (zone == null)
                {
                    Logger.Instance.Error("{0} tried to transfer to {1} from {2} but the zone could not be found.", client.HeroEntity.Name, client.HeroEntity.Zone.Id, zoneId);
                    return;
                }
                var newPos = GetFreePositionInZoneFromDirection(packet.Direction, zone, client.HeroEntity.Position);

                ZoneManager.Instance.SwitchToZoneAndPosition(client.HeroEntity, zone, newPos);
                client.HeroEntity.Direction = packet.Direction;
            }
        }
Пример #17
0
        public override void OnResponse( GameClient sender, RelayInfo info )
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if ( pm == null )
                return;

            if ( !pm.InRange( m_Owner.Location, 5 ) )
                return;

            switch ( info.ButtonID )
            {
                case 2: // Yes, and do not ask me again
                    {
                        pm.DisabledPvpWarning = true;
                        pm.SendLocalizedMessage( 1113796 ); // You may use your avatar's context menu to re-enable the warning later.

                        goto case 1;
                    }
                case 1: // Yes, I wish to proceed
                    {
                        BaseCreature.TeleportPets( pm, m_Owner.PointDest, m_Owner.MapDest );
                        pm.MoveToWorld( m_Owner.PointDest, m_Owner.MapDest );

                        break;
                    }
                case 0: // No, I do not wish to proceed
                    {
                        break;
                    }
            }
        }
Пример #18
0
        /// <summary>
        /// Method to handle the command and any arguments
        /// </summary>
        /// <param name="client"></param>
        /// <param name="args"></param>
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                string[] ignores = client.Player.DBCharacter.SerializedIgnoreList.Split(',');
                client.Out.SendCustomTextWindow("Ignore List (snapshot)", ignores);
                return;
            }

            string name = string.Join(" ", args, 1, args.Length - 1);

            int result = 0;
            GameClient fclient = WorldMgr.GuessClientByPlayerNameAndRealm(name, 0, false, out result);

            if (fclient == null)
            {
                name = args[1];
                if (client.Player.IgnoreList.Contains(name))
                {
                    client.Player.ModifyIgnoreList(name, true);
                    return;
                }
                else
                {
                    // nothing found
                    DisplayMessage(client, "No players online with that name.");
                    return;
                }
            }

            switch (result)
            {
                case 2:
                    {
                        // name not unique
                        DisplayMessage(client, "Character name is not unique.");
                        break;
                    }
                case 3: // exact match
                case 4: // guessed name
                    {
                        if (fclient == client)
                        {
                            DisplayMessage(client, "You can't add yourself!");
                            return;
                        }

                        name = fclient.Player.Name;
                        if (client.Player.IgnoreList.Contains(name))
                        {
                           client.Player.ModifyIgnoreList(name, true);
                        }
                        else
                        {
                            client.Player.ModifyIgnoreList(name, false);
                        }
                        break;
                    }
            }
        }
Пример #19
0
        public static void OnChatMessage(GameClient client, ClientMovementRequestPacket packet)
        {
            var player = client.HeroEntity;
            var zone = client.HeroEntity.Zone;

            if (zone == null)
                return;

            var requestedPosition = packet.CurrentPosition;
            var direction = packet.Direction;

            var distance = Vector2.Distance(requestedPosition, player.Position);
            // Ignore packets claiming to make large leaps and bounds
            if (distance > LenianceFactor)
            {
                Logger.Instance.Debug("Ignoring movement request");
                // Probably changing maps, so just ignore it
                return;
                //client.Connection.Disconnect("Hacking Attempt: Movement pulse exceeded");
            }

            // Set the state
            if (packet.Terminates)
                player.CharacterState = CharacterState.Idle;
            else
                player.CharacterState = CharacterState.Moving;

            // Move the player and set direction
            player.Direction = packet.Direction;
            player.Position = requestedPosition;
        }
Пример #20
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (IsSpammingCommand(client.Player, "hood"))
                return;

            client.Player.IsCloakHoodUp = !client.Player.IsCloakHoodUp;
        }
Пример #21
0
		//rewritten by Corillian so if it doesn't work you know who to yell at ;)
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			byte grouped = (byte)packet.ReadByte();
			ArrayList list = new ArrayList();
			if (grouped != 0x00)
			{
				ArrayList groups = GroupMgr.ListGroupByStatus(0x00);
				if (groups != null)
				{
					foreach (Group group in groups)
						if (GameServer.ServerRules.IsAllowedToGroup(group.Leader, client.Player, true))
						{
							list.Add(group.Leader);
						}
				}
			}

			ArrayList Lfg = GroupMgr.LookingForGroupPlayers();

			if (Lfg != null)
			{
				foreach (GamePlayer player in Lfg)
				{
					if (player != client.Player && GameServer.ServerRules.IsAllowedToGroup(client.Player, player, true))
					{
						list.Add(player);
					}
				}
			}

			client.Out.SendFindGroupWindowUpdate((GamePlayer[])list.ToArray(typeof(GamePlayer)));
		}
Пример #22
0
		private static void SendSystemMessageName(GameClient client)
		{
			if (client.Player != null)
			{
				client.Out.SendMessage("\n /reload <object/mob>  name <name_you_want>' reload all element with specified name in region.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
			}
		}
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            uint x = packet.ReadInt();
            uint y = packet.ReadInt();
            ushort id = packet.ReadShort();
            ushort item_slot = packet.ReadShort();

            if (client.Player.TargetObject == null)
            {
                client.Out.SendMessage("You must select an NPC to sell to.", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
                return;
            }

            lock (client.Player.Inventory)
            {
                InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)item_slot);
                if (item == null)
                    return;

                int itemCount = Math.Max(1, item.Count);
                int packSize = Math.Max(1, item.PackSize);

                if (client.Player.TargetObject is GameMerchant)
                {
                    //Let the merchant choos how to handle the trade.
                    ((GameMerchant)client.Player.TargetObject).OnPlayerSell(client.Player, item);
                }
                else if (client.Player.TargetObject is GameLotMarker)
                {
                    ((GameLotMarker)client.Player.TargetObject).OnPlayerSell(client.Player, item);
                }
            }
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            ushort unk1 = packet.ReadShort();
            ushort questIndex = packet.ReadShort();
            ushort unk2 = packet.ReadShort();
            ushort unk3 = packet.ReadShort();

            AbstractQuest quest = null;

            int index = 0;
            lock (client.Player.QuestList)
            {
                foreach (AbstractQuest q in client.Player.QuestList)
                {
                    // ignore completed quests
                    if (q.Step == -1)
                        continue;

                    if (index == questIndex)
                    {
                        quest = q;
                        break;
                    }

                    index++;
                }
            }

            if (quest != null)
                quest.AbortQuest();
        }
Пример #25
0
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			var aggroState = (byte) packet.ReadByte(); // 1-Aggressive, 2-Deffensive, 3-Passive
			var walkState = (byte) packet.ReadByte(); // 1-Follow, 2-Stay, 3-GoTarg, 4-Here
			var command = (byte) packet.ReadByte(); // 1-Attack, 2-Release

			//[Ganrod] Nidel: Animist can removed his TurretFnF without MainPet.
			if (client.Player.TargetObject != null && command == 2 && client.Player.ControlledBrain == null &&
			    client.Player.CharacterClass.ID == (int) eCharacterClass.Animist)
			{
				var turret = client.Player.TargetObject as TurretPet;
				if (turret != null && turret.Brain is TurretFNFBrain && client.Player.IsControlledNPC(turret))
				{
					//release
					new HandlePetCommandAction(client.Player, 0, 0, 2).Start(1);
					return;
				}
			}

			//[Ganrod] Nidel: Call only if player has controllednpc
			if (client.Player.ControlledBrain != null)
			{
				new HandlePetCommandAction(client.Player, aggroState, walkState, command).Start(1);
				return;
			}
		}
Пример #26
0
		public void HandlePacket(GameClient client, GSPacketIn packet)
		{
			int permissionSlot = packet.ReadByte();
			int newPermissionLevel = packet.ReadByte();
			ushort houseNumber = packet.ReadShort();

			// house is null, return
			var house = HouseMgr.GetHouse(houseNumber);
			if (house == null)
				return;

			// player is null, return
			if (client.Player == null)
				return;

			// can't set permissions unless you're the owner.
			if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
				return;

			// check if we're setting or removing permissions
			if (newPermissionLevel == 100)
			{
				house.RemovePermission(permissionSlot);
			}
			else
			{
				house.AdjustPermissionSlot(permissionSlot, newPermissionLevel);
			}
		}
Пример #27
0
        public override void Execute(GameClient session, string[] pms)
        {
            var client = AzureEmulator.GetGame().GetClientManager().GetClientByUserName(pms[0]);
            if (client == null)
            {
                session.SendWhisper(TextManager.GetText("user_not_found"));
                return;
            }
            if (client.GetHabbo().Rank >= session.GetHabbo().Rank)
            {
                session.SendWhisper(TextManager.GetText("user_is_higher_rank"));
                return;
            }
            int time;
            if (!int.TryParse(pms[1], out time))
            {
                session.SendWhisper(TextManager.GetText("enter_numbers"));
                return;
            }

            client.GetHabbo().FloodTime = AzureEmulator.GetUnixTimeStamp() + Convert.ToInt32(pms[1]);
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));
            serverMessage.AppendInteger(Convert.ToInt32(pms[1]));
            client.SendMessage(serverMessage);
        }
Пример #28
0
        public void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (!hasRights)
                return;
            if (item == null || item.GetBaseItem() == null || item.GetBaseItem().InteractionType != Interaction.Gate)
                return;

            var modes = item.GetBaseItem().Modes - 1;
            if (modes <= 0)
                item.UpdateState(false, true);

            if (item.GetRoom() == null || item.GetRoom().GetGameMap() == null || item.GetRoom().GetGameMap().SquareHasUsers(item.X, item.Y))
                return;

            int currentMode;
            int.TryParse(item.ExtraData, out currentMode);
            int newMode;
            if (currentMode <= 0)
                newMode = 1;
            else if (currentMode >= modes)
                newMode = 0;
            else
                newMode = currentMode + 1;

            if (newMode == 0 && !item.GetRoom().GetGameMap().ItemCanBePlacedHere(item.X, item.Y))
                return;

            item.ExtraData = newMode.ToString();
            item.UpdateState();
            item.GetRoom().GetGameMap().UpdateMapForItem(item);
            item.GetRoom().GetWiredHandler().ExecuteWired(Interaction.TriggerStateChanged, item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id), item);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.ConsortiaID == 0)
                return 0;

            int id = packet.ReadInt();
            bool result = false;
            string msg = "ConsortiaApplyLoginPassHandler.Failed";
            using (ConsortiaBussiness db = new ConsortiaBussiness())
            {
                int consortiaRepute = 0;
                ConsortiaUserInfo info = new ConsortiaUserInfo();
                if (db.PassConsortiaApplyUsers(id, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, client.Player.PlayerCharacter.ConsortiaID, ref msg, info, ref consortiaRepute))
                {
                    msg = "ConsortiaApplyLoginPassHandler.Success";
                    result = true;
                    if (info.UserID != 0)
                    {
                        info.ConsortiaID = client.Player.PlayerCharacter.ConsortiaID;
                        info.ConsortiaName = client.Player.PlayerCharacter.ConsortiaName;
                        GameServer.Instance.LoginServer.SendConsortiaUserPass(client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, info, false, consortiaRepute, info.LoginName, client.Player.PlayerCharacter.FightPower);
                    }
                }
            }

            packet.WriteBoolean(result);
            packet.WriteString(LanguageMgr.GetTranslation(msg));
            client.Out.SendTCP(packet);

            return 0;
        }
Пример #30
0
		private static void SendSystemMessageModel(GameClient client)
		{
			if (client.Player != null)
			{
				client.Out.SendMessage("\n /reload <object/mob>  model <model_ID>' reload all element with specified model_ID in region.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
			}
		}
Пример #31
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendMessage(new RecyclerRewardsComposer());
 }
Пример #32
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Account.PrivLevel == (int)ePrivLevel.Player)
            {
                GameTrainer trainer = client.Player.TargetObject as DOL.GS.GameTrainer;
                if (trainer == null || (trainer.CanTrain(client.Player) == false && trainer.CanTrainChampionLevels(client.Player) == false))
                {
                    client.Out.SendMessage("You must select a valid trainer for your class.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                    return;
                }
            }

            uint x          = packet.ReadInt();
            uint y          = packet.ReadInt();
            int  idLine     = packet.ReadByte();
            int  unk        = packet.ReadByte();
            int  row        = packet.ReadByte();
            int  skillIndex = packet.ReadByte();

            // idline not null so this is a Champion level training window
            if (idLine > 0)
            {
                if (row > 0 && skillIndex > 0)
                {
                    // Get Player CL Spec
                    var clspec = client.Player.GetSpecList().Where(sp => sp is LiveChampionsSpecialization).Cast <LiveChampionsSpecialization>().FirstOrDefault();

                    // check if the tree can be used
                    List <Tuple <MiniLineSpecialization, List <Tuple <Skill, byte> > > > tree = null;
                    if (clspec != null)
                    {
                        tree = clspec.GetTrainerTreeDisplay(client.Player, clspec.RetrieveTypeForIndex(idLine));
                    }

                    if (tree != null)
                    {
                        Tuple <byte, MiniLineSpecialization> skillstatus = clspec.GetSkillStatus(tree, row - 1, skillIndex - 1);

                        if (skillstatus.Item1 == 1)
                        {
                            client.Out.SendMessage("You already have that ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (skillstatus.Item1 != 2)
                        {
                            client.Out.SendMessage("You do not meet the requirements for that ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (client.Player.ChampionSpecialtyPoints < 1)
                        {
                            client.Out.SendMessage("You do not have enough champion specialty points for that ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }

                        skillstatus.Item2.Level++;
                        client.Player.AddSpecialization(skillstatus.Item2);
                        client.Player.RefreshSpecDependantSkills(false);
                        client.Player.Out.SendUpdatePlayer();
                        client.Player.Out.SendUpdatePoints();
                        client.Player.Out.SendUpdatePlayerSkills();
                        client.Player.UpdatePlayerStatus();
                        client.Player.Out.SendChampionTrainerWindow(idLine);

                        return;
                    }
                    else
                    {
                        client.Out.SendMessage("Could not find Champion Spec!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        log.ErrorFormat("Could not find Champion Spec idline {0}, row {1}, skillindex {2}", idLine, row, skillIndex);
                    }
                }
            }
            else
            {
                // Trainable Specs or RA's
                IList <Specialization> speclist = client.Player.GetSpecList().Where(e => e.Trainable).ToList();

                if (skillIndex < speclist.Count)
                {
                    Specialization spec = (Specialization)speclist[skillIndex];
                    if (spec.Level >= client.Player.BaseLevel)
                    {
                        client.Out.SendMessage("You can't train in this specialization again this level!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    // Graveen - autotrain 1.87 - allow players to train their AT specs even if no pts left
                    int temp = client.Player.SkillSpecialtyPoints + client.Player.GetAutoTrainPoints(spec, 2);

                    if (temp >= spec.Level + 1)
                    {
                        spec.Level++;
                        client.Player.OnSkillTrained(spec);

                        client.Out.SendUpdatePoints();
                        client.Out.SendTrainerWindow();
                        return;
                    }
                    else
                    {
                        client.Out.SendMessage("That specialization costs " + (spec.Level + 1) + " specialization points!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        client.Out.SendMessage("You don't have that many specialization points left for this level.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                }
                else if (skillIndex >= 100)
                {
                    // Realm Abilities
                    var raList = SkillBase.GetClassRealmAbilities(client.Player.CharacterClass.ID).Where(ra => !(ra is RR5RealmAbility));
                    if (skillIndex < raList.Count() + 100)
                    {
                        RealmAbility ra = raList.ElementAtOrDefault(skillIndex - 100);
                        if (ra != null)
                        {
                            ra.Level = client.Player.GetAbilityLevel(ra.KeyName);
                            int cost = ra.CostForUpgrade(ra.Level);
                            ra.Level++;

                            if (client.Player.RealmSpecialtyPoints < cost)
                            {
                                client.Out.SendMessage(ra.Name + " costs " + (cost) + " realm ability points!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                                client.Out.SendMessage("You don't have that many realm ability points left to get this.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                                return;
                            }
                            if (!ra.CheckRequirement(client.Player))
                            {
                                client.Out.SendMessage("You are not experienced enough to get " + ra.Name + " now. Come back later.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                                return;
                            }

                            client.Player.AddRealmAbility(ra, true);
                            client.Out.SendUpdatePoints();
                            client.Out.SendUpdatePlayer();
                            client.Out.SendUpdatePlayerSkills();
                            client.Out.SendTrainerWindow();
                        }
                        else
                        {
                            client.Out.SendMessage("Unfortunately your training failed. Please report that to admins or game master. Thank you.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            log.Error("Realm Ability " + ra.Name + "(" + ra.KeyName + ") unexpected not found");
                        }
                    }
                }

                if (log.IsErrorEnabled)
                {
                    log.Error("Player <" + client.Player.Name + "> requested to train incorrect skill index");
                }
            }
        }
Пример #33
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Account.PrivLevel == (int)ePrivLevel.Player)
            {
                // A trainer of the appropriate class must be around (or global trainer, with TrainedClass = eCharacterClass.Unknow
                GameTrainer trainer = client.Player.TargetObject as DOL.GS.GameTrainer;
                if (trainer == null || (trainer.CanTrain(client.Player) == false && trainer.CanTrainChampionLevels(client.Player) == false))
                {
                    client.Out.SendMessage("You must select a valid trainer for your class.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                    return;
                }
            }

            //Specializations - 8 trainable specs max
            uint                    size     = 8;
            long                    position = packet.Position;
            IList <uint>            skills   = new List <uint>();
            Dictionary <uint, uint> amounts  = new Dictionary <uint, uint>();
            bool                    stop     = false;

            for (uint i = 0; i < size; i++)
            {
                uint code = packet.ReadInt();
                if (!stop)
                {
                    if (code == 0xFFFFFFFF)
                    {
                        stop = true;
                    }
                    else
                    {
                        if (!skills.Contains(code))
                        {
                            skills.Add(code);
                        }
                    }
                }
            }

            foreach (uint code in skills)
            {
                uint val = packet.ReadInt();

                if (!amounts.ContainsKey(code) && val > 1)
                {
                    amounts.Add(code, val);
                }
            }

            IList <Specialization> specs = client.Player.GetSpecList().Where(e => e.Trainable).ToList();
            uint           skillcount    = 0;
            IList <string> done          = new List <string>();
            bool           trained       = false;

            // Graveen: the trainline command is called
            foreach (Specialization spec in specs)
            {
                if (amounts.ContainsKey(skillcount))
                {
                    if (spec.Level < amounts[skillcount])
                    {
                        TrainCommandHandler train = new TrainCommandHandler(true);
                        train.OnCommand(client, new string[] { "&trainline", spec.KeyName, amounts[skillcount].ToString() });
                        trained = true;
                    }
                }
                skillcount++;
            }

            //RealmAbilities
            packet.Seek(position + 64, System.IO.SeekOrigin.Begin);
            size = 50;            //50 RA's max?
            amounts.Clear();
            for (uint i = 0; i < size; i++)
            {
                uint val = packet.ReadInt();

                if (val > 0 && !amounts.ContainsKey(i))
                {
                    amounts.Add(i, val);
                }
            }

            if (amounts != null && amounts.Count > 0)
            {
                // Realm Abilities
                var raList = SkillBase.GetClassRealmAbilities(client.Player.CharacterClass.ID).Where(ra => !(ra is RR5RealmAbility));
                foreach (var kv in amounts)
                {
                    RealmAbility ra = raList.ElementAtOrDefault((int)kv.Key);
                    if (ra != null)
                    {
                        RealmAbility playerRA = (RealmAbility)client.Player.GetAbility(ra.KeyName);

                        if (playerRA != null && (playerRA.Level >= ra.MaxLevel || playerRA.Level >= kv.Value))
                        {
                            continue;
                        }

                        int cost = 0;
                        for (int i = playerRA != null ? playerRA.Level : 0; i < kv.Value; i++)
                        {
                            cost += ra.CostForUpgrade(i);
                        }

                        if (client.Player.RealmSpecialtyPoints < cost)
                        {
                            client.Out.SendMessage(ra.Name + " costs " + (cost) + " realm ability points!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            client.Out.SendMessage("You don't have that many realm ability points left to get this.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            continue;
                        }

                        if (!ra.CheckRequirement(client.Player))
                        {
                            client.Out.SendMessage("You are not experienced enough to get " + ra.Name + " now. Come back later.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            continue;
                        }

                        bool valid = false;
                        if (playerRA != null)
                        {
                            playerRA.Level = (int)kv.Value;
                            valid          = true;
                        }
                        else
                        {
                            ra.Level = (int)kv.Value;
                            valid    = true;
                            client.Player.AddRealmAbility(ra, false);
                        }

                        if (valid)
                        {
                            client.Out.SendUpdatePoints();
                            client.Out.SendUpdatePlayer();
                            client.Out.SendCharResistsUpdate();
                            client.Out.SendCharStatsUpdate();
                            client.Out.SendUpdatePlayerSkills();
                            client.Out.SendTrainerWindow();
                            trained = true;
                        }
                        else
                        {
                            client.Out.SendMessage("Unfortunately your training failed. Please report that to admins or game master. Thank you.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        }
                    }
                    else
                    {
                        client.Out.SendMessage("Unfortunately your training failed. Please report that to admins or game master. Thank you.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
            }
            if (trained)
            {
                client.Player.SaveIntoDatabase();
            }
        }
Пример #34
0
 public RequestItemList(Packet packet, GameClient client)
 {
     _client = client;
 }
 public ReactorSequence(GameClient gameClient, DialogSequence sequenceMenu)
     : base(gameClient)
 {
     client   = gameClient;
     sequence = sequenceMenu;
 }
 public ServerFormat30(GameClient gameClient, Dialog sequenceMenu)
     : this(gameClient)
 {
     Sequence = sequenceMenu;
 }
 public ServerFormat30(GameClient gameClient) : this()
 {
     _client = gameClient;
 }
Пример #38
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType ItemBagType = (eBageType)packet.ReadInt();

            int ItemPlace = packet.ReadInt();

            eBageType           PropBagType = (eBageType)packet.ReadInt();
            ItemInfo            Item        = null;
            List <ShopItemInfo> ShopItem    = new List <ShopItemInfo>();
            ItemInfo            Prop        = null;
            int PropPlace = packet.ReadInt();

            int Operation = packet.ReadInt();



            if (PropPlace == -1)
            {
                int templateID = packet.ReadInt();
                int type       = packet.ReadInt();
                int gold       = 0;
                int money      = 0;



                ItemTemplateInfo template = Bussiness.Managers.ItemMgr.FindItemTemplate(34101);
                Prop     = ItemInfo.CreateFromTemplate(template, 1, (int)ItemAddType.Buy);
                ShopItem = Bussiness.Managers.ShopMgr.FindShopbyTemplatID(34101);
                for (int i = 0; i < ShopItem.Count; i++)
                {
                    if (ShopItem[i].APrice1 == -1 && ShopItem[i].AValue1 != 0)
                    {
                        money          = ShopItem[i].AValue1;
                        Prop.ValidDate = ShopItem[i].AUnit;
                    }
                }

                if (Prop != null)
                {
                    // item = ItemInfo.SetItemType(item, type, ref gold, ref money, ref offer);
                    if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money)
                    {
                        client.Player.RemoveMoney(money);
                        client.Player.RemoveGold(gold);
                        LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Move, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, 0, 0, 0, "牌子编号", Prop.TemplateID.ToString(), type.ToString());
                    }
                    else
                    {
                        Prop = null;
                    }
                }
            }
            else
            {
                Prop = client.Player.GetItemAt(PropBagType, PropPlace);
            }
            Item = client.Player.GetItemAt(ItemBagType, ItemPlace);
            StringBuilder str = new StringBuilder();

            if (Prop == null || Item == null)
            {
                return(1);
            }

            bool result = false;

            ItemTemplateInfo TemplateItem = Managers.RefineryMgr.RefineryTrend(Operation, Item, ref result);

            if (result && TemplateItem != null)
            {
                ItemInfo          item = ItemInfo.CreateFromTemplate(TemplateItem, 1, (int)ItemAddType.RefineryTrend);
                AbstractInventory bg   = client.Player.GetItemInventory(TemplateItem);
                // Managers.RefineryMgr.InheritProperty(Item, ref item);
                if (bg.AddItem(item, bg.BeginSlot))
                {
                    client.Player.UpdateItem(item);
                    client.Player.RemoveItem(Item);
                    Prop.Count--;
                    client.Player.UpdateItem(Prop);
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Success"));
                }
                else
                {
                    str.Append("NoPlace");
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(item.GetBagName()) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace"));
                }
                return(1);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Fail"));
                return(1);
            }
        }
Пример #39
0
 public void ConnectGame(string address, int port, GameConf conf)
 {
     GameClient = new GameClient(address, port);
 }
Пример #40
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            client.ClientState = GameClient.eClientState.CharScreen;
            if (client.Player != null)
            {
                try
                {
                    // find the cached character and force it to update with the latest saved character
                    DOLCharacters cachedCharacter = null;
                    foreach (DOLCharacters accountChar in client.Account.Characters)
                    {
                        if (accountChar.ObjectId == client.Player.InternalID)
                        {
                            cachedCharacter = accountChar;
                            break;
                        }
                    }

                    if (cachedCharacter != null)
                    {
                        cachedCharacter = client.Player.DBCharacter;
                    }
                }
                catch (System.Exception ex)
                {
                    log.ErrorFormat("Error attempting to update cached player. {0}", ex.Message);
                }
            }

            client.Player = null;

            //reset realm if no characters
            if ((client.Account.Characters == null || client.Account.Characters.Length <= 0) && client.Account.Realm != (int)eRealm.None)
            {
                client.Account.Realm = (int)eRealm.None;
            }

            string accountName = packet.ReadString(24);

            if (accountName.EndsWith("-X"))
            {
                if (GameServer.ServerRules.IsAllowedCharsInAllRealms(client))
                {
                    client.Out.SendRealm(eRealm.None);
                }
                else
                {
                    //Requests to know what realm an account is
                    //assigned to... if Realm::NONE is sent, the
                    //Realm selection screen is shown
                    switch (client.Account.Realm)
                    {
                    case 1: client.Out.SendRealm(eRealm.Albion); break;

                    case 2: client.Out.SendRealm(eRealm.Midgard); break;

                    case 3: client.Out.SendRealm(eRealm.Hibernia); break;

                    default: client.Out.SendRealm(eRealm.None); break;
                    }
                }
            }
            else
            {
                eRealm chosenRealm;

                if (client.Account.Realm == (int)eRealm.None || GameServer.ServerRules.IsAllowedCharsInAllRealms(client))
                {
                    // allow player to choose the realm if not set already or if allowed by server rules
                    if (accountName.EndsWith("-S"))
                    {
                        chosenRealm = eRealm.Albion;
                    }
                    else if (accountName.EndsWith("-N"))
                    {
                        chosenRealm = eRealm.Midgard;
                    }
                    else if (accountName.EndsWith("-H"))
                    {
                        chosenRealm = eRealm.Hibernia;
                    }
                    else
                    {
                        if (log.IsErrorEnabled)
                        {
                            log.Error("User has chosen unknown realm: " + accountName + "; account=" + client.Account.Name);
                        }
                        client.Out.SendRealm(eRealm.None);
                        return;
                    }

                    if (client.Account.Realm == (int)eRealm.None && !GameServer.ServerRules.IsAllowedCharsInAllRealms(client))
                    {
                        // save the choice
                        client.Account.Realm = (int)chosenRealm;
                        GameServer.Database.SaveObject(client.Account);
                        // 2008-01-29 Kakuri - Obsolete
                        //GameServer.Database.WriteDatabaseTable( typeof( Account ) );
                    }
                }
                else
                {
                    // use saved realm ignoring what user has chosen if server rules do not allow to choose the realm
                    chosenRealm = (eRealm)client.Account.Realm;
                }

                client.Out.SendCharacterOverview(chosenRealm);
            }
        }
Пример #41
0
 public BOX_MESSAGE_DELETE_REC(GameClient client, byte[] data)
 {
     makeme(client, data);
 }
Пример #42
0
        /// <summary>
        /// 本地处理
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public TCPProcessCmdResults dispathProcessor(TMSKSocket socket, int nID, byte[] data, int count)
        {
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                //获取指令参数数量
                short cmdParamNum = -1;
                if (!cmdParamNumMapping.TryGetValue(nID, out cmdParamNum))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("未注册指令, CMD={0}, Client={1}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                ;
                //解析用户名称和用户密码
                string[] cmdParams = cmdData.Split(':');
                if (cmdParams.Length != cmdParamNum)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), cmdParams.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                //根据socket获取GameClient
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                //获取相对应的指令处理器
                ICmdProcessor cmdProcessor = null;
                if (!cmdProcesserMapping.TryGetValue(nID, out cmdProcessor))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("未注册指令, CMD={0}, Client={1}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                if (!cmdProcessor.processCmd(client, cmdParams))
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                return(TCPProcessCmdResults.RESULT_OK);
            }
            catch (Exception ex)
            {
                // 格式化异常错误信息
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
Пример #43
0
 public void Parse(GameClient session, ClientPacket packet)
 {
     session.SendPacket(new OpenHelpToolComposer());
 }
Пример #44
0
        private void Client_TeleportationOccuring(string map, int x, int y)
        {
            string message = "Position updated: " + map + " (" + x + ", " + y + ")";

            if (Game.Map == null || Game.IsTeleporting)
            {
                message += " [OK]";
            }
            else if (Game.MapName != map)
            {
                Script.OnWarningMessage(true, Game.MapName);
                message += " [WARNING, different map] /!\\";
                bool flagTele        = map.ToLowerInvariant().Contains("pokecenter") ? false : true;
                bool anotherFlagTele = map.ToLowerInvariant().Contains("player") ? false : true;
                if (flagTele && anotherFlagTele && Game.PreviousMapBeforeTeleport != Game.MapName && countGMTele >= 2)
                {
                    if (BeAwareOfStaff)
                    {
                        NeedResync     = true;
                        messageProcess = sendTime(5);
                    }
                    PlayShoutNotification?.Invoke();
                    countGMTele = 0;
                }
                else if (Game.MapName.ToLowerInvariant().Contains("prof. antibans classroom"))
                {
                    LogMessage("Bot got teleported to an unexpected Map, please check. This can be a GM/Admin/Mod teleport.", Brushes.OrangeRed);
                    PlayShoutNotification?.Invoke();
                    if (BeAwareOfStaff)
                    {
                        NeedResync     = true;
                        messageProcess = sendTime(5);
                    }
                }
            }
            else
            {
                int distance = GameClient.DistanceBetween(x, y, Game.PlayerX, Game.PlayerY);
                if (distance < 8)
                {
                    message += " [OK, lag, distance=" + distance + "]";
                }
                else
                {
                    Script.OnWarningMessage(false, string.Empty, distance);
                    message += " [WARNING, distance=" + distance + "] /!\\";
                    countGMTele++;
                    if (countGMTele > 2)
                    {
                        CheckTeleportion(1f);
                    }
                }
            }
            if (message.Contains("[OK]"))
            {
                LogMessage(message, Brushes.MediumSeaGreen);
            }
            if (message.Contains("WARNING"))
            {
                LogMessage(message, Brushes.OrangeRed);
            }
            MovementResynchronizer.Reset();
        }
Пример #45
0
        //修改:  Xiaov
        //时间:  2009-11-7
        //描述:  续费<已测试>
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //在游戏中不能续费
            //if (client.Player.CurrentRoom != null && client.Player.CurrentRoom.IsPlaying)
            //    return 0;
            //二次密码
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(0);
            }
            StringBuilder payGoods = new StringBuilder();                    //表示支付物品ID
            int           count    = packet.ReadInt();

            for (int i = 0; i < count; i++)
            {
                eBageType bag     = (eBageType)packet.ReadByte();
                int       place   = packet.ReadInt();
                int       Goods   = packet.ReadInt();
                int       type    = packet.ReadByte();
                bool      isDress = packet.ReadBoolean();

                if ((bag == 0 && place >= 31) || bag == eBageType.PropBag || bag == eBageType.Bank)
                {
                    ItemInfo item = client.Player.GetItemAt(bag, place);
                    if (item != null && item.ValidDate != 0 && !item.IsValidItem() && (bag == 0 || (bag == eBageType.PropBag && item.TemplateID == 10200)))
                    //if (item != null && item.ValidDate != 0 && (bag == 0 || bag == 11 || (bag == 1 && item.TemplateID == 10200)))
                    {
                        int        gold          = 0; //表示金币
                        int        money         = 0; //表示点券
                        int        offer         = 0; //表示功勋
                        int        gifttoken     = 0; //表示礼劵
                        int        oldDate       = item.ValidDate;
                        int        oldCount      = item.Count;
                        bool       isValid       = item.IsValidItem();
                        List <int> needitemsinfo = new List <int>();

                        eMessageType eMsg = eMessageType.Normal;
                        string       msg  = "UserBuyItemHandler.Success";

                        ShopItemInfo shopitem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(Goods);                             //获取商品信息
                        needitemsinfo = ItemInfo.SetItemType(shopitem, type, ref gold, ref money, ref offer, ref gifttoken);       //获取物品价格及兑换物TemplatID, Count

                        //////////////////////////////////////////////////////////////////////////////////////
                        //玩家背包中是否有兑换物品所需要的物品
                        int  icount = client.Player.MainBag.GetItems().Count;      //获取个数
                        bool result = true;
                        //for (int j = 0; j < needitemsinfo.Count; j += 2)
                        //{
                        //    ItemInfo temp = client.Player.PropBag.GetItemByTemplateID(icount, needitemsinfo[j]);
                        //    int iVaule = client.Player.PropBag.GetItemCount(needitemsinfo[j]);
                        //    if (temp != null || iVaule != needitemsinfo[j + 1] || !temp.IsBinds)
                        //    {
                        //        result = false;
                        //    }
                        //}
                        for (int j = 0; j < needitemsinfo.Count; j += 2)
                        {
                            if (client.Player.GetItemCount(needitemsinfo[j]) < needitemsinfo[j + 1])
                            {
                                result = false;
                            }
                        }

                        if (!result)
                        {
                            eMsg = eMessageType.ERROR;
                            msg  = "UserBuyItemHandler.NoBuyItem";
                            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
                            return(1);
                        }
                        /////////////////////////////////////////////////////////////


                        if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money && offer <= client.Player.PlayerCharacter.Offer && gifttoken <= client.Player.PlayerCharacter.GiftToken)
                        {
                            client.Player.RemoveMoney(money);
                            client.Player.RemoveGold(gold);
                            client.Player.RemoveOffer(offer);
                            client.Player.RemoveGiftToken(gifttoken);

                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            //从玩家背包中删除兑换所需要的物品
                            //for (int j = 0; j < needitemsinfo.Count; j += 2)
                            //{
                            //    ItemInfo temp = client.Player.PropBag.GetItemByTemplateID(icount, needitemsinfo[j]);
                            //    client.Player.PropBag.RemoveItem(temp);                                              /////////??????   日志
                            //    payGoods.Append(temp.TemplateID.ToString() + ";");
                            //}
                            for (int j = 0; j < needitemsinfo.Count; j += 2)
                            {
                                client.Player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1]);
                                payGoods.Append(needitemsinfo[j].ToString() + ":");
                            }
                            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                            if (!isValid && item.ValidDate != 0)
                            {
                                if (1 == type)
                                {
                                    item.ValidDate = shopitem.AUnit;
                                    item.BeginDate = DateTime.Now;
                                    item.IsUsed    = false;
                                }
                                if (2 == type)
                                {
                                    item.ValidDate = shopitem.BUnit;
                                    item.BeginDate = DateTime.Now;
                                    item.IsUsed    = false;
                                }
                                if (3 == type)
                                {
                                    item.ValidDate = shopitem.CUnit;
                                    item.BeginDate = DateTime.Now;
                                    item.IsUsed    = false;
                                }
                            }


                            if (bag == 0)
                            {
                                if (isDress)
                                {
                                    int solt = client.Player.MainBag.FindItemEpuipSlot(item.Template);
                                    client.Player.MainBag.MoveItem(place, solt, item.Count);
                                }
                                else
                                {
                                    client.Player.MainBag.UpdateItem(item);
                                }
                            }
                            else if (bag == eBageType.PropBag)
                            {
                                client.Player.PropBag.UpdateItem(item);
                            }
                            else
                            {
                                client.Player.StoreBag.UpdateItem(item);
                            }
                            LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Continue, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, 0, 0, "牌子编号", item.TemplateID.ToString(), type.ToString());
                        }
                        else
                        {
                            item.ValidDate = oldDate;
                            item.Count     = oldCount;
                            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserItemContineueHandler.NoMoney"));
                        }
                    }
                }
            }

            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserItemContineueHandler.Success"));

            return(0);
        }
Пример #46
0
 public override void OnUserLeaveRoom(GameClient Session)
 {
 }
        public void Handle(GameClient Session, ClientMessage Event)
        {
            Room     room     = Session.GetHabbo().CurrentRoom;
            RoomData roomData = room.RoomData;

            if ((room != null) && room.CheckRights(Session, true))
            {
                int           num     = Event.PopWiredInt32();
                string        str     = Essential.FilterString(Event.PopFixedString());
                string        str2    = Essential.FilterString(Event.PopFixedString());
                int           num2    = Event.PopWiredInt32();
                string        str3    = Essential.FilterString(Event.PopFixedString());
                int           num3    = Event.PopWiredInt32();
                int           id      = Event.PopWiredInt32();
                int           num5    = Event.PopWiredInt32();
                List <string> tags    = new List <string>();
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < num5; i++)
                {
                    if (i > 0)
                    {
                        builder.Append(",");
                    }
                    string item = Essential.FilterString(Event.PopFixedString().ToLower());
                    tags.Add(item);
                    builder.Append(item);
                }
                int  num7  = Event.PopWiredInt32();
                bool k     = Event.PopWiredBoolean();
                bool flag2 = Event.PopWiredBoolean();
                bool flag3 = Event.PopWiredBoolean();
                bool flag4 = Event.PopWiredBoolean();
                int  num8  = Event.PopWiredInt32();
                int  num9  = Event.PopWiredInt32();
                if ((num8 < -2) || (num8 > 1))
                {
                    num8 = 0;
                }
                if ((num9 < -2) || (num9 > 1))
                {
                    num9 = 0;
                }
                if (((str.Length >= 1) && ((num2 >= 0) && (num2 <= 2))) && ((num3 >= 10) && (num3 <= 500)))
                {
                    FlatCat flatCat = Essential.GetGame().GetNavigator().GetFlatCat(id);
                    if (flatCat != null)
                    {
                        if (flatCat.MinRank > Session.GetHabbo().Rank)
                        {
                            Session.SendNotification("Du hast nicht die dafür vorgegebene Rechte!");
                            id = 0;
                        }
                        room.AllowPet                  = k;
                        room.AllowPetsEating           = flag2;
                        room.AllowWalkthrough          = flag3;
                        room.Hidewall                  = flag4;
                        room.RoomData.AllowPet         = k;
                        room.RoomData.AllowPetsEating  = flag2;
                        room.RoomData.AllowWalkthrough = flag3;
                        room.RoomData.Hidewall         = flag4;
                        room.Name                 = str;
                        room.State                = num2;
                        room.Description          = str2;
                        room.Category             = id;
                        room.Password             = str3;
                        room.RoomData.Name        = str;
                        room.RoomData.State       = num2;
                        room.RoomData.Description = str2;
                        room.RoomData.Category    = id;
                        room.RoomData.Password    = str3;
                        room.Tags.Clear();
                        room.Tags.AddRange(tags);
                        room.UsersMax = num3;
                        room.RoomData.Tags.Clear();
                        room.RoomData.Tags.AddRange(tags);
                        room.RoomData.UsersMax   = num3;
                        room.Wallthick           = num8;
                        room.Floorthick          = num9;
                        room.RoomData.Wallthick  = num8;
                        room.RoomData.Floorthick = num9;
                        string str5 = "open";
                        if (room.State == 1)
                        {
                            str5 = "locked";
                        }
                        else if (room.State > 1)
                        {
                            str5 = "password";
                        }
                        using (DatabaseClient adapter = Essential.GetDatabase().GetClient())
                        {
                            adapter.AddParamWithValue("caption", room.Name);
                            adapter.AddParamWithValue("description", room.Description);
                            adapter.AddParamWithValue("password", room.Password);
                            adapter.AddParamWithValue("tags", builder.ToString());
                            adapter.ExecuteQuery(string.Concat(new object[] {
                                "UPDATE rooms SET caption = @caption, description = @description, password = @password, category = '", id, "', state = '", str5, "', tags = @tags, users_max = '", num3, "', allow_pets = '", (k ? 1 : 0), "', allow_pets_eat = '", (flag2 ? 1 : 0), "', allow_walkthrough = '", (flag3 ? 1 : 0), "', allow_hidewall = '", (room.Hidewall ? 1 : 0), "', floorthick = '", room.Floorthick,
                                "', wallthick = '", room.Wallthick, "' WHERE id = ", room.Id
                            }));
                        }

                        ServerMessage UpdateRoomOne = new ServerMessage(Outgoing.UpdateRoomOne);
                        UpdateRoomOne.AppendInt32(room.Id);
                        Session.SendMessage(UpdateRoomOne);

                        ServerMessage WallAndFloor = new ServerMessage(Outgoing.ConfigureWallandFloor);
                        WallAndFloor.AppendBoolean(room.Hidewall);
                        WallAndFloor.AppendInt32(room.Wallthick);
                        WallAndFloor.AppendInt32(room.Floorthick);
                        Session.GetHabbo().CurrentRoom.SendMessage(WallAndFloor, null);

                        RoomData data2 = room.RoomData;

                        ServerMessage RoomDataa = new ServerMessage(Outgoing.RoomData);
                        RoomDataa.AppendBoolean(false);
                        RoomDataa.AppendInt32(room.Id);
                        RoomDataa.AppendString(room.Name);
                        RoomDataa.AppendBoolean(true);
                        RoomDataa.AppendInt32(room.OwnerId);
                        RoomDataa.AppendString(room.Owner);
                        RoomDataa.AppendInt32(room.State);
                        RoomDataa.AppendInt32(room.UsersNow);
                        RoomDataa.AppendInt32(room.UsersMax);
                        RoomDataa.AppendString(room.Description);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32((room.Category == 0x34) ? 2 : 0);
                        RoomDataa.AppendInt32(room.Score);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(room.Category);

                        if (room.RoomData.GuildId == 0)
                        {
                            RoomDataa.AppendInt32(0);
                            RoomDataa.AppendInt32(0);
                        }
                        else
                        {
                            GroupsManager guild = Groups.GetGroupById(room.RoomData.GuildId);
                            RoomDataa.AppendInt32(guild.Id);
                            RoomDataa.AppendString(guild.Name);
                            RoomDataa.AppendString(guild.Badge);
                        }

                        RoomDataa.AppendString("");
                        RoomDataa.AppendInt32(room.Tags.Count);

                        foreach (string str6 in room.Tags)
                        {
                            RoomDataa.AppendString(str6);
                        }

                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendBoolean(true);
                        RoomDataa.AppendBoolean(true);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendBoolean(false);
                        RoomDataa.AppendBoolean(false);
                        RoomDataa.AppendBoolean(false);

                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendInt32(0);
                        RoomDataa.AppendBoolean(false);
                        RoomDataa.AppendBoolean(true);
                        Session.GetHabbo().CurrentRoom.SendMessage(RoomDataa, null);
                    }
                }
            }
        }
Пример #48
0
 public void Handle(GameClient Session, ClientMessage Event)
 {
 }
 public virtual void Handle(GameClient session, ClientMessage message)
 {
     session?.GetHabbo()?.GetMessenger()?.SendUpdates();
 }
 public override void OnPlace(GameClient Session, RoomItem RoomItem_0)
 {
 }
 public BASE_USER_ENTER_REC(GameClient client, byte[] data)
 {
     makeme(client, data);
 }
Пример #52
0
 internal void Response(GameClient ResponseClient, string Response)
 {
 }
Пример #53
0
 public CLAN_CHECK_CREATE_INVITE_REC(GameClient client, byte[] data)
 {
     this.makeme(client, data);
 }
Пример #54
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendMessage(new GiftWrappingConfigurationComposer());
 }
Пример #55
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            string VoucherCode = Packet.PopString().Replace("\r", "");

            Voucher Voucher = null;

            if (!CloudServer.GetGame().GetCatalog().GetVoucherManager().TryGetVoucher(VoucherCode, out Voucher))
            {
                Session.SendMessage(new VoucherRedeemErrorComposer(0));
                return;
            }

            if (Voucher.CurrentUses >= Voucher.MaxUses)
            {
                Session.SendNotification("Você usou esse código o máximo de vezes permitidas!");
                return;
            }

            DataRow GetRow = null;

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `user_vouchers` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `voucher` = @Voucher LIMIT 1");
                dbClient.AddParameter("Voucher", VoucherCode);
                GetRow = dbClient.getRow();
            }

            if (GetRow != null)
            {
                Session.SendNotification("Ops! Você já está usando esse código!");
                return;
            }
            else
            {
                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `user_vouchers` (`user_id`,`voucher`) VALUES ('" + Session.GetHabbo().Id + "', @Voucher)");
                    dbClient.AddParameter("Voucher", VoucherCode);
                    dbClient.RunQuery();
                }
            }

            Voucher.UpdateUses();

            if (Voucher.Type == VoucherType.CREDIT)
            {
                Session.GetHabbo().Credits += Voucher.Value;
                Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " créditos. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.DUCKET)
            {
                Session.GetHabbo().Duckets += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Voucher.Value));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " duckets. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.DIAMOND)
            {
                Session.GetHabbo().Diamonds += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Voucher.Value, 5));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " diamantes. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.GOTW)
            {
                Session.GetHabbo().GOTWPoints += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, Voucher.Value, 103));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " " + ExtraSettings.PTOS_COINS + ". Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.ITEM)
            {
                ItemData Item = null;
                if (!CloudServer.GetGame().GetItemManager().GetItem((Voucher.Value), out Item))
                {
                    // No existe este ItemId.
                    return;
                }

                Item GiveItem = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "", "");
                if (GiveItem != null)
                {
                    Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem);

                    Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1));
                    Session.SendMessage(new FurniListUpdateComposer());
                    Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acabou de receber o objeto raro, corre " + Session.GetHabbo().Username + ", confira seu invetário algo novo está ai!", ""));
                }

                Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
            }

            Session.SendMessage(new VoucherRedeemOkComposer());
        }
Пример #56
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 2:                     // continue
            {
                Guild guild = m_From.Guild as Guild;

                if (guild == null)
                {
                    PlayerState pl = PlayerState.Find(m_From);

                    if (pl != null)
                    {
                        pl.Leaving = DateTime.Now;

                        if (Faction.LeavePeriod == TimeSpan.FromDays(7.0))
                        {
                            m_From.SendLocalizedMessage(1005065);                                               // You will be removed from the faction in 7 days
                        }
                        else
                        {
                            m_From.SendMessage("You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays);
                        }
                    }
                }
                else if (guild.Leader != m_From)
                {
                    m_From.SendLocalizedMessage(1005061);                                       // You cannot quit the faction because you are not the guild master
                }
                else
                {
                    m_From.SendLocalizedMessage(1042285);                                       // Your guild is now quitting the faction.

                    for (int i = 0; i < guild.Members.Count; ++i)
                    {
                        Mobile      mob = (Mobile)guild.Members[i];
                        PlayerState pl  = PlayerState.Find(mob);

                        if (pl != null)
                        {
                            pl.Leaving = DateTime.Now;

                            if (Faction.LeavePeriod == TimeSpan.FromDays(7.0))
                            {
                                mob.SendLocalizedMessage(1005060);                                                   // Your guild will quit the faction in 7 days
                            }
                            else
                            {
                                mob.SendMessage("Your guild will quit the faction in {0} days.", Faction.LeavePeriod.TotalDays);
                            }
                        }
                    }
                }

                break;
            }

            case 1:                                  // cancel
            {
                m_From.SendLocalizedMessage(500737); // Canceled resignation.
                break;
            }
            }
        }
Пример #57
0
 /// <summary>
 /// Constructs a new PacketLib for Client Version 1.127
 /// </summary>
 public PacketLib1127(GameClient client)
     : base(client)
 {
 }
Пример #58
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendMessage(new SanctionStatusComposer());
 }
Пример #59
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendMessage(new ScrSendUserInfoComposer());
 }
Пример #60
0
 public Appearing(GameClient client, byte[] data)
 {
     base.makeme(client, data);
 }