[OpenNos/Collection] Crash fixes

12/14/2018 10:34 AfterLife-#31
Packetlogger use item on Magic Eraser Crash

Most crashes can be fixxed by doing your null-checks..


12/14/2018 17:51 redbull2905#32
FIX trade (opennos)

change:

Code:
        // TODO: TRANSLATE IT TO PACKETDEFINITION!
        [Packet("exc_list")]
        public void ExchangeList(string packet)
        {
            string[] packetsplit = packet.Split(' ');
            if (packetsplit.Length > 2)
            {
                if (!long.TryParse(packetsplit[2], out long gold))
                {
                    return;
                }
                if (!long.TryParse(packetsplit[3], out long bankgold))
                {
                    return;
                }
                byte[] type = new byte[10];
                byte[] qty = new byte[10];
                short[] slot = new short[10];
                var packetList = string.Empty;

                if (gold < 0 || gold > Session.Character.Gold || bankgold < 0 || bankgold > Session.Character.GoldBank / 1000 || Session.Character.ExchangeInfo == null || Session.Character.ExchangeInfo.ExchangeList.Any())
                {
                    return;
                }

                var targetSession = ServerManager.Instance.GetSessionByCharacterId(Session.Character.ExchangeInfo.TargetCharacterId);
                if (Session.Character.HasShopOpened || targetSession != null && targetSession.Character.HasShopOpened)
                {
                    CloseExchange(Session, targetSession);
                    return;
                }

                for (int j = 7, i = 0; j <= packetsplit.Length && i < 10; j += 3, i++)
                {
                    byte.TryParse(packetsplit[j - 3], out type[i]);
                    short.TryParse(packetsplit[j - 2], out slot[i]);
                    byte.TryParse(packetsplit[j - 1], out qty[i]);
                    if ((InventoryType)type[i] == InventoryType.Bazaar)
                    {
                        CloseExchange(Session, targetSession);
                        return;
                    }

                    var item = Session.Character.Inventory.LoadBySlotAndType(slot[i], (InventoryType)type[i]);
                    if (item == null)
                    {
                        return;
                    }

                    if (qty[i] <= 0 || item.Amount < qty[i])
                    {
                        return;
                    }

                    var it = item.DeepCopy();
                    if (it.Item.IsTradable && !it.IsBound)
                    {
                        it.Amount = qty[i];
                        Session.Character.ExchangeInfo.ExchangeList.Add(it);
                        if (type[i] != 0)
                        {
                            packetList += $"{i}.{type[i]}.{it.ItemVNum}.{qty[i]} ";
                        }
                        else
                        {
                            packetList += $"{i}.{type[i]}.{it.ItemVNum}.{it.Rare}.{it.Upgrade} ";
                        }
                    }
                    else if (it.IsBound)
                    {
                        Session.SendPacket("exc_close 0");
                        Session.CurrentMapInstance?.Broadcast(Session, "exc_close 0", ReceiverType.OnlySomeone, string.Empty, Session.Character.ExchangeInfo.TargetCharacterId);

                        ServerManager.Instance.SetProperty(Session.Character.ExchangeInfo.TargetCharacterId, nameof(Character.ExchangeInfo), null);
                        Session.Character.ExchangeInfo = null;
                        return;
                    }
                }

                Session.Character.ExchangeInfo.Gold = gold;
                Session.Character.ExchangeInfo.BankGold = bankgold;
                Session.CurrentMapInstance?.Broadcast(Session, $"exc_list 1 {Session.Character.CharacterId} {gold} {0} {bankgold} {0} {packetList}", ReceiverType.OnlySomeone, string.Empty, Session.Character.ExchangeInfo.TargetCharacterId);
                Session.Character.ExchangeInfo.Validated = true;
            }

        }
by:

Code:
        // TODO: TRANSLATE IT TO PACKETDEFINITION!
        [Packet("exc_list")]
        public void ExchangeList(string packet)
        {
            string[] packetsplit = packet.Split(' ');
            if (packetsplit.Length < 4)
            {
                Session.SendPacket(UserInterfaceHelper.GenerateInfo("Update your Client & Download the new launcher"));
                return;
            }

            if (!long.TryParse(packetsplit[2], out long gold))
            {
                return;
            }

            if (!long.TryParse(packetsplit[3], out long bankGold))
            {
                return;
            }

            byte[] type = new byte[10];
            ushort[] qty = new ushort[10];
            short[] slot = new short[10];
            string packetList = string.Empty;

            if (gold < 0 || gold > Session.Character.Gold || Session.Character.ExchangeInfo == null || Session.Character.ExchangeInfo.ExchangeList.Any())
            {
                return;
            }

            ClientSession targetSession = ServerManager.Instance.GetSessionByCharacterId(Session.Character.ExchangeInfo.TargetCharacterId);
            if (Session.Character.HasShopOpened || targetSession != null && targetSession.Character.HasShopOpened)
            {
                CloseExchange(Session, targetSession);
                return;
            }

            for (int j = 7, i = 0; j <= packetsplit.Length && i < 10; j += 3, i++)
            {
                byte.TryParse(packetsplit[j - 3], out type[i]);
                short.TryParse(packetsplit[j - 2], out slot[i]);
                ushort.TryParse(packetsplit[j - 1], out qty[i]);
                if ((InventoryType)type[i] == InventoryType.Bazaar)
                {
                    CloseExchange(Session, targetSession);
                    return;
                }

                ItemInstance item = Session.Character.Inventory.LoadBySlotAndType(slot[i], (InventoryType)type[i]);
                if (item == null)
                {
                    return;
                }

                if (qty[i] <= 0 || item.Amount < qty[i])
                {
                    return;
                }

                ItemInstance it = item.DeepCopy();
                if (it.Item.IsTradable && !it.IsBound)
                {
                    //it.Amount = qty[i];
                    Session.Character.ExchangeInfo.ExchangeList.Add(it);
                    if (type[i] != 0)
                    {
                        packetList += $"{i}.{type[i]}.{it.ItemVNum}.{qty[i]} ";
                    }
                    else
                    {
                        packetList += $"{i}.{type[i]}.{it.ItemVNum}.{it.Rare}.{it.Upgrade} ";
                    }
                }
                else if (it.IsBound)
                {
                    Session.SendPacket("exc_close 0");
                    Session.CurrentMapInstance?.Broadcast(Session, "exc_close 0", ReceiverType.OnlySomeone, string.Empty, Session.Character.ExchangeInfo.TargetCharacterId);

                    ServerManager.Instance.SetProperty(Session.Character.ExchangeInfo.TargetCharacterId, nameof(Character.ExchangeInfo), null);
                    Session.Character.ExchangeInfo = null;
                    return;
                }
            }

            Session.Character.ExchangeInfo.Gold = gold;
            Session.Character.ExchangeInfo.BankGold = bankGold;
            Session.CurrentMapInstance?.Broadcast(Session, $"exc_list 1 {Session.Character.CharacterId} {gold} {(bankGold == 0 ? 0 : bankGold)} {(packetList == string.Empty ? "0" : packetList)}",
                ReceiverType.OnlySomeone, string.Empty, Session.Character.ExchangeInfo.TargetCharacterId);
            Session.Character.ExchangeInfo.Validated = true;
        }

        /// <summary>
        ///     req_exc packet
        /// </summary>
        /// <param name="exchangeRequestPacket"></param>
        public void ExchangeRequest(ExchangeRequestPacket exchangeRequestPacket)
        {
            if (exchangeRequestPacket.CharacterId != 0 &&
                Session.Character.MapInstanceId != ServerManager.Instance.GetProperty<Guid>(exchangeRequestPacket.CharacterId, nameof(Character.MapInstanceId)))
            {
                ServerManager.Instance.SetProperty(exchangeRequestPacket.CharacterId, nameof(Character.ExchangeInfo), null);
                Session.Character.ExchangeInfo = null;
            }
            else
            {
                switch (exchangeRequestPacket.RequestType)
                {
                    case RequestExchangeType.Requested:
                        if (!Session.HasCurrentMapInstance)
                        {
                            return;
                        }

                        ClientSession targetSession = Session.CurrentMapInstance.GetSessionByCharacterId(exchangeRequestPacket.CharacterId);
                        if (targetSession == null)
                        {
                            return;
                        }

                        if (targetSession.Character.Group != null && targetSession.Character.Group?.GroupType != GroupType.Group)
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                            return;
                        }

                        if (Session.Character.Group != null && Session.Character.Group?.GroupType != GroupType.Group)
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"), 0));
                            return;
                        }

                        if (Session.Character.IsBlockedByCharacter(exchangeRequestPacket.CharacterId))
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                            return;
                        }

                        if (Session.Character.Speed == 0 || targetSession.Character.Speed == 0)
                        {
                            Session.Character.ExchangeBlocked = true;
                        }

                        if (targetSession.Character.LastSkillUse.AddSeconds(20) > DateTime.Now || targetSession.Character.LastDefence.AddSeconds(20) > DateTime.Now)
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateInfo(string.Format(Language.Instance.GetMessageFromKey("PLAYER_IN_BATTLE"), targetSession.Character.Name)));
                            return;
                        }

                        if (Session.Character.LastSkillUse.AddSeconds(20) > DateTime.Now || Session.Character.LastDefence.AddSeconds(20) > DateTime.Now)
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("IN_BATTLE")));
                            return;
                        }

                        if (Session.Character.HasShopOpened || targetSession.Character.HasShopOpened)
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("HAS_SHOP_OPENED"), 10));
                            return;
                        }

                        if (targetSession.Character.ExchangeBlocked)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TRADE_BLOCKED"), 11));
                        }
                        else
                        {
                            if (Session.Character.InExchangeOrTrade || targetSession.Character.InExchangeOrTrade)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ALREADY_EXCHANGE"), 0));
                            }
                            else
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateModal(string.Format(Language.Instance.GetMessageFromKey("YOU_ASK_FOR_EXCHANGE"), targetSession.Character.Name),
                                    0));
                                Session.Character.TradeRequests.Add(targetSession.Character.CharacterId);
                                targetSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                    $"#req_exc^2^{Session.Character.CharacterId} #req_exc^5^{Session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("INCOMING_EXCHANGE"), Session.Character.Name)}"));
                            }
                        }

                        break;

                    case RequestExchangeType.Confirmed: // click Trade button in exchange window
                        if (Session.HasCurrentMapInstance && Session.HasSelectedCharacter
                            && Session.Character.ExchangeInfo != null && Session.Character.ExchangeInfo.TargetCharacterId != Session.Character.CharacterId)
                        {
                            if (!Session.HasCurrentMapInstance)
                            {
                                return;
                            }

                            targetSession = Session.CurrentMapInstance.GetSessionByCharacterId(Session.Character.ExchangeInfo.TargetCharacterId);

                            if (targetSession == null)
                            {
                                return;
                            }

                            if (Session.Character.Group != null && Session.Character.Group?.GroupType != GroupType.Group)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                                return;
                            }

                            if (targetSession.Character.Group != null && targetSession.Character.Group?.GroupType != GroupType.Group)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"), 0));
                                return;
                            }

                            if (Session.IsDisposing || targetSession.IsDisposing)
                            {
                                CloseExchange(Session, targetSession);
                                return;
                            }

                            lock (targetSession.Character.Inventory)
                            {
                                lock (Session.Character.Inventory)
                                {
                                    ExchangeInfo targetExchange = targetSession.Character.ExchangeInfo;
                                    Inventory inventory = targetSession.Character.Inventory;

                                    long gold = targetSession.Character.Gold;
                                    int backpack = targetSession.Character.HaveBackpack() ? 1 : 0;

                                    if (targetExchange == null || Session.Character.ExchangeInfo == null)
                                    {
                                        return;
                                    }

                                    if (Session.Character.ExchangeInfo.Validated && targetExchange.Validated)
                                    {
                                        Session.Character.ExchangeInfo.Confirmed = true;
                                        if (targetExchange.Confirmed && Session.Character.ExchangeInfo.Confirmed)
                                        {
                                            Session.SendPacket("exc_close 1");
                                            targetSession.SendPacket("exc_close 1");

                                            bool  [MENTION=1560910]Continue[/MENTION] = true;
                                            bool goldmax = false;
                                            if (!Session.Character.Inventory.EnoughPlace(targetExchange.ExchangeList, Session.Character.HaveBackpack() ? 1 : 0))
                                            {
                                                 [MENTION=1560910]Continue[/MENTION] = false;
                                            }

                                            if (!inventory.EnoughPlace(Session.Character.ExchangeInfo.ExchangeList, backpack))
                                            {
                                                 [MENTION=1560910]Continue[/MENTION] = false;
                                            }

                                            if (Session.Character.ExchangeInfo.Gold > Session.Character.Gold)
                                            {
                                                return;
                                            }

                                            if (  [MENTION=1560910]Continue[/MENTION] || goldmax)
                                            {
                                                string message =   [MENTION=1560910]Continue[/MENTION]
                                                    ? UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0)
                                                    : UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_GOLD"), 0);
                                                Session.SendPacket(message);
                                                targetSession.SendPacket(message);
                                                CloseExchange(Session, targetSession);
                                            }
                                            else
                                            {
                                                if (Session.Character.ExchangeInfo.ExchangeList.Any(ei => !(ei.Item.IsTradable || ei.IsBound)))
                                                {
                                                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_NOT_TRADABLE"), 0));
                                                    CloseExchange(Session, targetSession);
                                                }
                                                else // all items can be traded
                                                {
                                                    Session.Character.IsExchanging = targetSession.Character.IsExchanging = true;

                                                    // exchange all items from target to source
                                                    Exchange(targetSession, Session);

                                                    // exchange all items from source to target
                                                    Exchange(Session, targetSession);

                                                    Session.Character.IsExchanging = targetSession.Character.IsExchanging = false;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Session.SendPacket(UserInterfaceHelper.GenerateInfo(string.Format(Language.Instance.GetMessageFromKey("IN_WAITING_FOR"),
                                                targetSession.Character.Name)));
                                        }
                                    }
                                }
                            }
                        }

                        break;

                    case RequestExchangeType.Cancelled: // cancel trade thru exchange window
                        if (Session.HasCurrentMapInstance && Session.Character.ExchangeInfo != null)
                        {
                            targetSession = Session.CurrentMapInstance.GetSessionByCharacterId(Session.Character.ExchangeInfo.TargetCharacterId);
                            CloseExchange(Session, targetSession);
                        }

                        break;

                    case RequestExchangeType.List:
                        bool otherInExchangeOrTrade = ServerManager.Instance.GetProperty<bool>(exchangeRequestPacket.CharacterId, nameof(Character.InExchangeOrTrade));
                        if (!Session.Character.InExchangeOrTrade || !otherInExchangeOrTrade)
                        {
                            ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(exchangeRequestPacket.CharacterId);
                            if (exchangeRequestPacket.CharacterId == Session.Character.CharacterId || Session.Character.Speed == 0 || otherSession == null ||
                                otherSession.Character.TradeRequests.All(s => s != Session.Character.CharacterId))
                            {
                                return;
                            }

                            if (Session.Character.Group != null && Session.Character.Group?.GroupType != GroupType.Group)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                                return;
                            }

                            if (otherSession.Character.Group != null && otherSession.Character.Group?.GroupType != GroupType.Group)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"), 0));
                                return;
                            }

                            Session.SendPacket($"exc_list 1 {exchangeRequestPacket.CharacterId} -1");
                            ExchangeInfo exc = new ExchangeInfo
                            {
                                TargetCharacterId = exchangeRequestPacket.CharacterId,
                                Confirmed = false
                            };
                            Session.Character.ExchangeInfo = exc;
                            ServerManager.Instance.SetProperty(exchangeRequestPacket.CharacterId, nameof(Character.ExchangeInfo),
                                new ExchangeInfo { TargetCharacterId = Session.Character.CharacterId, Confirmed = false });
                            Session.CurrentMapInstance?.Broadcast(Session, $"exc_list 1 {Session.Character.CharacterId} -1", ReceiverType.OnlySomeone, string.Empty, exchangeRequestPacket.CharacterId);
                        }
                        else
                        {
                            Session.CurrentMapInstance?.Broadcast(Session, UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ALREADY_EXCHANGE"), 0),
                                ReceiverType.OnlySomeone, string.Empty, exchangeRequestPacket.CharacterId);
                        }

                        break;

                    case RequestExchangeType.Declined:
                        ServerManager.Instance.GetProperty<string>(exchangeRequestPacket.CharacterId, nameof(Character.Name));
                        ServerManager.Instance.SetProperty(exchangeRequestPacket.CharacterId, nameof(Character.ExchangeInfo), null);
                        Session.Character.ExchangeInfo = null;
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("YOU_REFUSED"), 10));
                        Session.CurrentMapInstance?.Broadcast(Session,
                            Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EXCHANGE_REFUSED"), Session.Character.Name), 10), ReceiverType.OnlySomeone, string.Empty,
                            exchangeRequestPacket.CharacterId);
                        break;

                    default:
                        Logger.Log.Warn($"Exchange-Request-Type not implemented. RequestType: {exchangeRequestPacket.RequestType})");
                        break;
                }
            }
        }
If I made mistakes, please let me know :)
12/14/2018 18:46 Blowa#33
Quote:
Originally Posted by redbull2905 View Post
If I made mistakes, please let me know :)
[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]
Wow, such fix, please credit the right people, don't claim it as yours.
- .Instance property is because we changed Static class to singletons in ON.NosWings
- You commented "it.Amount = qty[i];" which will make your fix have an unexpected behavior (The expected behavior is to set the right quantity to the new item)
- Validated property should probably be the name of that property under Ciapa's Fork of OpenNos


"Your fix" :lul:
12/14/2018 18:54 erixor#34
Moreover, to actually proove you have no idea of what the f*ck you're talking about, you're asking people to replace exc_list packet implementation with exc_list + exc_req packet implementation xD

P.S: Wtf are those "[MENTION = x] Continue [ / MENTION]" in your exc_req? :rolleyes:

Please stop pretending to be a developer. If you want any credibility, you need to at least learn something.
12/14/2018 19:28 redbull2905#35
Except that I try to help me, I am not a jester who criticizes h24 and who does nothing ^ ^ big cancer.
12/14/2018 19:34 erixor#36
Blowa is simply saying that you should respect other peoples work by at least not saying it's yours. When you will have understood that, maybe people will start showing respect to you.
12/16/2018 15:41 Shıgeo#37
[BugFix] My fix of the MoveItem (Itemdupe): (InventoryPacketHandler.cs) was false... updated! Redo your changes. Arigato
12/31/2018 10:34 Eleniita96#38
When we create a 4th class new character all the next created new characters are of the 4th class, instead of adventurer. Can someone help me? <3

Thank you!
12/31/2018 12:52 Itachi-Senpai#39
Quote:
Originally Posted by Eleniita96 View Post
When we create a 4th class new character all the next created new characters are of the 4th class, instead of adventurer. Can someone help me? <3

Thank you!
What ?
01/13/2019 01:11 Adrameleckh#40
fix second bug dupe by logger Chigeo

Code:
// add and remove save inventory
                        destinationInventory = takeItem(destinationInventory.Slot, destinationInventory.Type);
                        if (destinationInventory == null)
                        {
                            Logger.Log.Debug($"ShigeoWall: user {Session.Character.Name} tried an Crash: MOVE ITEM");
                            return;
                        }

                        destinationInventory.Slot = sourceSlot;
                        destinationInventory.Type = sourcetype;
                        sourceInventory = takeItem(sourceInventory.Slot, sourceInventory.Type);
                        if (sourceInventory == null)
                        {
                            Logger.Log.Debug($"ShigeoWall: user {Session.Character.Name} tried an Crash: MOVE ITEM");
                            return;
                        }
01/13/2019 04:29 Shıgeo#41
Quote:
Originally Posted by Adrameleckh View Post
fix second bug dupe by logger Chigeo

Code:
// add and remove save inventory
                        destinationInventory = takeItem(destinationInventory.Slot, destinationInventory.Type);
                        if (destinationInventory == null)
                        {
                            Logger.Log.Debug($"ShigeoWall: user {Session.Character.Name} tried an Crash: MOVE ITEM");
                            return;
                        }

                        destinationInventory.Slot = sourceSlot;
                        destinationInventory.Type = sourcetype;
                        sourceInventory = takeItem(sourceInventory.Slot, sourceInventory.Type);
                        if (sourceInventory == null)
                        {
                            Logger.Log.Debug($"ShigeoWall: user {Session.Character.Name} tried an Crash: MOVE ITEM");
                            return;
                        }
I'll check it, if it's correct I get it in the list and write your name to the fix.
Arigato <3
04/02/2019 16:36 redbull2905#42
Code:
 Mate attacker = Session.Character.Mates.First(x => x.MateTransportId == suctlPacket.MateTransportId);
Code:
Mate attacker = Session.Character.Mates.FirstOrDefault(x => x.MateTransportId == suctlPacket.MateTransportId);
            if (attacker == null)
            {
                return;
            }
04/02/2019 21:45 Shıgeo#43
Quote:
Originally Posted by redbull2905 View Post
Code:
 Mate attacker = Session.Character.Mates.First(x => x.MateTransportId == suctlPacket.MateTransportId);
Code:
Mate attacker = Session.Character.Mates.FirstOrDefault(x => x.MateTransportId == suctlPacket.MateTransportId);
            if (attacker == null)
            {
                return;
            }
Thanks for your reply. <3
I will check it and put it the next days inside the list. (Do you fixxed it?, by yourself?)
04/04/2019 18:55 redbull2905#44
yes someone did a server and I saw the logs of the crash that came from the.
06/21/2019 15:56 Radiv#45
kick null from raid
HTML Code:
                // Kick from Raid
                case 3:
                    if (Session.CurrentMapInstance.MapInstanceType == MapInstanceType.RaidInstance)
                    {
                        return;
                    }

                    if (Session.Character.Group?.IsLeader(Session) == true)
                    {
                        ClientSession chartokick = ServerManager.Instance.GetSessionByCharacterId(rdPacket.CharacterId);
                        if (chartokick.Character?.Group == null)
                        {
                            return;
                        }
                        if (rdPacket.CharacterId != chartokick.Character.CharacterId)
                        {
                            return;
                        }

                        chartokick.SendPacket(
                            UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("KICK_RAID"), 0));
                        grp = chartokick.Character?.Group;
                        chartokick.SendPacket(chartokick.Character?.GenerateRaid(1, true));
                        chartokick.SendPacket(chartokick.Character?.GenerateRaid(2, true));
                        grp?.LeaveGroup(chartokick);
                        grp?.Characters.ForEach(s =>
                        {
                            s.SendPacket(grp.GenerateRdlst());
                            s.SendPacket(s.Character.GenerateRaid(0));
                        });
                    }break;
change it to
HTML Code:
                // Kick from Raid
                case 3:
                    if (Session.CurrentMapInstance.MapInstanceType == MapInstanceType.RaidInstance)
                    {
                        return;
                    }

                    if (Session.Character.Group?.IsLeader(Session) == true)
                    {
                        ClientSession chartokick = ServerManager.Instance.GetSessionByCharacterId(rdPacket.CharacterId);
                        if (chartokick != null)
                        {
                            if (chartokick.Character?.Group == null)
                            {
                                return;
                            }
                            if (rdPacket.CharacterId != chartokick.Character.CharacterId)
                            {
                                return;
                            }

                            chartokick.SendPacket(
                                UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("KICK_RAID"), 0));
                            grp = chartokick.Character?.Group;
                            chartokick.SendPacket(chartokick.Character?.GenerateRaid(1, true));
                            chartokick.SendPacket(chartokick.Character?.GenerateRaid(2, true));
                            grp?.LeaveGroup(chartokick);
                            grp?.Characters.ForEach(s =>
                            {
                                s.SendPacket(grp.GenerateRdlst());
                                s.SendPacket(s.Character.GenerateRaid(0));
                            });
                        }
                    }break;