void OnSignTextSet(ref HookContext ctx, ref HookArgs.SignTextSet args)
        {
            var player = ctx.Player;

            if (player == null || player.Name == null)
            {
                ProgramLog.Log("<Restrict> Invalid player in OnSignTextSet.");
                ctx.SetResult(HookResult.IGNORE);
                return;
            }

            if (!restrictGuests)
            {
                return;
            }

            if (player.AuthenticatedAs == null)
            {
                ctx.SetResult(HookResult.IGNORE);
                player.sendMessage("<Restrict> You are not allowed to edit signs as a guest.");
                player.sendMessage("<Restrict> Type \"/reg password\" to request registration.");
            }
            else if (IsRestrictedForUser(ctx.Player, SignEdit))
            {
                ctx.SetResult(HookResult.IGNORE);
                player.sendMessage("<Restrict> You are not allowed to edit signs without permissions.");
            }
        }
        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)  //TODO: redesign signs
        {
            int   start     = num - 1;
            short signIndex = BitConverter.ToInt16(readBuffer, num);

            num += 2;
            int x = BitConverter.ToInt32(readBuffer, num);

            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);

            num += 4;

            short existing = (short)Sign.ReadSign(x, y);

            if (existing >= 0)
            {
                signIndex = existing;
            }

            string SignText;

            if (!ParseString(readBuffer, num, length - num + start, out SignText))
            {
                return; // invalid characters
            }
            var player = Main.players[whoAmI];

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

            var args = new HookArgs.SignTextSet
            {
                X         = x, Y = y,
                SignIndex = signIndex,
                Text      = SignText,
                OldSign   = Main.sign[signIndex],
            };

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

            if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
            {
                return;
            }


            if (Main.sign[signIndex] == null)
            {
                Main.sign[signIndex] = new Sign();
            }
            Main.sign[signIndex].x = args.X;
            Main.sign[signIndex].y = args.Y;
            Sign.TextSign(signIndex, args.Text);
        }
Ejemplo n.º 3
0
 void OnSignEdit(ref HookContext ctx, ref HookArgs.SignTextSet 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.IGNORE);
                     ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red);
                     return;
                 }
             }
         }
     }
 }