public void Process(int start, int length, int num, int whoAmI, byte[] readBuffer, byte bufferData)
        {
            int x = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int chestIndex = Chest.FindChest(x, y);

            var chestEvent = new PlayerChestOpenEvent();
            chestEvent.Sender = Main.players[whoAmI];
            chestEvent.ID = chestIndex;
            Program.server.PluginManager.processHook(Hooks.PLAYER_CHEST, chestEvent);
            if (chestEvent.Cancelled)
            {
                return;
            }

            if (chestIndex > -1 && Chest.UsingChest(chestIndex) == -1)
            {
                for (int i = 0; i < Chest.MAX_ITEMS; i++)
                {
                    NetMessage.SendData(32, whoAmI, -1, "", chestIndex, (float)i);
                }
                NetMessage.SendData(33, whoAmI, -1, "", chestIndex);
                Main.players[whoAmI].chest = chestIndex;
                return;
            }
        }
Example #2
0
 public override void onPlayerOpenChest(PlayerChestOpenEvent Event)
 {
     TileRef tileRef = Server.tile.At((int)Server.chest[Event.ID].x, (int)Server.chest[Event.ID].y);
     Program.tConsole.WriteLine("Chest Type: " + tileRef.Data.Type.ToString());
     Event.Cancelled = CancelEvent(Event.Sender.Name);
     base.onPlayerOpenChest(Event);
 }
 public override void onPlayerOpenChest(PlayerChestOpenEvent Event)
 {
     int player = ((Player)Event.Sender).whoAmi;
     var region = IsPointInRegion(new Vector2(Main.chest[Event.ID].x, Main.chest[Event.ID].y));
     if (region != null && !IsPlayerRegionMember(player, region))
     {
         Event.Sender.sendMessage("This area is protected!");
         Event.Cancelled = true;
         return;
     }
 }
 /// <summary>
 /// Hook method for player opening a chest
 /// </summary>
 /// <param name="Event">PlayerChestOpenEvent info</param>
 public virtual void onPlayerOpenChest(PlayerChestOpenEvent Event)
 {
 }
Example #5
0
 public override void onPlayerOpenChest(PlayerChestOpenEvent Event)
 {
     Player player = Server.GetPlayerByName(Event.Sender.Name);
     if (IsInsideAnotherHouse(player.Name, (int)Server.chest[Event.ID].x, (int)Server.chest[Event.ID].y, CHECK_CHEST_LOCK) &&
         !player.Op)
     {
         Event.Cancelled = true;
         player.sendMessage("You cannot open this chest, it's locked and inside someone else's house", chatColor);
     }
     base.onPlayerOpenChest(Event);
 }