Esempio n. 1
0
        private static void OnTogglePvp(object sender, GetDataHandlers.TogglePvpEventArgs args)
        {
            var ply = TShock.Players[args.PlayerId];
            var dt  = RtPlayer.GetPlayerInfo(ply);

            if (dt.ForcePvP == true && !args.Pvp ||
                dt.ForcePvP == false && args.Pvp ||
                !dt.CanTogglePvP)
            {
                ply.SendErrorMessage("You can't change your PvP status in this region!");
                ply.SendData(PacketTypes.TogglePvp, "", args.PlayerId);
                args.Handled = true;
            }
        }
Esempio n. 2
0
        private static void OnPlayerPermission(PlayerPermissionEventArgs args)
        {
            var rt = RtPlayer.GetPlayerInfo(args.Player).CurrentRegion;

            if (rt?.HasEvent(Event.TempPermission) != true)
            {
                return;
            }

            if (rt.HasPermission(args.Permission) && !args.Player.HasPermission("regiontrigger.bypass.tempperm"))
            {
                args.Handled = true;
            }
        }
Esempio n. 3
0
        private static void OnNewProjectile(object sender, GetDataHandlers.NewProjectileEventArgs args)
        {
            var ply = TShock.Players[args.Owner];
            var rt  = RtPlayer.GetPlayerInfo(ply).CurrentRegion;

            if (rt?.HasEvent(Event.Projban) != true)
            {
                return;
            }

            if (rt.ProjectileIsBanned(args.Type) && !ply.HasPermission("regiontrigger.bypass.projban"))
            {
                ply.Disable($"Create banned projectile in region {rt.Region.Name}.", DisableFlags.WriteToLogAndConsole);
                ply.SendErrorMessage("This projectile is banned here.");
                ply.RemoveProjectile(args.Index, args.Owner);
            }
        }
Esempio n. 4
0
        private void OnSecondUpdate()
        {
            foreach (var player in TShock.Players.Where(p => p?.Active == true))
            {
                var dt        = RtPlayer.GetPlayerInfo(player);
                var oldRegion = dt.CurrentRegion;
                dt.CurrentRegion = RtRegions.GetCurrentRegion(player);

                if (dt.CurrentRegion != oldRegion)
                {
                    if (oldRegion != null)
                    {
                        OnRegionLeft(player, oldRegion, dt);
                    }

                    if (dt.CurrentRegion != null)
                    {
                        OnRegionEntered(player, dt);
                    }
                }

                if (dt.CurrentRegion == null)
                {
                    continue;
                }

                if (dt.CurrentRegion.HasEvent(Event.Message) && !string.IsNullOrWhiteSpace(dt.CurrentRegion.Message) && dt.CurrentRegion.MsgInterval != 0)
                {
                    if (dt.MsgCd < dt.CurrentRegion.MsgInterval)
                    {
                        dt.MsgCd++;
                    }
                    else
                    {
                        player.SendInfoMessage(dt.CurrentRegion.Message);
                        dt.MsgCd = 0;
                    }
                }
            }
        }
Esempio n. 5
0
        private static void OnPlayerUpdate(object sender, GetDataHandlers.PlayerUpdateEventArgs args)
        {
            var ply = TShock.Players[args.PlayerId];
            var rt  = RtPlayer.GetPlayerInfo(ply).CurrentRegion;

            if (rt?.HasEvent(Event.Itemban) != true)
            {
                return;
            }

            /*BitsByte control = args.Control;
             * if (control[5])
             * {
             *      var itemName = ply.TPlayer.inventory[args.Item].Name;
             *      if (rt.ItemIsBanned(itemName) && !ply.HasPermission("regiontrigger.bypass.itemban"))
             *      {
             *              control[5] = false;
             *              args.Control = control;
             *              ply.Disable($"using a banned item ({itemName})", DisableFlags.WriteToLogAndConsole);
             *              ply.SendErrorMessage($"You can't use {itemName} here.");
             *      }
             * }*/

            ControlSet control = args.Control;

            if (control.bitsbyte[5])
            {
                string name = ply.TPlayer.inventory[(int)args.SelectedItem].Name;
                if (rt.ItemIsBanned(name) && !ply.HasPermission("regiontrigger.bypass.itemban"))
                {
                    control.bitsbyte[5] = false;
                    args.Control        = control;
                    ply.Disable("using a banned item (" + name + ")", DisableFlags.WriteToLogAndConsole);
                    ply.SendErrorMessage("You can't use " + name + " here.");
                }
            }
        }
Esempio n. 6
0
 private static void OnGreetPlayer(GreetPlayerEventArgs args)
 {
     RtPlayer.GetPlayerInfo(TShock.Players[args.Who]);
 }