Results 1 to 9 of 9
  1. #1
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113

    Unhappy 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

  2. #2
    krazyshank's Avatar
    Join Date
    Jan 2012
    Gender
    male
    Location
    RealmStock
    Posts
    2,589
    Reputation
    467
    Thanks
    16,673
    My Mood
    Angelic
    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;

    Accepting PayPal - Bitcoin - Giftcards - Items:

    Find it here: MPGH Sales Thread

  3. #3
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113
    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...

  4. #4
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113

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

  5. #5
    NisuxenZ's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    127
    Reputation
    21
    Thanks
    715
    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.

  6. The Following 3 Users Say Thank You to NisuxenZ For This Useful Post:

    Alde. (05-15-2015),krazyshank (05-14-2015),[MPGH]Solvi (05-15-2015)

  7. #6
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113
    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...

  8. #7
    krazyshank's Avatar
    Join Date
    Jan 2012
    Gender
    male
    Location
    RealmStock
    Posts
    2,589
    Reputation
    467
    Thanks
    16,673
    My Mood
    Angelic
    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.

    Accepting PayPal - Bitcoin - Giftcards - Items:

    Find it here: MPGH Sales Thread

  9. #8
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113
    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...

  10. #9
    pixelzerg's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    UK
    Posts
    188
    Reputation
    10
    Thanks
    1,113
    how on earth does one close a thread?

Similar Threads

  1. [Help Request] Realm Relay scripting help (newbie)
    By codelion in forum Realm of the Mad God Help & Requests
    Replies: 9
    Last Post: 04-30-2014, 12:21 PM
  2. Realm Relay Installation Help Please
    By ImJazz in forum Realm of the Mad God Help & Requests
    Replies: 2
    Last Post: 01-02-2014, 10:44 PM
  3. [Help Request] Skype API help
    By rabir007 in forum C# Programming
    Replies: 2
    Last Post: 03-22-2013, 09:58 AM
  4. [Help Request] Help with rabir Gamin tool [Skype API]
    By rabir007 in forum Crossfire Coding Help & Discussion
    Replies: 0
    Last Post: 03-19-2013, 12:41 PM
  5. [Help Request] Need Some Quick Help With IPB Board API
    By pilotberry in forum C++/C Programming
    Replies: 0
    Last Post: 06-28-2012, 10:52 PM