UnhappyHelpK Relay API Help

Posts 19 of 9 · Page 1 of 1
K Relay API Help
I'm new to coding in Microsoft Visual Studio (though I have done a ton of other coding languages - e.g Javascript, Java...)
This may be a bit of a noob question but I am new after all.

I am trying to write an auto trade bot using K Relay - yes, quite ambitious I suppose, but I have
coded auto trade bots for ROTMG in the past (which copyright law forbids me to upload here)

I usually hardly ever ask questions on forums like this one - instead I try and find a way around
it or search for something on google but I realized that this question is API-Specific...

I'm having trouble sending the "ChangeTrade" packet to select the item.
Which requires you to define the variables:
Offers => Boolean[]
Send => Boolean
Id => Byte

I noticed that there is a variable type in the K Relay - boolean[]
I'm not so sure how to assign a value to it or what assignable values there are.
I did not find much documentation on it and debugging didn't help either...

This is the output my debugging produced:

Offers = System.Boolean[]
send = True
ID = 45

I'm fairly confident I am defining the "send" and "Id" variables correctly.
But the offers variable is seriously confusing for me.

Here's some code which I made - it's supposed to change your offer to a mana potion:
Code:
     ChangeTradePacket pkt = (ChangeTradePacket)Packet.Create(PacketType.CHANGETRADE);
            pkt.Id = 95;
            pkt.Send = true;
            Boolean[] moo = ??!!;
            pkt.Offers = moo;
            client.SendToServer(pkt);
If somebody could show me how it's done that'll be awesome. Thanks
Well, first I'll just mention that you don't have to manually specify the ID and Send variables of the packet because Packet.Create() does that for you.

Anyway, Boolean[] is an array of "bool"s. It's a standard data type, not specific to K Relay.
Aka true or false, and in this case, you'd want to make it a length of 8 because it represents whether or not any of your 8 inventory items are selected for the trade. Example:
Code:
tradePacket.Offers = new bool[8];
Offers[0] = true;
Offers[2] = false;
Offers[3] = false;
Offers[4] = false;
Offers[5] = false;
Offers[6] = false;
Offers[7] = false;
ah I see! I should have known it would be an array! Thanks for your help - you truly are an amazing coder.
I'm guessing therefore that the location[] value type is also an array...
Help with K Relay Code
Quote Originally Posted by krazyshank View Post
Example:
Code:
tradePacket.Offers = new bool[8];
Offers[0] = true;
Offers[2] = false;
Offers[3] = false;
Offers[4] = false;
Offers[5] = false;
Offers[6] = false;
Offers[7] = false;
Sorry to ask of your assistance again but I just can't figure out why this isn't working.
The compiler gives no errors in visual studio and the debugging all appears in the console fine
yet I cannot make the code select stuff in my inventory.

Code:
Console.WriteLine("trying to select slots");
            ChangeTradePacket pkt = (ChangeTradePacket)Packet.Create(PacketType.CHANGETRADE);
            pkt.Offers = new bool[8];
            pkt.Offers[0] = true;
            pkt.Offers[1] = true;
            pkt.Offers[2] = true;
            pkt.Offers[3] = false;
            pkt.Offers[4] = false;
            pkt.Offers[5] = false;
            pkt.Offers[6] = false;
            pkt.Offers[7] = false;
            Console.WriteLine("Sending select packet");
            client.SendToServer(pkt);
            Console.WriteLine("done");
Here's the console output:

Code:
trying to select slots
Sending select packet
done
When the code is ran, it doesn't select the items. It also appears to not update any of the trade changes on the other side of the trade.
Quote Originally Posted by pixelzerg View Post
It also appears to not update any of the trade changes on the other side of the trade.
Change trade packets take boolean arrays of length 12. The first 4 slots are for equipment and the next 8 are inventory. You cannot trade equipment slots but for some reason the developers did that. Set the pkt.Offers[0 - 3] to false and [4 - 11] to true or whatever slots you want to be true.
I thought it would be something like that. I'm really busy so I couldn't test it out. I have 4 exams per day every day for 1 week.
Once that's over though - I'll have a long break and so I should be able to work much more on coding.
In the meantime I have to have to rely on the community.
What would I do without you guys

I'll try that out when I have time...
Quote Originally Posted by pixelzerg View Post
I thought it would be something like that. I'm really busy so I couldn't test it out. I have 4 exams per day every day for 1 week.
Once that's over though - I'll have a long break and so I should be able to work much more on coding.
In the meantime I have to have to rely on the community.
What would I do without you guys

I'll try that out when I have time...
Another thing I should mention is that yeah any type with [] at the end is indeed an array.

But the reason why it says Boolean[] and in my example I made it bool[] is that those primitives names are aliases for the actual types:
bool == Boolean
int == Integer
string == String
etc.
I'm sorry to say that making the array size to 12 and setting 0-3 to false did not work either :/
It did, however, prevent the problem that made the other side not update. We're at least making some progress!

By the way, how would one determine what they had in their inventory.
Coding this trade bot is much harder than I expected. My previous one was easier to say the least.

I think I might postpone this project until after my exams have finished. It will take more time than I thought at first.

- - - Updated - - -

yes, I know what boolean, etc are. Although I did a good job sounding like one with these embarrassing set of messages - I am not a complete noob in coding - i'm just new to coding with visual studio.

- - - Updated - - -

[QUOTE=pixelzerg;10505771]
By the way, how would one determine what they had in their inventory.
[QUOTE]

On second thought, don't answer that question - I'm pretty close to finding out by myself. Just a few more debuggings to be sure...
how on earth does one close a thread?
Posts 19 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?