当前位置: 首页>>代码示例>>C#>>正文


C# HookContext.SetResult方法代码示例

本文整理汇总了C#中Terraria_Server.Plugins.HookContext.SetResult方法的典型用法代码示例。如果您正苦于以下问题:C# HookContext.SetResult方法的具体用法?C# HookContext.SetResult怎么用?C# HookContext.SetResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Terraria_Server.Plugins.HookContext的用法示例。


在下文中一共展示了HookContext.SetResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnUnkownPacketSend

        public static void OnUnkownPacketSend(ref HookContext ctx, ref HookArgs.UnkownSendPacket args)
        {
            switch (args.PacketId)
            {
                case (int)Packets.CLIENT_MOD_GOD:
                    {
                        NetMessageExtension msg = new NetMessageExtension();

                        if (args.RemoteClient != -1)
                        {
                            var player = Main.players[args.RemoteClient];

                            if (player.HasClientMod)
                            {
                                if (Server.AllowTDCMRPG)
                                {
                                    Server.notifyOps(
                                        String.Format("Failed attempt to {0} God Mode on an RPG Server.", true, (args.Number == 1) ? "give" : "remove"));
                                    return;
                                }

                                Server.notifyOps(
                                    String.Format("{0} {1} God Mode.", true, player.Name, (args.Number == 1) ? "has" : "doesn't have"));

                                msg.GodTDCMClient(args.Number == 1);
                                args.Message = msg;
                                ctx.SetResult(HookResult.IGNORE); //Let TDSM know it's to ignore returning.
                            }
                        }
                        break;
                    }

            }
        }
开发者ID:TimeBomb,项目名称:Essentials-TDSM,代码行数:34,代码来源:Net.cs

示例2: OnProjectile

        void OnProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args)
        {
            if (configBlockExplosives == false || args.Type==ProjectileType.ORB_OF_LIGHT || args.Type==ProjectileType.FLAMELASH )
            {
                return;
            }
            else
            {
                Player player = ctx.Sender as Player;
                if (player == null) return;

                PlayerState state = null;
                if (!player.PluginData.Contains(this))
                {
                    state = new PlayerState();
                    player.PluginData[this] = state;
                    states.Add(state);
                }
                else
                {
                    state = (PlayerState)player.PluginData[this];
                }

                ProjectileType type = args.Type;

                if (!(type == ProjectileType.ORB_OF_LIGHT || type == ProjectileType.FLAMELASH || type == ProjectileType.MISSILE_MAGIC))
                {
                    state.projectiles += 1;
                }

                if (state.projectiles >= 9)
                {
                    ctx.SetResult(HookResult.IGNORE);
                    state.projectiles -= 9;
                    ProgramLog.Admin.Log("[" + base.Name + "]: Stopped projectile {0} spam from {1}.", type, player.Name ?? "<null>");
                    return;
                }

                if (player != null && (type == ProjectileType.DYNAMITE || type == ProjectileType.GRENADE || type == ProjectileType.BOMB || type == ProjectileType.BOMB_STICKY || type == ProjectileType.ARROW_HELLFIRE))
                {
                    ctx.SetResult(HookResult.IGNORE);
                    player.sendMessage("You are not allowed to use explosives on this server.", 255, 255, 0, 0);
                    ProgramLog.Admin.Log("[" + base.Name + "]: Cancelled Projectile Use of Player: " + ((Player)ctx.Sender).Name);
                }
            }
        }
开发者ID:elevatorguy,项目名称:rakAntiGrief,代码行数:46,代码来源:rakAntiGrief.cs

示例3: OnChestOpen

 void OnChestOpen(ref HookContext ctx, ref HookArgs.ChestOpenReceived args)
 {
     Player player = Server.GetPlayerByName(ctx.Sender.Name);
     if (IsInsideAnotherHouse(player.Name, (int)Main.chest[args.ChestIndex].x, (int)Main.chest[args.ChestIndex].y, CHECK_CHEST_LOCK) &&
         !player.Op)
     {
         ctx.SetResult(HookResult.IGNORE);
         player.sendMessage("You cannot open this chest, it's locked and inside someone else's house", chatColor);
     }
     //base.onPlayerOpenChest(Event);
 }
开发者ID:elevatorguy,项目名称:House,代码行数:11,代码来源:House.cs

示例4: OnProjectileReceived

        void OnProjectileReceived(ref HookContext ctx, ref HookArgs.ProjectileReceived args)
        {
            Vector2 Position = new Vector2(args.X, args.Y);

                foreach (Region rgn in regionManager.Regions)
                {
                    if (rgn.HasPoint(Position / 16))
                    {
                        if (rgn.ProjectileList.Contains("*") ||
                            rgn.ProjectileList.Contains(args.Type.ToString()))// ||
                            //rgn.ProjectileList.Contains(args.Projectile.Name.ToLower().Replace(" ", "")))
                        {
                            if (IsRestrictedForUser(ctx.Player, rgn, ProjectileUse))
                            {
                                ctx.SetResult(HookResult.ERASE);
                                ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red);
                                return;
                            }
                        }
                    }
                }
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:22,代码来源:Regions.cs

示例5: OnLiquidFlowReceived

        void OnLiquidFlowReceived(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args)
        {
            Vector2 Position = new Vector2(args.X, args.Y);

                foreach (Region rgn in regionManager.Regions)
                {
                    if (rgn.HasPoint(Position))
                    {
                        if (IsRestrictedForUser(ctx.Player, rgn, LiquidFlow))
                        {
                            ctx.SetResult(HookResult.ERASE);
                            ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red);
                            return;
                        }
                    }
                }
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:17,代码来源:Regions.cs

示例6: OnChestOpen

 void OnChestOpen(ref HookContext ctx, ref HookArgs.ChestOpenReceived args)
 {
     foreach (Region rgn in regionManager.Regions)
         {
             if (rgn.HasPoint(new Vector2(args.X, args.Y)))
             {
                 if (ctx.Sender is Player)
                 {
                     if (IsRestrictedForUser(ctx.Player, rgn, DoorChange))
                     {
                         ctx.SetResult(HookResult.RECTIFY);
                         ctx.Player.sendMessage("You cannot edit this object!", ChatColor.Red);
                         return;
                     }
                 }
             }
         }
 }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:18,代码来源:Regions.cs

示例7: OnPlayerJoined

        public static void OnPlayerJoined(int plr)
        {
            var player = Main.players[plr];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.PlayerEnteringGame
            {
                Slot = plr,
            };

            HookPoints.PlayerEnteringGame.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
            {
                return;
            }

            var msg = NetMessage.PrepareThreadInstance ();

            var motd = Program.properties.Greeting.Split('@');
            for (int i = 0; i < motd.Length; i++)
            {
                if (motd[i] != null && motd[i].Trim().Length > 0)
                {
                    msg.PlayerChat (255, motd[i], 0, 0, 255);
                }
            }

            string list = "";
            for (int i = 0; i < 255; i++)
            {
                if (Main.players[i].Active)
                {
                    if (list == "")
                        list += Main.players[i].Name;
                    else
                        list = list + ", " + Main.players[i].Name;
                }
            }

            msg.PlayerChat (255, "Current players: " + list + ".", 255, 240, 20);
            msg.Send (plr); // send these before the login event, so messages from plugins come after

            var slot = NetPlay.slots[plr];

            slot.announced = true;

            // to player
            msg.Clear();
            msg.SendSyncOthersForPlayer (plr);

            ProgramLog.Users.Log ("{0} @ {1}: ENTER {2}", slot.remoteAddress, plr, player.Name);

            if (player.HasHackedData())
            {
                player.Kick("No Hacked Health or Mana is allowed.");
            }

            // to other players
            msg.Clear();
            msg.PlayerChat (255, player.Name + " has joined.", 255, 240, 20);
            msg.ReceivingPlayerJoined (plr);
            msg.SendSyncPlayerForOthers (plr); // broadcasts the preceding message too

            var args2 = new HookArgs.PlayerEnteredGame
            {
                Slot = plr,
            };

            ctx.SetResult (HookResult.DEFAULT);
            HookPoints.PlayerEnteredGame.Invoke (ref ctx, ref args2);

            if (ctx.CheckForKick ())
            {
                return;
            }
        }
开发者ID:Skiles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:83,代码来源:NetMessage.cs

示例8: OnAlter

 void OnAlter(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args)
 {
     var player = ctx.Player;
     if (player == null || player.Name == null) {
         ProgramLog.Log ("<Mysql> Invalid player in onPlayerTileChange.");
         ctx.SetResult (HookResult.IGNORE);
         return;
     }
     if (s.isEnabled(ctx.Sender.Name) && ctx.Sender.Op) {
         var msg = getBlockHistory(args.X, args.Y, ctx.Sender);
         ProgramLog.Admin.Log ("<mysql> "+ctx.Sender.Name+" got tile history ("+args.X+", "+args.Y+")");
         ctx.SetResult (HookResult.IGNORE);
         return;
     }
     if (!logtiles || !mysqlenabled)
         return;
     if (!args.RemovalFailed)//fixes multiple log entries for the same tile
     {
         logTile(player.Name, (int)args.X, (int)args.Y, args.Action, args.Type, Main.tile.At(args.X, args.Y));
         //ProgramLog.Admin.Log(player.Name + " " + (int)args.X + " " + (int)args.Y + " " + args.Action + " " + args.Type + " " + Main.tile.At(args.X, args.Y).Type + " " + Main.tile.At(args.X, args.Y).Wall);
     }
     // args.Style is ignored for now
 }
开发者ID:elevatorguy,项目名称:TDSM_mysql,代码行数:23,代码来源:MysqlPlugin.cs

示例9: onPlayerChat

        void onPlayerChat(ref HookContext ctx, ref HookArgs.PlayerChat args)
        {
            Player player = ctx.Sender as Player;
            string playername = player.Name;

            if (mutelist.checklist(playername))
            {
                DateTime timemuted = mutelist.getTimeMuted(playername);
                TimeSpan timeleft = timemuted.AddMinutes(5) - DateTime.UtcNow;

                if (timemuted > DateTime.UtcNow.AddHours(1))
                {
                    player.sendMessage("You are muted for a long time.");
                }
                else
                {
                    player.sendMessage("You have " + timeleft.Minutes + ":" + timeleft.Seconds + " before you can chat again.");
                }

                ctx.SetResult(HookResult.IGNORE);
            }

            return;
        }
开发者ID:elevatorguy,项目名称:TDSM_Mute,代码行数:24,代码来源:MutePlugin.cs

示例10: OnReceiveProjectile

 void OnReceiveProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args)
 {
     if (!explosivesAllowed && args.Type.IsExplosive())
     {
         Log("Cancelled Explosive usage of Player: " + ctx.Player.Name);
         ctx.SetResult(HookResult.ERASE);
     }
 }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:8,代码来源:TDSM_Plugin.cs

示例11: OnPlayerWorldAlteration

 void OnPlayerWorldAlteration(ref HookContext ctx, ref HookArgs.PlayerWorldAlteration args)
 {
     if (!tileBreakageAllowed) return;
     Log("Cancelled Tile change of Player: " + ctx.Player.Name);
     ctx.SetResult(HookResult.RECTIFY);
 }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:6,代码来源:TDSM_Plugin.cs

示例12: OnReceiveProjectile

 void OnReceiveProjectile(ref HookContext ctx, ref HookArgs.ProjectileReceived args)
 {
     if (!explosivesAllowed)
     {
         int type = (int)args.Type;
         if (type == (int)ProjectileType.BOMB /* 28 */ ||
             type == (int)ProjectileType.DYNAMITE /* 29 */ ||
             type == (int)ProjectileType.BOMB_STICKY /* 37 */)
         {
             Log("Cancelled Explosive usage of Player: " + ctx.Player.Name);
             ctx.SetResult(HookResult.ERASE);
         }
     }
 }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:14,代码来源:TDSM_Plugin.cs

示例13: OnSignTextSet

 void OnSignTextSet(ref HookContext ctx, ref HookArgs.SignTextSet args)
 {
     Player player = Server.GetPlayerByName(ctx.Sender.Name);
     if (IsInsideAnotherHouse(player.Name, (int)args.X, (int)args.Y, CHECK_SIGN_LOCK) &&
         !player.Op)
     {
         ctx.SetResult(HookResult.RECTIFY);
         player.sendMessage("You cannot edit this sign, it's locked and inside someone else's house", chatColor);
     }
     //base.onPlayerEditSign(Event);
 }
开发者ID:elevatorguy,项目名称:House,代码行数:11,代码来源:House.cs

示例14: OnLiquidFlow

        void OnLiquidFlow(ref HookContext ctx, ref HookArgs.LiquidFlowReceived args)
        {
            Player player = Server.GetPlayerByName(ctx.Sender.Name);
            if (IsInsideAnotherHouse(player.Name, (int)args.X, (int)args.Y))
            {
                ctx.SetResult(HookResult.IGNORE);
                player.sendMessage("You cannot use liquid inside someone else's house", chatColor);
            }

            //base.onPlayerFlowLiquid(Event);
        }
开发者ID:elevatorguy,项目名称:House,代码行数:11,代码来源:House.cs

示例15: OnSignTextSet

        void OnSignTextSet(ref HookContext ctx, ref HookArgs.SignTextSet args)
        {
            if (configExtendedReachSign == false)
            {
                return;
            }
            else
            {
                Player player = ctx.Sender as Player;

                if (player == null || player.Op == true)
                {
                    return;
                }

                int x = (int)args.X;
                int y = (int)args.Y;

                if (inSpawn(x, y))
                {
                    ctx.SetResult(HookResult.IGNORE);
                    player.sendMessage("You are not allowed to edit spawn on this server.", 255, 255, 0, 0);
                    return;
                }
                else if (distance(player.Location.X, player.Location.Y, x, y) > configExtendedReachRange)
                {
                    ctx.SetResult(HookResult.IGNORE);
                    player.sendMessage("You are too far away to edit that sign.", 255, 255, 0, 0);
                    ProgramLog.Admin.Log("[" + base.Name + "]: Cancelled Sign Edit of Player: " + player.Name);
                }
            }
        }
开发者ID:elevatorguy,项目名称:rakAntiGrief,代码行数:32,代码来源:rakAntiGrief.cs


注:本文中的Terraria_Server.Plugins.HookContext.SetResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。