示例#1
0
文件: L2Npc.cs 项目: LFBRxD/L2dotNET
 public override async Task BroadcastUserInfoAsync()
 {
     // TODO: Sends to all players on the server. It is not right
     foreach (L2Player pl in L2World.GetPlayers())
     {
         await pl.SendPacketAsync(new NpcInfo(this));
     }
 }
示例#2
0
 public override async Task SendPacketAsync(GameserverPacket pk)
 {
     foreach (L2Player pl in L2World.GetPlayers())
     {
         // TODO: Sends to all players on the server. It is not right
         await pl.Gameclient.SendPacketAsync(pk);
     }
 }
示例#3
0
        public override async Task RunImpl()
        {
            L2Player player = L2World.GetPlayers().FirstOrDefault(x => x.Account.AccountId == _accountId);

            if (player == null)
            {
                GameServer.ServiceProvider.GetService <ClientManager>().Disconnect(_accountId);
                return;
            }

            await L2World.KickPlayer(player);
        }
示例#4
0
        public virtual List <L2Player> GetKnownPlayers(bool excludeSelf = true)
        {
            L2WorldRegion region = Region;

            if (region == null)
            {
                return(new List <L2Player>());
            }

            List <L2Player> result = new List <L2Player>();

            if (excludeSelf)
            {
                region.GetSurroundingRegions().ForEach(reg => result.AddRange(L2World.GetPlayers().Where(obj => obj != this)));
            }
            else
            {
                region.GetSurroundingRegions().ForEach(reg => result.AddRange(L2World.GetPlayers()));
            }
            return(result);
        }
示例#5
0
 public override void Execute(string param)
 {
     Console.WriteLine("Count - " + L2World.GetPlayers().Count);
 }
示例#6
0
        public void UpdatePlayersOnline()
        {
            short cnt = (short)L2World.GetPlayers().Count;

            SendPacket(new PlayerCount(cnt));
        }
示例#7
0
 private static void UpdateTimeForAll()
 {
     L2World.GetPlayers().ForEach(UpdateTimeForPlayer);
 }
示例#8
0
        public void ScreenAnnounce(string text)
        {
            CreatureSay cs = new CreatureSay(SayIDList.CHAT_SCREEN_ANNOUNCE, text);

            L2World.GetPlayers().ForEach(p => p.SendPacketAsync(cs));
        }
示例#9
0
        public void CriticalAnnounce(string text)
        {
            CreatureSay cs = new CreatureSay(SayIDList.CHAT_CRITICAL_ANNOUNCE, text);

            L2World.GetPlayers().ForEach(p => p.SendPacketAsync(cs));
        }
示例#10
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;

                CreatureSay cs = new CreatureSay(player.ObjectId, _type, player.Name, _text);

                switch (_type)
                {
                case SayIDList.CHAT_NORMAL:
                    foreach (L2Player target in L2World.GetPlayers().Where(target => player.IsInsideRadius(target, 1250, true, false) && (player != target)))
                    {
                        target.SendPacketAsync(cs);
                    }

                    player.SendPacketAsync(cs);
                    break;

                case SayIDList.CHAT_SHOUT:
                    //L2World.BroadcastToRegion(player.X, player.Y, cs);
                    break;

                case SayIDList.CHAT_TELL:
                    {
                        L2Player target;
                        if (player.Name.Equals(_target))
                        {
                            target = player;
                        }
                        //else
                        //    target = L2World.GetPlayer(_target);

                        //if (target == null)
                        //{
                        //    SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_NOT_ONLINE);
                        //    sm.AddString(_target);
                        //    player.sendPacket(sm);

                        //    player.sendActionFailed();
                        //    return;
                        //}
                        //else
                        //{
                        //    if (target.WhieperBlock)
                        //    {
                        //        player.sendSystemMessage(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
                        //        player.sendActionFailed();
                        //        return;
                        //    }
                        //    else
                        //    {
                        //        player.sendPacket(new CreatureSay(player.ObjID, Type, $"->"{target.Name}", _text));
                        //        target.sendPacket(cs);
                        //    }
                        //}
                    }
                    break;

                case SayIDList.CHAT_PARTY:
                    player.Party?.BroadcastToMembers(cs);
                    break;

                case SayIDList.CHAT_MARKET:
                    L2World.GetPlayers().ForEach(p => p.SendPacketAsync(cs));
                    break;

                case SayIDList.CHAT_HERO:
                    {
                        if (player.Heroic == 1)
                        {
                            L2World.GetPlayers().ForEach(p => p.SendPacketAsync(cs));
                        }
                        else
                        {
                            player.SendActionFailedAsync();
                        }
                    }

                    break;
                }
            });
        }