Please Register and Login to our forum to access all features!
ROTMG free hack Hack ROTMG and Private Server ROTMG Private Server
Play ROTMG Tool Private Server Play ROTMG Hacked Client
View the Frequently Asked Questions Donate to ROTMG Tool Visit the Community Site
Realm of the Mad God Hacks, Cheats and Private Server - Come as Guests, Stay as Family!
Advertisement

Item Slot Glitch Fix - ROTMG Tool


Download the source files to run your very own Realm of the Mad God private server, or share modifications and other releases

Item Slot Glitch Fix

Postby Ahlwong » Wed 08 Oct, 2014 10:47 pm

So thanks to Nilly for posting this <3

Code: Select all
   private void DoTrade()
        {
            string failedMsg = "Error while trading. Trade unsuccessful.";
            string msg = "Trade Successful!";
            var thisItems = new List<Item>();
            var targetItems = new List<Item>();

            // make sure trade targets are valid
            if (tradeTarget == null || Owner == null || tradeTarget.Owner == null || Owner != tradeTarget.Owner)
            {
                if (this != null)
                    psr.SendPacket(new TradeDonePacket
                    {
                        Result = 1,
                        Message = failedMsg
                    });

                if (tradeTarget != null)
                    tradeTarget.psr.SendPacket(new TradeDonePacket
                    {
                        Result = 1,
                        Message = failedMsg
                    });

                //TODO - logThis
                return;
            }

            // get trade items
            for (int i = 4; i < Inventory.Length; i++)
            {
                if (trade[i] && !Inventory[i].Soulbound)
                {
                    thisItems.Add(Inventory[i]);
                    Inventory[i] = null;
                    UpdateCount++;

                    // save this trade info
                    if (itemnumber1 == 0)
                    {
                        items1 = items1 + " " + thisItems[itemnumber1].ObjectId;
                    }
                    else if (itemnumber1 > 0)
                    {
                        items1 = items1 + ", " + thisItems[itemnumber1].ObjectId;
                    }
                    itemnumber1++;
                }


                if (tradeTarget.trade[i] && !tradeTarget.Inventory[i].Soulbound)
                {
                    targetItems.Add(tradeTarget.Inventory[i]);
                    tradeTarget.Inventory[i] = null;
                    tradeTarget.UpdateCount++;

                    // save target trade info
                    if (itemnumber2 == 0)
                    {
                        items2 = items2 + " " + targetItems[itemnumber2].ObjectId;
                    }
                    else if (itemnumber2 > 0)
                    {
                        items2 = items2 + ", " + targetItems[itemnumber2].ObjectId;
                    }
                    itemnumber2++;
                }
            }

            // move thisItems -> tradeTarget
            for (int j = thisItems.Count - 1; j >= 0; j--)
                for (int i = 0; i < tradeTarget.Inventory.Length; i++)
                {
                    if ((tradeTarget.SlotTypes[i] == 0 &&
                            tradeTarget.Inventory[i] == null) ||
                        (thisItems[j] != null &&
                            tradeTarget.SlotTypes[i] == thisItems[j].SlotType &&
                            tradeTarget.Inventory[i] == null))
                    {
                        tradeTarget.Inventory[i] = thisItems[j];
                        thisItems.RemoveAt(j);
                        break;
                    }
                }

            // move tradeItems -> this
            for (int j = targetItems.Count - 1; j >= 0; j--)
                for (int i = 0; i < Inventory.Length; i++)
                {
                    if ((SlotTypes[i] == 0 &&
                            Inventory[i] == null) ||
                        (targetItems[j] != null &&
                            SlotTypes[i] == targetItems[j].SlotType &&
                            Inventory[i] == null))
                    {
                        Inventory[i] = targetItems[j];
                        targetItems.RemoveAt(j);
                        break;
                    }
                }

            // check for lingering items
            if (thisItems.Count > 0 ||
                targetItems.Count > 0)
            {
                msg = "An error occured while trading! Some items were lost!";
            }

            // trade successful, notify and save
            psr.SendPacket(new TradeDonePacket
            {
                Result = 1,
                Message = msg
            });
            tradeTarget.psr.SendPacket(new TradeDonePacket
            {
                Result = 1,
                Message = msg
            });
            SaveToCharacter();
            psr.Save();
            tradeTarget.SaveToCharacter();
            tradeTarget.psr.Save();

            // log trade
            const string dir = @"logs";
            if (!Directory.Exists(dir))
                Directory.CreateDirectory(dir);
            using (var writer = new StreamWriter(@"logs\TradeLog.log", true))
            {
                writer.WriteLine(Name + " traded " + "{" + items1 + "}" + " with " + tradeTarget.Name + " for " +
                                 "{" + items2 + "}");
            }
            Console.Out.WriteLine(Name + " traded " + "{" + items1 + "}" + " with " + tradeTarget.Name + " for " +
                                  "{" + items2 + "}");

            // clean up
            items1 = "";
            items2 = "";
            itemnumber1 = 0;
            itemnumber2 = 0;
            UpdateCount++;
            tradeTarget.UpdateCount++;
            name1 = "";
            name2 = "";
            tradeTarget.tradeTarget = null;
            tradeTarget.trade = null;
            tradeTarget.tradeAccepted = false;
            tradeTarget = null;
            trade = null;
            tradeAccepted = false;
        }


Apparently this is a really bad way of doing things as it cause much lag when lots of people try to pickup/move items

We could work on improving this soon but for now I guess it is worth it]

Thanks,

Ahlwong
ROTMG Tool Rank Achievements:
Developer from April 2014 - June 2016
Helper from April 2014 - June 2014
Moderator from June 2014 - August 2014
Global Moderator from August 2014 - October 2014
Supreme Moderator from October 2014 - March 2016
YouTube Team Director from August 2015 - October 2016
Ex-Staff since June 2016
My legend ends here. It's your time to build your legend!
User avatar
Ahlwong<i> Offline</i>
Ex-Staff
Ex-Staff
Posts: 1601
Joined: Feb '14
PS Name: Ahlwong
Location: Sydney
Thanks: 171
Member of the Quarter Nuclear Award Created Award Great Ideas Award YouTube Medal
Bug Zapper Award LMAO Award 20k Posts Day! [OLD] Member of the Month

Re: Item Slot Glitch Fix

Postby HeroTech » Sat 18 Oct, 2014 5:36 am

thanks nilly c:
HeroTech<i> Offline</i>
Learning the Ropes
Learning the Ropes
Posts: 43
Joined: Oct '14
PS Name: Herotech
Thanks: 1

Re: Item Slot Glitch Fix

Postby JTC19 » Sat 18 Oct, 2014 7:14 am

nilly is the best
'
JTC19<i> Offline</i>
Learning the Ropes
Learning the Ropes
Posts: 22
Joined: Aug '14
PS Name: JTC
Thanks: 0

Re: Item Slot Glitch Fix

Postby Ahlwong » Sat 18 Oct, 2014 11:15 pm

Apparently this was in Doomed Realms source 0.o
ROTMG Tool Rank Achievements:
Developer from April 2014 - June 2016
Helper from April 2014 - June 2014
Moderator from June 2014 - August 2014
Global Moderator from August 2014 - October 2014
Supreme Moderator from October 2014 - March 2016
YouTube Team Director from August 2015 - October 2016
Ex-Staff since June 2016
My legend ends here. It's your time to build your legend!
User avatar
Ahlwong<i> Offline</i>
Ex-Staff
Ex-Staff
Posts: 1601
Joined: Feb '14
PS Name: Ahlwong
Location: Sydney
Thanks: 171
Member of the Quarter Nuclear Award Created Award Great Ideas Award YouTube Medal
Bug Zapper Award LMAO Award 20k Posts Day! [OLD] Member of the Month

Re: Item Slot Glitch Fix

Postby SorenOwl » Sun 19 Oct, 2014 12:31 pm

Well then.........
Image
*note* I am Organized Chaos part of the Chaos-Coders hacking group I founded and I am also Chaos Graphics
I work for multiple servers atm
I am not up for hire
I am also working for lust gaming *dot*net


Please take your time to...
PM me if anyone hacks, dupes, etc,...
Pm if you just want to chat
Pm if you need any help!

Please Pm me if anyone hacks, dupes, spamming, or is being a nuisance to the /psplay.php, /pplay.php or Rotmgtool.com/bb environment. *WE NEED PROOF OF THIS*
User avatar
SorenOwl<i> Offline</i>
Ex-Staff
Ex-Staff
Posts: 3310
Joined: Feb '14
PS Name: SorenOwl
Location: My nest
Thanks: 51
Nuclear Award Created Award Great Ideas Award Bug Zapper Award LMAO Award
20k Posts Day! [OLD] Member of the Month

Postby DaemonMan » Thu 16 Apr, 2015 5:47 am

where i add this ?
DaemonMan<i> Offline</i>
Just Joined
Just Joined
Posts: 1
Joined: Apr '15
PS Name: TSfortre
Thanks: 0

Postby SorenOwl » Sun 26 Apr, 2015 12:14 pm

Please don't necro post
//closed
Image
*note* I am Organized Chaos part of the Chaos-Coders hacking group I founded and I am also Chaos Graphics
I work for multiple servers atm
I am not up for hire
I am also working for lust gaming *dot*net


Please take your time to...
PM me if anyone hacks, dupes, etc,...
Pm if you just want to chat
Pm if you need any help!

Please Pm me if anyone hacks, dupes, spamming, or is being a nuisance to the /psplay.php, /pplay.php or Rotmgtool.com/bb environment. *WE NEED PROOF OF THIS*
User avatar
SorenOwl<i> Offline</i>
Ex-Staff
Ex-Staff
Posts: 3310
Joined: Feb '14
PS Name: SorenOwl
Location: My nest
Thanks: 51
Nuclear Award Created Award Great Ideas Award Bug Zapper Award LMAO Award
20k Posts Day! [OLD] Member of the Month