Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 17:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HELP] Problem with Trading lot of items

Discussion on [HELP] Problem with Trading lot of items within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
ZeRo-ToLeRaNcE's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 544
Received Thanks: 655
[HELP] Problem with Trading lot of items

Hello ppl,

i have an wierd problem.
when characters are trading for example 20 dragonballs, and when the trade
is done, the character that has recieved the dragonballs has only 16 dragonballs in his inventory, and the one who has send it has the other 4 in his inventory.

olso with some items such as +12 etc will be not good.

i have read the Trading release from arco, and try that but no result.
can someone help me please??

What i have discoverd is that when the traded items are tranfered to the other character i can Debug it and loof the Items are added to the Temp. storage. and when he is going to tranfer it then de I.ID is getting sometime a 0. insteed of the dragonball item UID. here is it going wrong:

Code:
foreach (uint Id in C.MyChar.TradeSide)
                                {
                                    Game.Item I = C.MyChar.FindInvItem(Id);
                                    Who.AddFullItem([COLOR="Red"]I.ID[/COLOR], I.Bless, I.Plus, I.Enchant, I.Soc1, I.Soc2, I.Color, I.Progress, I.TalismanProgress, I.Effect, I.FreeItem, I.CurDur, I.MaxDur, I.Suspicious, I.Locked);
                                    //   Who.AddItem(I);
                                    C.MyChar.RemoveItem(I.ID, 1, C.MyChar.MyClient);
                                }
                                foreach (uint Id in Who.TradeSide)
                                {
                                    Game.Item I = Who.FindInvItem(Id);
                                    C.MyChar.AddFullItem([COLOR="red"]I.ID[/COLOR], I.Bless, I.Plus, I.Enchant, I.Soc1, I.Soc2, I.Color, I.Progress, I.TalismanProgress, I.Effect, I.FreeItem, I.CurDur, I.MaxDur, I.Suspicious, I.Locked);
                                    //   C.MyChar.AddItem(I);
                                    Who.RemoveItem(I.ID, 1, Who.MyClient);
                                }
if i check the TRADESIDE from the Who or C then i see that all items are good. all the ID and UID are good.

i will give some code what i use now, olso the whole trade.cs.

Thanks,

ZeRo

Packet Code from Packets.cs:

Code:
public static COPacket TradeItem(Game.Item I)
        {
            byte[] Packet = new byte[8 + 48];
            COPacket P = new COPacket(Packet);
            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)0x3f0);
            P.WriteInt32(I.UID);
            P.WriteInt32(I.ID);
            P.WriteInt16(I.CurDur);
            P.WriteInt16(I.MaxDur);
            P.WriteInt16(2);
            P.WriteInt16(0);
            P.WriteInt32(I.TalismanProgress);
            P.Move(0);
            P.WriteByte((byte)I.Soc1);
            P.WriteByte((byte)I.Soc2);
            P.WriteInt16((ushort)I.Effect);
            P.WriteByte(I.Plus);
            P.WriteByte(I.Bless);
            if (I.FreeItem)
                P.WriteByte(1);
            else
                P.WriteByte(0);
            P.WriteByte(I.Enchant);
            P.Move(6);
            if (I.Locked == 1)
                P.WriteInt16(3);
            else P.WriteInt16(0);
            P.WriteInt32((uint)I.Color);
            P.WriteInt32(I.Progress);

            return P;
        }
Complete trade.cs code:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NewestCOServer.Game;

namespace NewestCOServer.PacketHandling
{
    public class Trade
    {
        static void CancelTrade(Main.GameClient C)
        {
            if (C.MyChar.Trading)
            {
                Character Who = (Character)World.H_Chars[C.MyChar.TradingWith];
                if (Who != null)
                {
                    Who.MyClient.AddSend(Packets.TradePacket(C.MyChar.TradingWith, 5));
                    Who.Trading = false;
                    Who.TradingWith = 0;
                    Who.TradeSide.Clear();
                    Who.TradingCPs = 0;
                    Who.TradingSilvers = 0;
                    Who.ClickedOK = false;
                    Who.Silvers = Who.Silvers;//update the silvers
                    Who.CPs = Who.CPs;//update the cps
                    Who.MyClient.AddSend(Packets.ChatMessage(Who.MyClient.MessageID, "SYSTEM", Who.Name, "Trading failed!", 2005, 0));
                }
                C.AddSend(Packets.TradePacket(C.MyChar.TradingWith, 5));
                C.MyChar.Trading = false;
                C.MyChar.TradingWith = 0;
                C.MyChar.TradeSide = new System.Collections.ArrayList(20);
                C.MyChar.TradingCPs = 0;
                C.MyChar.TradingSilvers = 0;
                C.MyChar.ClickedOK = false;
                C.MyChar.CPs = C.MyChar.CPs;//update the cps
                C.MyChar.Silvers = C.MyChar.Silvers;//update the silvers
                C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "Trading failed!", 2005, 0));
            }
        }
        public static void Handle(Main.GameClient C, byte[] Data)
        {
            uint UID = BitConverter.ToUInt32(Data, 4);
            byte Type = Data[8];

            switch (Type)
            {
                case 1:
                    {
                        Character Who = (Character)World.H_Chars[UID];
                        if (Who != null && !Who.Trading)
                        {
                            if (!C.MyChar.Trading)
                            {
                                if (Who.EntityID != C.MyChar.TradingWith)
                                {
                                    C.MyChar.TradingWith = UID;
                                    if (Who.EntityID == C.MyChar.TradingWith && Who.TradingWith == C.MyChar.EntityID)
                                    {
                                        Who.MyClient.AddSend(Packets.TradePacket(C.MyChar.EntityID, 3));
                                        C.AddSend(Packets.TradePacket(Who.EntityID, 3));
                                        C.MyChar.Trading = true;
                                        Who.Trading = true;
                                        break;
                                    }
                                    else
                                    {
                                        C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]Request for trading has been sent out.", 2005, 0));
                                        Who.MyClient.AddSend(Packets.TradePacket(C.MyChar.EntityID, 1));
                                    }
                                }
                                if (Who.EntityID == C.MyChar.TradingWith && Who.TradingWith == C.MyChar.EntityID)
                                {
                                    Who.MyClient.AddSend(Packets.TradePacket(C.MyChar.EntityID, 3));
                                    C.AddSend(Packets.TradePacket(Who.EntityID, 3));
                                    C.MyChar.Trading = true;
                                    Who.Trading = true;
                                }
                            }
                            else
                                C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]Close the current trade before you take another one.", 2005, 0));
                        }
                        else
                            C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]The target is trading with someone else.", 2005, 0));

                        break;
                    }
                case 2:
                    {
                        CancelTrade(C);
                        break;
                    }
                case 6:
                    {
                        Character Who = (Character)World.H_Chars[C.MyChar.TradingWith];
                        if (Who != null)
                        {
                            if (C.MyChar.TradeSide.Count < 20)
                            {
                                if (Who.Inventory.Count + C.MyChar.TradeSide.Count < 40)
                                {
                                    Game.Item I = C.MyChar.FindInvItem(UID);
                                    if (!I.FreeItem)
                                    {
                                        Who.MyClient.AddSend(Packets.TradeItem(I));
                                        C.MyChar.TradeSide.Add(I.UID);
                                    }
                                    else
                                    {
                                        C.AddSend(Packets.TradePacket(UID, 11));
                                        C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]Cannot trade items made with gm commands.", 2005, 0));
                                    }
                                }
                                else
                                {
                                    C.AddSend(Packets.TradePacket(UID, 11));
                                    C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]Your trade partner can't hold any more items.", 2005, 0));
                                    Who.MyClient.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "[Trade]The one your trading with cant add anymore items on the table because you have no room in your inventory.", 2005, 0));
                                }
                            }

                        }
                        break;
                    }
                case 7:
                    {
                        C.MyChar.TradingSilvers = UID;
                        Character Who = (Character)World.H_Chars[C.MyChar.TradingWith];
                        Who.MyClient.AddSend(Packets.TradePacket(UID, 8));

                        break;
                    }
                case 13:
                    {
                        C.MyChar.TradingCPs = UID;
                        Character Who = (Character)World.H_Chars[C.MyChar.TradingWith];
                        Who.MyClient.AddSend(Packets.TradePacket(UID, 12));

                        break;
                    }
                case 10:
                    {
                        Character Who = (Character)World.H_Chars[C.MyChar.TradingWith];

                        if (Who != null && Who.ClickedOK)
                        {
                            if (C.MyChar.Silvers >= C.MyChar.TradingSilvers && C.MyChar.CPs >= C.MyChar.TradingCPs && Who.Silvers >= Who.TradingSilvers && Who.CPs >= Who.TradingCPs)
                            {
                                Who.MyClient.AddSend(Packets.TradePacket(C.MyChar.TradingWith, 5));
                                C.AddSend(Packets.TradePacket(C.MyChar.EntityID, 5));

                                Who.Silvers += C.MyChar.TradingSilvers;
                                Who.Silvers -= Who.TradingSilvers;
                                C.MyChar.Silvers += Who.TradingSilvers;
                                C.MyChar.Silvers -= C.MyChar.TradingSilvers;

                                Who.CPs += C.MyChar.TradingCPs;
                                Who.CPs -= Who.TradingCPs;
                                C.MyChar.CPs += Who.TradingCPs;
                                C.MyChar.CPs -= C.MyChar.TradingCPs;


                                foreach (uint Id in C.MyChar.TradeSide)
                                {
                                    Game.Item I = C.MyChar.FindInvItem(Id);
                                    Who.AddFullItem(I.ID, I.Bless, I.Plus, I.Enchant, I.Soc1, I.Soc2, I.Color, I.Progress, I.TalismanProgress, I.Effect, I.FreeItem, I.CurDur, I.MaxDur,I.Suspicious,I.Locked);
                                 //   Who.AddItem(I);
                                    C.MyChar.RemoveItem(I.ID,1,C);
                                }
                                foreach (uint Id in Who.TradeSide)
                                {
                                    Game.Item I = Who.FindInvItem(Id);
                                    C.MyChar.AddFullItem(I.ID, I.Bless, I.Plus, I.Enchant, I.Soc1, I.Soc2, I.Color, I.Progress, I.TalismanProgress, I.Effect, I.FreeItem, I.CurDur, I.MaxDur,I.Suspicious,I.Locked);
                                 //   C.MyChar.AddItem(I);
                                    Who.RemoveItem(I.ID,1,Who.MyClient);
                                }

                                Who.Trading = false;
                                Who.TradingWith = 0;
                                Who.TradeSide = new System.Collections.ArrayList(20);
                                Who.TradingCPs = 0;
                                Who.TradingSilvers = 0;
                                Who.ClickedOK = false;
                                Who.MyClient.AddSend(Packets.ChatMessage(Who.MyClient.MessageID, "SYSTEM", Who.Name, "Trading succeeded!", 2005, 0));
                                C.MyChar.Trading = false;
                                C.MyChar.TradingWith = 0;
                                C.MyChar.TradeSide = new System.Collections.ArrayList(20);
                                C.MyChar.TradingCPs = 0;
                                C.MyChar.TradingSilvers = 0;
                                C.MyChar.ClickedOK = false;
                                C.AddSend(Packets.ChatMessage(C.MessageID, "SYSTEM", C.MyChar.Name, "Trading succeeded!", 2005, 0));
                            }
                            else
                                CancelTrade(C);
                        }
                        else
                        {
                            C.MyChar.ClickedOK = true;
                            Who.MyClient.AddSend(Packets.TradePacket(0, 10));
                        }

                        break;
                    }
            }
        }
    }
}
ZeRo-ToLeRaNcE is offline  
Old 02/15/2011, 20:46   #2
 
ZeRo-ToLeRaNcE's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 544
Received Thanks: 655
There is nobody who can help me with this wierd problem??
ZeRo-ToLeRaNcE is offline  
Reply


Similar Threads Similar Threads
WTB ZSZC Fire Gold/Items [Trading for Water Items]
03/09/2011 - Silkroad Online Trading - 5 Replies
asdasd
Trading acc with items seven hearts for ruff items..!
05/14/2008 - General Gaming Discussion - 2 Replies
acc lvl 204 knight in seven hearts normal server not the high rate.. 3 O7 and 3R7 and all 200 items refine 8 and refines & black lisents... just add my msn and we will talk if u want .. [email protected]
Trading Co2 acc and super items for runescape items/gold and may take accs
02/03/2008 - Runescape Trading - 4 Replies
I am trading my lvl 15 water>tro for runescape items/money and may take acc 90+ Here are some items in co2 that i have but there are sold seperate: lvl 15 super club +4 2 soc w/2sdg and enchaned 108 lvl 40 super blade+4 2soc w/2sdg enchaned 98 lvl 70 super trojan armor 1 soc w/sdg enchaned 138 lvl 47 super earrings +2 1soc w/srg -5 damage lvl 30 elite boots +3 1 soc w/sdg enchaned 136
Trading maple items for diablo 2 items
06/01/2007 - MapleStory - 1 Replies
Trading my maple items any items i gt them all for diablo 2 enigma and the two other items which goes with it.



All times are GMT +2. The time now is 17:08.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.