Jump to content
Tuts 4 You
knight039

value was either too large or too small c#

Rate this topic

Recommended Posts

knight039

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?
 

Share this post


Link to post
Share on other sites
Kurapica

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.

 

Share this post


Link to post
Share on other sites

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...