Register for your free account! | Forgot your password?

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

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

Advertisement



About Item amount (StackSize)

Discussion on About Item amount (StackSize) within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2009
Posts: 33
Received Thanks: 2
About Item amount (StackSize)

Hello guys i have a questions in this code.

Code:
uint Amount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                    ConquerItem item = new ConquerItem(true);
                    switch (shop.MoneyType)
                    {
                        case Database.ShopFile.MoneyType.Gold:
                            {
                                if (iteminfo.BaseInformation.GoldWorth * Amount > client.Entity.Money)
                                    return;
                                if (client.Entity.Money - (iteminfo.BaseInformation.GoldWorth * Amount) > client.Entity.Money)
                                    return;
                                item.ID = itemUsage.dwParam;
                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                item.Color = (Game.Enums.Color)3;

                                uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                while (NewAmount > 0)
                                {
                                    if (iteminfo.BaseInformation.StackSize == 0)
                                    {
                                        item = new ConquerItem(true);
                                        item.ID = itemUsage.dwParam;
                                        item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                        item.Color = (Game.Enums.Color)3;
                                        client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                        item.MaxStackSize = item.StackSize = 1;
                                        NewAmount--;
                                    }
                                    else
                                    {
                                        if (client.Inventory.GetStackContainer(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, 1, out _ExistingItem))
                                        {
                                            _ExistingItem.StackSize++;

                                            Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                            _ExistingItem.Send(client);
                                            NewAmount -= 1;
                                        }
                                        else
                                        {
                                            item = new ConquerItem(true);
                                            item.ID = itemUsage.dwParam;
                                            item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                            item.Color = (Game.Enums.Color)3;
                                            item.MaxStackSize = iteminfo.BaseInformation.StackSize;
                                            item.StackSize = 1;
                                            if (NewAmount >= item.MaxStackSize)
                                            {
                                                item.StackSize = item.MaxStackSize;
                                                NewAmount -= item.StackSize;
                                            }
                                            else
                                            {
                                                item.StackSize = (ushort)NewAmount;
                                                NewAmount = 0;
                                            }
                                            client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                            Database.ConquerItemTable.UpdateStack(item);
                                        }
                                    }
                                }
                                client.Entity.Money -= (iteminfo.BaseInformation.GoldWorth * Amount);
                                break;
                            }
                        case Database.ShopFile.MoneyType.ConquerPoints:
                            {
                                bool bound = true;
                                if (itemUsage.dwExtraInfo3 == 2 || shop.UID == 20574)
                                {
                                    if (shop.UID == 20574)
                                        bound = false;
                                    if (iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.BoundCps)
                                        return;
                                    if (client.Entity.BoundCps - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.BoundCps)
                                        return;
                                    item.ID = itemUsage.dwParam;
                                    if (item.ID % 730000 <= 12)
                                        item.Plus = (Byte)(item.ID % 730000);
                                    item.Color = (Game.Enums.Color)Kernel.Random.Next(4, 8);
                                    item.Bound = bound;
                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                    uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                    while (NewAmount > 0)
                                    {
                                        if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                                        {
                                            if (_ExistingItem.StackSize == 0)
                                                _ExistingItem.StackSize = 0;

                                            ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                            _StackCount -= (ushort)_ExistingItem.StackSize;
                                            try
                                            {
                                                _ExistingItem.Bound = bound;
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }
                                            if (_StackCount >= NewAmount)
                                                _StackCount = (ushort)NewAmount;
                                            _ExistingItem.StackSize += _StackCount;

                                            Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                            _ExistingItem.Send(client);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                                            NewAmount -= _StackCount;
                                        }
                                        else
                                        {
                                            if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
                                            {
                                                item = new ConquerItem(true);
                                                item.ID = itemUsage.dwParam;
                                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                item.Color = (Game.Enums.Color)3;
                                                item.Bound = bound;
                                                ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                                if (NewAmount <= iteminfo.BaseInformation.StackSize)
                                                    _StackCount = (ushort)NewAmount;
                                                item.StackSize = (ushort)_StackCount;
                                                client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                Database.ConquerItemTable.UpdateStack(item);
                                                NewAmount -= _StackCount;
                                            }
                                            else
                                            {
                                                if ((itemUsage.dwParam % 730000) <= 12)
                                                {
                                                    ConquerItem newItem = new GamePackets.ConquerItem(true);
                                                    newItem.ID = itemUsage.dwParam;
                                                    newItem.Plus = (Byte)(newItem.ID % 730000);
                                                    newItem.Bound = bound;
                                                    client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                }
                                                else
                                                {
                                                    item = new ConquerItem(true);
                                                    item.ID = itemUsage.dwParam;
                                                    item.Bound = bound;
                                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                    item.Color = (Game.Enums.Color)3;
                                                    item.StackSize = 1;
                                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                }
                                                NewAmount--;
                                            }
                                        }
                                    }
                                    client.Entity.BoundCps -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
                                }
                                else
                                {
                                    if (shop.UID == 20574 || iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.ConquerPoints) return;
                                    if (client.Entity.ConquerPoints - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.ConquerPoints)
                                        return;
                                    item.ID = itemUsage.dwParam;
                                    if (item.ID % 730000 <= 12)
                                        item.Plus = (Byte)(item.ID % 730000);
                                    item.Color = (Game.Enums.Color)Kernel.Random.Next(4, 8);
                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                    uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
                                    while (NewAmount > 0)
                                    {
                                        if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
                                        {
                                            if (_ExistingItem.StackSize == 0)
                                                _ExistingItem.StackSize = 1;

                                            ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                            _StackCount -= (ushort)_ExistingItem.StackSize;

                                            if (_StackCount >= NewAmount)
                                                _StackCount = (ushort)NewAmount;
                                            _ExistingItem.StackSize += _StackCount;

                                            Database.ConquerItemTable.UpdateStack(_ExistingItem);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Update;
                                            _ExistingItem.Send(client);
                                            _ExistingItem.Mode = Game.Enums.ItemMode.Default;
                                            NewAmount -= _StackCount;
                                        }
                                        else
                                        {
                                            if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
                                            {
                                                item = new ConquerItem(true);
                                                item.ID = itemUsage.dwParam;
                                                item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                item.Color = (Game.Enums.Color)3;
                                                ushort _StackCount = iteminfo.BaseInformation.StackSize;
                                                if (NewAmount <= iteminfo.BaseInformation.StackSize)
                                                    _StackCount = (ushort)NewAmount;
                                                item.StackSize = (ushort)_StackCount;
                                                client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                Database.ConquerItemTable.UpdateStack(item);
                                                NewAmount -= _StackCount;
                                            }
                                            else
                                            {
                                                if ((itemUsage.dwParam % 730000) <= 12)
                                                {
                                                    ConquerItem newItem = new GamePackets.ConquerItem(true);
                                                    newItem.ID = itemUsage.dwParam;
                                                    newItem.Plus = (Byte)(newItem.ID % 730000);
                                                    client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
                                                }
                                                else
                                                {
                                                    item = new ConquerItem(true);
                                                    item.ID = itemUsage.dwParam;
                                                    item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
                                                    item.Color = (Game.Enums.Color)3;
                                                    item.StackSize = 1;
                                                    client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
                                                }
                                                NewAmount--;
                                            }
                                        }
                                    }
                                    client.Entity.ConquerPoints -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
                                }
                                break;
                            }
                    }
                }
            }
        }
It allows you to buy more than the size of the bag



alissoncuan is offline  
Old 11/30/2019, 18:04   #2
 
elite*gold: 12
Join Date: Jul 2011
Posts: 7,472
Received Thanks: 3,657
That's not a question, and that code is unreadable.


Spirited is offline  
Thanks
1 User
Old 12/02/2019, 18:10   #3
 
elite*gold: 0
Join Date: Jul 2009
Posts: 581
Received Thanks: 202
Brazilians being brazilians.
Okay, I wont give you code but if you want to check if your inventory has space for an specific item you need to calculate:
Free Space = Item.MaxStackAmount * InventorySpace (Single block) + (Sum((Items of the same type).MaxStackAmount) - Sum((Items of the same type).StackAmount))
Good luck

Edit:
Since it can't be copied into any source, I'm leaving my version.
pintinho12 is offline  
Thanks
1 User
Old 12/02/2019, 23:22   #4
 
elite*gold: 0
Join Date: Sep 2009
Posts: 33
Received Thanks: 2
Brazilians are the best
with what you explained I was able to solve the problem
Thanks


alissoncuan is offline  
Thanks
1 User
Old 12/03/2019, 04:50   #5
 
elite*gold: 12
Join Date: Jul 2011
Posts: 7,472
Received Thanks: 3,657
Nothing to do with being Brazilian... Just has to do with level of experience.
Spirited is offline  
Old 12/03/2019, 22:17   #6
 
elite*gold: 0
Join Date: Jul 2009
Posts: 581
Received Thanks: 202
Quote:
Originally Posted by Spirited View Post
Nothing to do with being Brazilian... Just has to do with level of experience.
I mean because of the way the question has been formulated ^^,
There's a small community of good developers and our servers are allies. And this time I've got to admit, I'm surprised and I was totally wrong about him, tho I think I know him XD


pintinho12 is offline  
Reply



« [Feature Analysis] Interface Items | Why would I lose my fkey? »

Similar Threads
Opennos Stacksize Change/Ändern
06/29/2018 - Nostale - 13 Replies
Hallo ich habe Im moment das Problem das ich nur 99beim npc Kaufen kann und nur 255 lagern Kann ich möchte aber gerne 999beim Npc Kaufen und 999 lagern und 999 droppen Lassen da es auch im moment nur bei 99 liegt Kann mir einer erklären wie das geht? Würde mich Sehr Freuen ;) Hello I have at the moment the problem that I can only 99beim buy in npc and only 255 store Can I like but 999beim Buy Npc and 999 store and drop 999 Since it is synonymous in the moment only at 99 Can explain to me...
[TUT] Unlimited Cash Skill Amount and Pet Skill Amount Hack
12/15/2011 - Grand Chase Hacks, Bots, Cheats & Exploits - 33 Replies
This Hack allows you to use potion as much as you like in one dungeon run,, Requirement : 1. Cheat Engine lastest version 2. Windows 7 64bit (not tested with other 64bit OS) 3. grandchase.exe How to use : Unlimited Potion Amount Hack : Exact Value, Bytes, uncheck the Fast Scan
WPE item amount
07/20/2006 - World of Warcraft - 5 Replies
Ich wollte mal fragen ob es in WPE ne möglichkeit gibt 50 reagenzien auf einmal einzuholen anstatt jedes item einzeln besorgen zu müssen...



All times are GMT +1. The time now is 06:24.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

BTC: 33E6kMtxYa7dApCFzrS3Jb7U3NrVvo8nsK
ETH: 0xc6ec801B7563A4376751F33b0573308aDa611E05

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