Jump to content
Tuts 4 You

value was either too large or too small c#


knight039

Recommended Posts

I am having a problem with a code, with the following message
 

value was either too large or too small for an unsigned byte.

code is

    private static void ByteWrite(IntPtr address, byte[] bytes)
    {
      int lpNumberOfBytesWritten = 2;
      Player.WriteProcessMemory((int) Proc.Handle, address, bytes, bytes.Length, ref lpNumberOfBytesWritten);
    }

    public static void UsarItem(int Slot)
    {
      Player.ByteWrite(new IntPtr(7875792), new byte[32]
      {
        (byte) 36,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 115,
        (byte) 3,
        Player.ClientID[0],
        Player.ClientID[1],
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 1,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        Convert.ToByte(Slot),
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        (byte) 0,
        Player.IntToArrayByte(Player.Loc.X)[0],
        Player.IntToArrayByte(Player.Loc.X)[1],
        Player.IntToArrayByte(Player.Loc.Y)[0],
        Player.IntToArrayByte(Player.Loc.Y)[1]
      });
      Player.SendPacket((byte) 36);
      Thread.Sleep(100);

Could someone give me some help?
 

Link to comment

The error is easy to understand, if you try to cast an int to a byte you must make sure the int is within this range

0..255 , if the int is outside this range then an exception will be thrown.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...