Exemple #1
0
        /// <summary> Spawns this player to all other players that can see the player in the current world. </summary>
        public static void GlobalSpawn(Player p, Position pos, Orientation rot, bool self, string possession = "")
        {
            Player[] players = PlayerInfo.Online.Items;
            p.Game.lastSpawnColor = p.Game.Infected ? ZSGame.InfectCol : p.color;
            TabList.Update(p, self);

            foreach (Player other in players)
            {
                if ((other.Loading && p != other) || p.level != other.level)
                {
                    continue;
                }

                if (p != other && other.CanSeeEntity(p))
                {
                    Spawn(other, p, pos, rot, possession);
                }
                else if (p == other && self)
                {
                    other.Pos     = pos; other.SetYawPitch(rot.RotY, rot.HeadX);
                    other.lastPos = other.Pos; other.lastRot = other.Rot;
                    Spawn(other, p, pos, rot, possession);
                }
            }
        }
Exemple #2
0
        /// <summary> Despawns this player to all other players that can
        /// (or cannot if 'toVisible' is false) see the player in the current world. </summary>
        public static void GlobalDespawn(Player p, bool self, bool toVisible = true)
        {
            Player[] players = PlayerInfo.Online.Items;
            TabList.RemoveAll(p, self, toVisible);

            foreach (Player other in players)
            {
                if (p.level != other.level)
                {
                    continue;
                }

                bool despawn = other.CanSeeEntity(p);
                if (!toVisible)
                {
                    despawn = !despawn;
                }

                if (p != other && despawn)
                {
                    Despawn(other, p);
                }
                else if (p == other && self)
                {
                    Despawn(other, p);
                }
            }
        }
Exemple #3
0
        /// <summary> Spawns this player to all other players that can see the player in the current world. </summary>
        public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z,
                                       byte rotx, byte roty, bool self, string possession = "")
        {
            Player[] players = PlayerInfo.Online.Items;
            p.Game.lastSpawnColor = p.Game.Infected ? ZombieGame.InfectCol : p.color;
            TabList.Update(p, self);

            foreach (Player other in players)
            {
                if ((other.Loading && p != other) || p.level != other.level)
                {
                    continue;
                }

                if (p != other && Entities.CanSeeEntity(other, p))
                {
                    Spawn(other, p, p.id, x, y, z, rotx, roty, possession);
                }
                else if (p == other && self)
                {
                    other.pos = new ushort[3] {
                        x, y, z
                    }; other.rot = new byte[2] {
                        rotx, roty
                    };
                    other.oldpos = other.pos; other.oldrot = other.rot;
                    Spawn(other, p, Entities.SelfID, x, y, z, rotx, roty, possession);
                }
            }
        }
Exemple #4
0
 internal static void Despawn(Player dst, PlayerBot b)
 {
     dst.SendRaw(Opcode.RemoveEntity, b.id);
     if (Server.TablistBots)
     {
         TabList.Remove(dst, b.id);
     }
 }
Exemple #5
0
 internal static void Despawn(Player dst, byte id)
 {
     dst.SendRaw(Opcode.RemoveEntity, id);
     if (!Server.TablistGlobal)
     {
         TabList.Remove(dst, id);
     }
 }
Exemple #6
0
 internal static void Despawn(Player dst, PlayerBot b)
 {
     OnEntityDespawnedEvent.Call(b, dst);
     dst.Send(Packet.RemoveEntity(b.id));
     if (Server.Config.TablistBots)
     {
         TabList.Remove(dst, b);
     }
 }
Exemple #7
0
        public static void Despawn(Player dst, PlayerBot b)
        {
            OnEntityDespawnedEvent.Call(b, dst);
            dst.Session.SendRemoveEntity(b.id);

            if (Server.Config.TablistBots)
            {
                TabList.Remove(dst, b);
            }
        }
Exemple #8
0
        internal static void Despawn(Player dst, Player other)
        {
            OnEntityDespawnedEvent.Call(other, dst);
            byte id = other == dst ? SelfID : other.id;

            dst.Send(Packet.RemoveEntity(id));
            if (!Server.Config.TablistGlobal)
            {
                TabList.Remove(dst, other);
            }
        }
Exemple #9
0
 static void SetChat(Player p, Level l, string v)
 {
     Toggle(p, l, ref l.Config.ServerWideChat, "Local level only chat", true);
     Player[] players = PlayerInfo.Online.Items;
     foreach (Player pl in players)
     {
         if (pl.level == l)
         {
             TabList.Update(pl, true);
         }
     }
 }
Exemple #10
0
        public static void Spawn(Player dst, Player p, Position pos,
                                 Orientation rot, string possession = "")
        {
            byte   id = p == dst ? Entities.SelfID : p.id;
            string name = p.color + p.truename + possession;
            string skin = p.SkinName, model = p.Model;

            OnEntitySpawnedEvent.Call(p, ref name, ref skin, ref model, dst);

            SpawnRaw(dst, id, p, pos, rot, skin, name, model);
            if (!Server.Config.TablistGlobal)
            {
                TabList.Add(dst, p, id);
            }
        }
Exemple #11
0
        internal static void Spawn(Player dst, PlayerBot b)
        {
            string name = Chat.Format(b.color + b.DisplayName, dst, true, false);

            if (b.DisplayName.CaselessEq("empty"))
            {
                name = "";
            }
            string skin  = Chat.Format(b.SkinName, dst, true, false);
            string model = Chat.Format(b.Model, dst, true, false);

            OnEntitySpawnedEvent.Call(b, ref name, ref skin, ref model, dst);
            SpawnRaw(dst, b.id, b, b.Pos, b.Rot, skin, name, model);
            if (Server.Config.TablistBots)
            {
                TabList.Add(dst, b);
            }
        }
Exemple #12
0
        internal static void Spawn(Player dst, Player p, byte id, ushort x, ushort y, ushort z,
                                   byte rotx, byte roty, string possession = "")
        {
            if (!Server.TablistGlobal)
            {
                TabList.Add(dst, p, id);
            }
            if (!Server.zombie.Running || !p.Game.Infected)
            {
                string col = GetSupportedCol(dst, p.color);
                if (dst.hasExtList)
                {
                    dst.SendExtAddEntity2(id, p.skinName, col + p.truename + possession, x, y, z, rotx, roty);
                }
                else
                {
                    dst.SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty);
                }
                return;
            }

            string name = p.truename, skinName = p.skinName;

            if (ZombieGameProps.ZombieName != "" && !dst.Game.Aka)
            {
                name = ZombieGameProps.ZombieName; skinName = name;
            }

            if (dst.hasExtList)
            {
                dst.SendExtAddEntity2(id, skinName, Colors.red + name + possession, x, y, z, rotx, roty);
            }
            else
            {
                dst.SendSpawn(id, Colors.red + name + possession, x, y, z, rotx, roty);
            }

            if (dst.hasChangeModel && id != Entities.SelfID)
            {
                dst.SendChangeModel(id, ZombieGameProps.ZombieModel);
            }
        }
Exemple #13
0
        internal static void Spawn(Player dst, PlayerBot b)
        {
            string name = Chat.Format(b.color + b.DisplayName, dst, true, true, false);

            if (b.DisplayName.CaselessEq("empty"))
            {
                name = "";
            }
            string skin = Chat.Format(b.SkinName, dst, true, true, false);

            if (dst.hasExtList)
            {
                dst.SendExtAddEntity2(b.id, skin, name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
            }
            else
            {
                dst.SendSpawn(b.id, name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
            }
            if (Server.TablistBots)
            {
                TabList.Add(dst, b);
            }
        }
Exemple #14
0
        /// <summary> Attempts to change the nickname of the target player </summary>
        /// <remarks> Not allowed when players who cannot speak (e.g. muted) </remarks>
        public static bool SetNick(Player p, string target, string nick)
        {
            if (Colors.Strip(nick).Length >= 30)
            {
                p.Message("Nick must be under 30 letters.");
                return(false);
            }
            Player who = PlayerInfo.FindExact(target);

            if (nick.Length == 0)
            {
                MessageAction(p, target, who, "λACTOR &Sremoved λTARGET nick");
                nick = Server.ToRawUsername(target);
            }
            else
            {
                if (!p.CheckCanSpeak("change nicks"))
                {
                    return(false);
                }

                // TODO: select color from database?
                string color = who != null ? who.color : Group.GroupIn(target).Color;
                MessageAction(p, target, who, "λACTOR &Schanged λTARGET nick to " + color + nick);
            }

            if (who != null)
            {
                who.DisplayName = nick;
            }
            if (who != null)
            {
                TabList.Update(who, true);
            }
            PlayerDB.SetNick(target, nick);
            return(true);
        }