Пример #1
0
        public void sendClientScript2(int id2, int id, object[] parameters, string types)
        {
            if (parameters.Length != types.Length)
            {
                misc.WriteError("params size should be the same as types length");
                return;
            }
            PacketBuilder packet = new PacketBuilder().setId(115).setSize(Packet.Size.VariableShort)
                                   .addUShort(count++)
                                   .addString(types);
            int idx = 0;

            for (int i = types.Length - 1; i >= 0; i--)
            {
                if (types[i] == 's')
                {
                    packet.addString((string)parameters[idx]);
                }
                else
                {
                    packet.addInt((int)parameters[idx]);
                }
                idx++;
            }
            packet.addInt(id);
            connection.SendPacket(packet.toPacket());
        }
Пример #2
0
        public void sendItems(int interfaceId, int childId, int type, Item[] inventory)
        {
            PacketBuilder pb = new PacketBuilder().setId(105).setSize(Packet.Size.VariableShort);

            pb.addInt((interfaceId << 16) + childId);
            pb.addUShort(type);
            pb.addUShort(inventory.Length);
            for (int i = 0; i < inventory.Length; i++)
            {
                Item item = inventory[i];
                int  id = -1, amount = 0;
                if (inventory[i] != null)
                {
                    id     = item.getItemId();
                    amount = item.getItemAmount();
                }
                if (amount > 254)
                {
                    pb.addByteS(255);
                    pb.addInt(amount);
                }
                else
                {
                    pb.addByteS(amount);
                }
                pb.addUShort(id + 1);
            }
            connection.SendPacket(pb.toPacket());
        }