From 479b539b44075cc0fa53ce9c073477f5cf4e93d1 Mon Sep 17 00:00:00 2001 From: Li Date: Sun, 8 May 2022 17:17:00 +1200 Subject: [PATCH] Fix %CALL HORSE --- HorseIsleServer/LibHISP/Game/Chat/Command.cs | 30 +++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/HorseIsleServer/LibHISP/Game/Chat/Command.cs b/HorseIsleServer/LibHISP/Game/Chat/Command.cs index 10f1c2b..0de0d1c 100644 --- a/HorseIsleServer/LibHISP/Game/Chat/Command.cs +++ b/HorseIsleServer/LibHISP/Game/Chat/Command.cs @@ -782,17 +782,27 @@ namespace HISP.Game.Chat if (!user.Administrator) return false; - if (args.Length >= 1) - if (args[0].ToUpper() != "HORSE") - return false; + if (args.Length <= 0) + return; - string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message); - - WildHorse horse = WildHorse.WildHorses[GameServer.RandomNumberGenerator.Next(0, WildHorse.WildHorses.Length)]; - horse.X = user.X; - horse.Y = user.Y; - - GameServer.UpdateAreaForAll(user.X, user.Y); + try + { + if (args[0].ToUpper() != "HORSE") + return false; + + string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message); + + WildHorse horse = WildHorse.WildHorses[GameServer.RandomNumberGenerator.Next(0, WildHorse.WildHorses.Length)]; + horse.X = user.X; + horse.Y = user.Y; + + GameServer.UpdateAreaForAll(user.X, user.Y); + } + catch (Exception) + { + return false; + } + byte[] chatPacket = PacketBuilder.CreateChat(formattedmessage, PacketBuilder.CHAT_BOTTOM_LEFT); user.LoggedinClient.SendPacket(chatPacket);