예제 #1
0
        private void SetDPS(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Invalid usage: /regdamage[/rd] [region name] [damage]", Color.Red);
            }
            else
            {
                string region = args.Parameters[0];
                int    damage = 0;
                if (!int.TryParse(args.Parameters[1], out damage))
                {
                    args.Player.SendMessage("You must specify damage as a number.", Color.Red);
                    return;
                }

                FlaggedRegion reg = regions.getRegion(region);
                if (reg == null)
                {
                    args.Player.SendMessage("Invalid region", Color.Red);
                    return;
                }

                args.Player.SendMessage(String.Format("DPS for {0} is now {1}", region, damage), Color.Green);
                reg.setDPS(damage);
                regions.UpdateRegion(reg.getRegion().Name);
            }
        }
예제 #2
0
        public void OnDamage(object sender, TShockAPI.GetDataHandlers.PlayerDamageEventArgs args)
        {
            Region r = TShock.Regions.GetTopRegion(
                TShock.Regions.InAreaRegion((int)Main.player[args.ID].position.X / 16, (int)Main.player[args.ID].position.Y / 16));

            if (r != null)
            {
                FlaggedRegion reg = regionManager.getRegion(r.Name);
                if (reg != null)
                {
                    List <Flags> flags = reg.getFlags();
                    if (flags.Contains(Flags.HEALONDAMAGE))
                    {
                        int heal   = 0;
                        int damage = Math.Max(args.Damage * (args.Critical ? 2 : 1) -
                                              (int)(Math.Round(Main.player[args.ID].statDefense * .5)), 1);

                        var items = TShock.Utils.GetItemByIdOrName("heart");
                        while (heal < damage)
                        {
                            Utilities.GiveItem(items[0].name, (int)Main.player[args.ID].position.X, (int)Main.player[args.ID].position.Y, items[0].width,
                                               items[0].height, items[0].type, 1, items[0].prefix, args.ID, Main.player[args.ID].velocity);
                            heal += 20;
                        }
                    }
                }
            }
        }
예제 #3
0
        private void SetHPS(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Invalid usage: /regheal[/rh] [region name] [heal]", Color.Red);
            }
            else
            {
                string region = args.Parameters[0];
                int    health = 0;
                if (!int.TryParse(args.Parameters[1], out health))
                {
                    args.Player.SendMessage("You must specify health as a number of seconds between heart drops.", Color.Red);
                    return;
                }

                FlaggedRegion reg = regions.getRegion(region);
                if (reg == null)
                {
                    args.Player.SendMessage("Invalid region", Color.Red);
                    return;
                }

                args.Player.SendMessage(String.Format("HPS for {0} is now {1}", region, health), Color.Green);
                reg.setHPS(health);
                regions.UpdateRegion(reg.getRegion().Name);
            }
        }
예제 #4
0
        private void SetDPS(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Invalid usage: /regdps(/rd) [region name] <dps>", Color.Red); // param) region name: 0, damage: 1, total count: 2
            }
            else
            {
                string region = args.Parameters[0];
                int    damage = 0;
                if (!int.TryParse(args.Parameters[1], out damage))
                {
                    args.Player.SendMessage("You must specify damage as a number.", Color.Red);
                    return;
                }

                FlaggedRegion reg = regions.getRegion(region);
                if (reg == null)
                {
                    args.Player.SendMessage("Invalid region", Color.Red);
                    return;
                }

                args.Player.SendMessage(String.Format("DPS for Region '{0}' is now '{1}'.", region, damage), Color.Green); // reference
                reg.setDPS(damage);
                regions.UpdateRegion(reg.getRegion().Name);
            }
        }
예제 #5
0
        private void SetHPS(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Invalid usage: /reghps(/rh) [region name] <hps>", Color.Red);
            }
            else
            {
                string region = args.Parameters[0];
                int    health = 0;
                if (!int.TryParse(args.Parameters[1], out health))
                {
                    args.Player.SendMessage("You must specify heart-drop period as a number.", Color.Red);
                    return;
                }

                FlaggedRegion reg = regions.getRegion(region);
                if (reg == null)
                {
                    args.Player.SendMessage("Invalid region", Color.Red);
                    return;
                }

                args.Player.SendMessage(String.Format("HPS for Region '{0}' is now {1}.", region, health), Color.Green);
                reg.setHPS(health);
                regions.UpdateRegion(reg.getRegion().Name);
            }
        }
예제 #6
0
        private void SetTempGroup(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Invalid usage: /regtemp[/rt] [region name] [group name]", Color.Red);
            }
            else
            {
                string region = args.Parameters[0];
                string group  = args.Parameters[1];
                Group  g      = TShock.Groups.GetGroupByName(group);
                if (g == null)
                {
                    args.Player.SendErrorMessage("Group '{0}' does not exist.", group);
                    return;
                }

                FlaggedRegion reg = regions.getRegion(region);
                if (reg == null)
                {
                    args.Player.SendMessage("Invalid region", Color.Red);
                    return;
                }

                args.Player.SendMessage(String.Format("Temp Group for {0} is now {1}", region, g.Name), Color.Green);
                reg.setTempGroup(g);
                regions.UpdateRegion(reg.getRegion().Name);
            }
        }
 public void ImportRegion( string name, int flags, int d )
 {
     var reg = TShock.Regions.GetRegionByName(name);
     if( reg == null )
     {
         Console.WriteLine( "{0} was not found in tshocks region list.", name);
         return;
     }
     FlaggedRegion f = new FlaggedRegion(reg, flags);
     f.setDPS( d );
     regions.Add( name, f );
 }
예제 #8
0
        public bool UpdateRegion(string name)
        {
            if (!regions.ContainsKey(name))
            {
                return(false);
            }

            FlaggedRegion f = regions[name];

            RegionFlags.db.Query(
                "UPDATE Regions SET Flags=@0, Damage=@1, Heal=@2, TempGroup=@3 WHERE Name=@4", f.getIntFlags(), f.getDPS(), f.getHPS(), f.getTempGroup(), name);
            return(true);
        }
예제 #9
0
        private void OnUpdate(EventArgs args)
        {
            lock ( players )
            {
                foreach (RegionPlayer ply in players)
                {
                    if (ply != null)
                    {
                        ply.Update();
                    }
                }
            }

            DateTime now = DateTime.Now;

            if ((now - lastUpdate).TotalSeconds > 0)
            {
                lastUpdate = now;
                lock (Main.npc)
                {
                    foreach (NPC npc in Main.npc)
                    {
                        if (!npc.active)
                        {
                            continue;
                        }

                        Region r = TShock.Regions.GetTopRegion(
                            TShock.Regions.InAreaRegion((int)npc.position.X / 16, (int)npc.position.Y / 16));
                        if (r != null)
                        {
                            FlaggedRegion reg = regions.getRegion(r.Name);
                            if (reg != null)
                            {
                                List <Flags> flags = reg.getFlags();
                                if (flags.Contains(Flags.MOBKILL))
                                {
                                    npc.StrikeNPC(9999, 0f, 0);
                                    NetMessage.SendData(23, -1, -1, "", npc.whoAmI, 0f, 0f, 0f, 0);
                                }
                                else if (flags.Contains(Flags.NOMOB))
                                {
                                    npc.active = false;
                                    NetMessage.SendData(23, -1, -1, "", npc.whoAmI, 0f, 0f, 0f, 0);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        public bool UpdateRegion(string name)
        {
            if (!regions.ContainsKey(name))
            {
                return(false);
            }

            FlaggedRegion f = regions[name];

            //string Flagsnew = "";
            //Flagsnew = String.Join(",", f.getIntFlags);
            RegionFlags.db.Query(
                "UPDATE Regions SET Flags=@0, Damage=@1, Heal=@2 WHERE Name=@3", f.getIntFlags(), f.getDPS(), f.getHPS(), name);
            return(true);
        }
 public void ImportRegion( string name, int flags, int d, int h, List<string> items, Group tempGroup )
 {
     var reg = TShock.Regions.GetRegionByName(name);
     if( reg == null )
     {
         Console.WriteLine( "{0} was not found in tshocks region list.", name);
         return;
     }
     FlaggedRegion f = new FlaggedRegion(reg, flags);
     f.setDPS( d );
     f.setHPS(h);
     f.setBannedItems(items);
     f.setTempGroup(tempGroup);
     regions.Add( name, f );
 }
        public bool AddRegion( string name, int flags )
        {
            if( regions.ContainsKey( name ) )
            {
                return false;
            }
            var reg = TShock.Regions.GetRegionByName(name);
            FlaggedRegion f = new FlaggedRegion(reg, flags);
            f.setDPS(0);
            //todo:save to db
            RegionFlags.db.Query(
                    "INSERT INTO Regions (Name, Flags, Damage) VALUES (@0, @1, @2);",
                    name, flags, 0);
            regions.Add(name, f);

            return true;
        }
예제 #13
0
        public void ImportRegion(string name, int flags, int d, int h, List <string> items, Group tempGroup)
        {
            var reg = TShock.Regions.GetRegionByName(name);

            if (reg == null)
            {
                Console.WriteLine("{0} was not found in tshocks region list.", name);
                return;
            }
            FlaggedRegion f = new FlaggedRegion(reg, flags);

            f.setDPS(d);
            f.setHPS(h);
            f.setBannedItems(items);
            f.setTempGroup(tempGroup);
            regions.Add(name, f);
        }
예제 #14
0
        public bool AddRegion(string name, int flags)
        {
            if (regions.ContainsKey(name))
            {
                return(false);
            }
            var           reg = TShock.Regions.GetRegionByName(name);
            FlaggedRegion f   = new FlaggedRegion(reg, flags);

            f.setDPS(0);
            //todo:save to db
            RegionFlags.db.Query(
                "INSERT INTO Regions (Name, Flags, Damage) VALUES (@0, @1, @2);",
                name, flags, 0);
            regions.Add(name, f);

            return(true);
        }
예제 #15
0
        private void ViewFlags(CommandArgs args)
        {
            if (args.Parameters.Count == 1)
            {
                FlaggedRegion region = regions.getRegion(args.Parameters[0]);
                if (region == null)
                {
                    args.Player.SendErrorMessage("Region '{0}' is not a region flag defined region.", args.Parameters[0]);
                    return;
                }

                string flags = string.Join(", ", region.getFlags().Select(f => f.ToString()));
                args.Player.SendInfoMessage("Flags for '{0} are: {1}", region.getRegion().Name, flags);
                return;
            }

            args.Player.SendErrorMessage("Usage: /regview[/rv] [region name] - Views the flags on a given region.");
        }
예제 #16
0
        public void OnNPCStrike(object sender, TShockAPI.GetDataHandlers.NPCStrikeEventArgs args)
        {
            Region r = TShock.Regions.GetTopRegion(
                TShock.Regions.InAreaRegion((int)Main.npc[args.ID].position.X / 16, (int)Main.npc[args.ID].position.Y / 16));

            if (r != null)
            {
                FlaggedRegion reg = regionManager.getRegion(r.Name);
                if (reg != null)
                {
                    List <Flags> flags = reg.getFlags();
                    if (flags.Contains(Flags.GODMOB))
                    {
                        args.Handled           = true;
                        Main.npc[args.ID].life = Main.npc[args.ID].lifeMax;
                        NetMessage.SendData(23, -1, -1, "", args.ID, 0f, 0f, 0f, 0);
                    }
                }
            }
        }
예제 #17
0
        public void ImportRegion(string name, int flags, int d, int h, List <string> items)  // add string wid after name
        {
            //public List<Region> ListAllRegions(string worldid);
            //var rid = TShock.Regions.ListAllRegions(wid);
            var reg = TShock.Regions.GetRegionByName(name);

            //var regwid = TShock.Regions.GetRegionByWorldID(wid);
            if (reg == null) // && regwid == Main.worldID.ToString // add rid.Equals(Main.worldID)
            {
                //Console.ForegroundColor = ConsoleColor.Magenta;
                //Log.Error("Some regions were not found in this world.");

                //Console.WriteLine( "{0} was not found in region list.", name);
                return;
            }
            FlaggedRegion f = new FlaggedRegion(reg, flags);

            f.setDPS(d);
            f.setHPS(h);
            f.setBannedItems(items);
            regions.Add(name, f);
        }
예제 #18
0
        public void Update()
        {
            DateTime now = DateTime.Now;

            Region r = TShock.Regions.GetTopRegion(TShock.Regions.InAreaRegion(player.TileX, player.TileY));

            bool inPVPZone       = false;
            bool inNoPVPZone     = false;
            bool inTempGroupZone = false;

            bool warning = ((now - lastWarned).TotalSeconds > 5);

            if (r != null)
            {
                FlaggedRegion reg = regionManager.getRegion(r.Name);
                if (reg != null)
                {
                    List <Flags> flags = reg.getFlags();
                    if (flags.Contains(Flags.PRIVATE) && !r.HasPermissionToBuildInRegion(player))
                    {
                        Vector2 pos = positions.getTP();
                        player.Teleport((int)pos.X, (int)pos.Y);
                        if (warning)
                        {
                            player.SendMessage("You are barred from entering that region.", Color.Red);
                            lastWarned = now;
                        }
                    }
                    List <string> bannedItems = new List <string>();
                    if (flags.Contains(Flags.ITEMBAN) && InvalidInventory(reg.getItembans(), out bannedItems))
                    {
                        Vector2 pos  = positions.getTP();
                        Vector2 diff = pos - player.TPlayer.position;
                        if (((diff.X * diff.X) + (diff.Y * diff.Y)) > (100 * 100))
                        {
                            player.Teleport((int)pos.X, (int)pos.Y);
                        }
                        else
                        {
                            player.Spawn(Main.spawnTileX, Main.spawnTileY);
                        }


                        if (warning)
                        {
                            player.SendMessage(String.Format("The following are banned in that area: {0}", string.Join(",", bannedItems)), Color.Red);
                            lastWarned = now;
                        }
                    }
                    if (flags.Contains(Flags.DEATH) && !r.HasPermissionToBuildInRegion(player))
                    {
                        NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, " died Indiana Jone's style.", player.Index, 0, 999999,
                                            (float)0);
                        if (warning)
                        {
                            player.SendMessage("You just stumbled into a death trap... no pun intended.", Color.Yellow);
                            lastWarned = now;
                        }
                    }
                    if (flags.Contains(Flags.PVP))
                    {
                        if (!player.TPlayer.hostile)
                        {
                            player.SendMessage("PVP arena entered, pvp enabled.", Color.Green);
                        }

                        player.TPlayer.hostile = true;
                        player.SendData(PacketTypes.TogglePvp);
                        NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                        inPVPZone = true;
                        forcedPVP = true;
                    }
                    if (flags.Contains(Flags.NOPVP))
                    {
                        if (player.TPlayer.hostile)
                        {
                            player.SendMessage("PVP free area entered, pvp disabled.", Color.Green);
                        }

                        player.TPlayer.hostile = false;
                        player.SendData(PacketTypes.TogglePvp);
                        NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                        inNoPVPZone = true;
                        removedPVP  = true;
                    }
                    if (flags.Contains(Flags.HURT))
                    {
                        if ((now - lastDamageUpdate).TotalSeconds > 0)
                        {
                            lastDamageUpdate = now;
                            if (reg.getDPS() > 0)
                            {
                                int damage = (player.TPlayer.statDefense / 2) + reg.getDPS();
                                NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, " died a slow, horrible death.", player.Index, 0, damage,
                                                    (float)0);
                            }
                        }
                    }
                    if (flags.Contains(Flags.HEAL) && reg.getHPS() > 0)
                    {
                        if ((now - lastHealUpdate).TotalSeconds >= reg.getHPS())
                        {
                            lastHealUpdate = now;
                            var    items = TShock.Utils.GetItemByIdOrName("heart");
                            Player ply   = player.TPlayer;
                            Utilities.GiveItem(items[0].name, (int)ply.position.X, (int)ply.position.Y, items[0].width,
                                               items[0].height, items[0].type, 1, items[0].prefix, player.Index, ply.velocity);
                        }
                    }
                    if (flags.Contains(Flags.TEMPGROUP))
                    {
                        if (player.Group != reg.getTempGroup())
                        {
                            player.Group = reg.getTempGroup();
                            tempGroup    = true;
                            player.SendInfoMessage("Your group has been changed to {0}.", player.Group);
                        }
                        inTempGroupZone = true;
                    }
                }
            }

            if (!inPVPZone && forcedPVP)
            {
                forcedPVP = false;
                player.TPlayer.hostile = false;
                player.SendData(PacketTypes.TogglePvp);
                NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                player.SendMessage("PVP arena left, pvp disabled.", Color.Green);
            }

            if (!inNoPVPZone && removedPVP)
            {
                removedPVP             = false;
                player.TPlayer.hostile = false;
                player.SendData(PacketTypes.TogglePvp);
                NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                player.SendMessage("PVP free area left, pvp disabled.", Color.Green);
            }

            if (!inTempGroupZone && tempGroup)
            {
                if (player.Group != OriginalGroup)
                {
                    player.Group = OriginalGroup;
                    player.SendInfoMessage("Your group has been changed back to {0}.", player.Group);
                }
                tempGroup = false;
            }

            if ((now - lastUpdate).TotalSeconds > 1)
            {
                positions.enqueue(player.TPlayer.position);
                lastUpdate = now;
            }
        }
예제 #19
0
        private void SetFlags(CommandArgs args)
        {
            if (args.Parameters.Count == 1 && args.Parameters[0] == "flags")
            {
                string flags = string.Join(", ", Enum.GetNames(typeof(Flags)));
                args.Player.SendInfoMessage("Available flags: {0}", flags);
                return;
            }
            if (args.Parameters.Count < 3)
            {
                args.Player.SendMessage("Invalid usage: /rflags(/rf) set|rem [region name] [flag]", Color.Red);
                return;
            }

            string        regionname = args.Parameters[1];
            string        flag       = args.Parameters[2];
            FlaggedRegion reg        = regions.getRegion(regionname);

            if (reg == null)
            {
                args.Player.SendMessage("Invalid region", Color.Red);
                return;
            }
            switch (args.Parameters[0])
            {
            case "set":
            case "add":
            {
                Flags enumval;
                if (Flags.TryParse(flag.ToUpper(), out enumval))
                {
                    reg.setFlags(enumval);
                    if (!regions.UpdateRegion(regionname))
                    {
                        args.Player.SendMessage("Region doesn't exist.", Color.Red);
                    }
                    args.Player.SendMessage("Region now has flag.", Color.Green);
                }
                else
                {
                    args.Player.SendMessage("Invalid flag", Color.Red);
                }
                break;
            }

            case "rem":
            case "remove":
            {
                Flags enumval;
                if (Flags.TryParse(flag.ToUpper(), out enumval))
                {
                    reg.removeFlags(enumval);
                    if (!regions.UpdateRegion(regionname))
                    {
                        args.Player.SendMessage("Region doesn't exist.", Color.Red);
                    }
                    args.Player.SendMessage("Flag has been removed from region.", Color.Green);
                }
                else
                {
                    args.Player.SendMessage("Invalid flag", Color.Red);
                }
                break;
            }
            }
        }
예제 #20
0
        public void Update()
        {
            e = new SendDataEventArgs();
            DateTime now = DateTime.Now;

            Region r = TShock.Regions.GetTopRegion(TShock.Regions.InAreaRegion(player.TileX, player.TileY));

            bool inPVPZone   = false;
            bool inNoPVPZone = false;

            bool warning = ((now - lastWarned).TotalSeconds >= 5);

            if (r != null)
            {
                FlaggedRegion reg = regionManager.getRegion(r.Name);
                if (reg != null)
                {
                    List <Flags> flags = reg.getFlags();
                    if (flags.Contains(Flags.PRIVATE) && !player.Group.HasPermission("enter." + r.Name + "")) // && !r.HasPermissionToBuildInRegion(player))
                    {
                        Vector2 pos = positions.getpos();
                        player.Teleport((int)pos.X, (int)pos.Y);
                        if (warning)
                        {
                            player.SendMessage(String.Format("[SYSTEM] You can't enter '{0}' at your level!", r.Name), Color.OrangeRed);
                            lastWarned = now;
                        }
                    }
                    List <string> bannedItems = new List <string>();
                    if (flags.Contains(Flags.ITEMBAN) && InvalidInventory(reg.getBannedItems(), out bannedItems) && !player.Group.HasPermission("rf.ibpass"))
                    {
                        Vector2 pos  = positions.getpos();
                        Vector2 diff = pos - player.TPlayer.position;

                        if (((diff.X * diff.X) + (diff.Y * diff.Y)) > (100 * 100))
                        {
                            player.Teleport((int)pos.X, (int)pos.Y);
                        }

                        else
                        {
                            player.Spawn(Main.spawnTileX, Main.spawnTileY);
                        }

                        if (warning)
                        {
                            player.SendMessage(String.Format("The following are banned in that area: {0}", string.Join(",", bannedItems)), Color.Red);
                            lastWarned = now;
                        }
                    }
                    if (flags.Contains(Flags.DEATH) && !r.HasPermissionToBuildInRegion(player))
                    {
                        NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, " died Indiana Jone's style.", player.Index, 0, 999999,
                                            (float)0);
                        if (warning)
                        {
                            player.SendMessage("You just stumbled into a death trap... no pun intended.", Color.Yellow);
                            lastWarned = now;
                        }
                    }
                    if (flags.Contains(Flags.PVP))
                    {
                        if (!player.TPlayer.hostile)
                        {
                            player.SendMessage("[ARENA] PvP Enabled.", Color.Red);
                        }
                        if (e.MsgId == PacketTypes.ChatText && !e.Handled)
                        {
                            if (e.number2 == 255 && e.number3 == 255 && e.number4 == 255)
                            {
                                if (e.text.Contains("has enabled PvP!") || e.text.Contains("has disabled PvP!"))
                                {
                                    e.Handled = true;
                                }
                            }
                        }
                        player.TPlayer.hostile = true;
                        player.SendData(PacketTypes.TogglePvp);
                        NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                        inPVPZone = true;
                        forcedPVP = true;
                    }
                    if (flags.Contains(Flags.NOPVP))
                    {
                        if (player.TPlayer.hostile)
                        {
                            player.SendMessage("[SAFE] PvP Disabled.", Color.Red);
                        }
                        if (e.MsgId == PacketTypes.ChatText && !e.Handled)
                        {
                            if (e.number2 == 255 && e.number3 == 255 && e.number4 == 255)
                            {
                                if (e.text.Contains("has enabled PvP!") || e.text.Contains("has disabled PvP!"))
                                {
                                    e.Handled = true;
                                }
                            }
                        }
                        player.TPlayer.hostile = false;
                        player.SendData(PacketTypes.TogglePvp);
                        NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                        inNoPVPZone = true;
                        removedPVP  = true;
                    }
                    if (flags.Contains(Flags.HURT))
                    {
                        if ((now - lastDamageUpdate).TotalSeconds > 0)
                        {
                            lastDamageUpdate = now;
                            if (reg.getDPS() > 0)
                            {
                                int damage = (player.TPlayer.statDefense / 2) + reg.getDPS();
                                NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, " died a slow, horrible death.", player.Index, 0, damage,
                                                    (float)0);
                            }
                        }
                    }
                    if (flags.Contains(Flags.HEAL) && reg.getHPS() > 0)
                    {
                        if ((now - lastHealUpdate).TotalSeconds >= reg.getHPS())
                        {
                            lastHealUpdate = now;
                            var    items = TShock.Utils.GetItemByIdOrName("heart");
                            Player ply   = player.TPlayer;
                            Utils.GiveItem(items[0].name, (int)ply.position.X, (int)ply.position.Y, items[0].width,
                                           items[0].height, items[0].type, 1, items[0].prefix, player.Index, ply.velocity);
                        }
                    }
                }
            }

            if (!inPVPZone && forcedPVP)
            {
                forcedPVP = false;
                player.TPlayer.hostile = false;
                player.SendData(PacketTypes.TogglePvp);
                NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                player.SendMessage("[FREE] PvP can be toggled.", Color.MediumSeaGreen);
            }

            if (!inNoPVPZone && removedPVP)
            {
                removedPVP             = false;
                player.TPlayer.hostile = false;
                player.SendData(PacketTypes.TogglePvp);
                NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
                player.SendMessage("[FREE] PvP can be toggled.", Color.MediumSeaGreen);
            }

            if ((now - lastUpdate).TotalSeconds > 1)
            {
                positions.enqueue(player.TPlayer.position);
                lastUpdate = now;
            }
        }