Register for your free account! | Forgot your password?

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

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

Advertisement



Weird problem at itens removal [Help]

Discussion on Weird problem at itens removal [Help] within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
Weird problem at itens removal [Help]

yo!

hmmm i'm just learning more with my current patched source but... there is something bothering me...

i've tried many times and the problem stay the same....
when i call the void for the second or third time... the iten is not removed anymore .... oO
those are my voids for remove and check to contains an item :
Code:
        public static void RemoveItem(uint UID, ClientSocket CSocket)
        {
        Again:
            try
            {
                CSocket.Client.Inventory.Remove(UID);
            }
            catch { Console.WriteLine("Error while removing UID " + UID); goto Again; }
        }

        public static void RemoveItem(uint ID, byte Times, ClientSocket CSocket)
        {
            byte ItemsFound = 0;

            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
            {
                if (Item == null) continue;
                if (ItemsFound == Times) break;
                if (Item.ID == ID)
                {
                    RemoveItem(Item.UID, CSocket);
                    ItemsFound++;
                }
            }
        }

        public static bool ContainsItem(uint ID, byte Times, ClientSocket CSocket)
        {
            byte Count = 0;
            Struct.ItemInfo[] Inv = CSocket.Client.Inventory.Values;

                foreach (Struct.ItemInfo Item in Inv)
                    if (Item != null)
                        if (Item.ID == ID)
                            Count++;

            return (Count >= Times);
        }
//Don't say you haven't added database removal and the itenusage packet... they're at my Inventory class ^^

if somene saw something wrong inside the codes.... i would like the help ^^
12tails is offline  
Old 04/11/2011, 22:52   #2
 
|NeoX's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 237
Received Thanks: 99
I dont see the problem but smething worse...

public static void RemoveItem(uint UID, ClientSocket CSocket)
{
Again:
try
{
CSocket.Client.Inventory.Remove(UID);
}
catch { Console.WriteLine("Error while removing UID " + UID); goto Again; }
}

Basicly it will loop forever if that UID isnt existing? Oh ****!
|NeoX is offline  
Old 04/11/2011, 23:06   #3
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
that's the remove void :
Code:
        public void Remove(uint key)
        {
            byte c = 0;
            foreach (Struct.ItemInfo it in Items)
                if (it != null)
                {
                    if (it.UID == key)
                    {
                        Owner.Owner.Send(ConquerPacket.ItemUsage(it.UID, 255, Struct.ItemUsage.RemoveItem));
                        Database.DeleteItem(it.UID);
                        Items[c] = null;
                        CountDown();
                        break;
                    }
                    c++;
                }
        }
so it will loop if there is a problem here ^^
12tails is offline  
Old 04/12/2011, 10:35   #4
 
|NeoX's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 237
Received Thanks: 99
Ohh im sorry
|NeoX is offline  
Old 04/12/2011, 13:13   #5
 
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
Items is list? ( list<object> Items = ...) ?

if is list , try:

public void Remove(uint key)
{

for(byte x =0; x < Items.Count; x++)
{
if(Items[x] != null)
if(Items[x].UID == key)

{
Owner.Owner.Send(ConquerPacket.ItemUsage(Items[x].UID, 255, Struct.ItemUsage.RemoveItem));
Database.DeleteItem(Items[x].UID);
Items.Remove(Items[x]); //Items[x] = null;
CountDown();
break;

}



}
}
teroareboss1 is offline  
Old 04/12/2011, 18:38   #6
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
Quote:
public bool RemoveItems(uint ID, byte Times, ClientSocket CSocket)
{
var Items = from I in this.Inventory.Values where I.ID == ID select I;
if (Items.Count() == Times || Items.Count() >= Times)
{
int Count = 0;
foreach (Struct.ItemInfo Item in Items)
{
this.Inventory.Remove(Item.UID);
this.Send(ConquerPacket.ItemUsage(Item.UID, 255, Struct.ItemUsage.RemoveItem));
Database.DeleteItem(Item.UID);
if (Count == Times) return true;
Count++;
}
}
return false;
}
Quote:
if (Client.RemoveItems(ID, Times, Client))
{
do something
}
else {Message"You dont have the whatever you are looking for "}
thats gonna do all 3 voids work thought

i dident test that but i believe that should do the job ,
good luck ,
{ Angelius } is offline  
Old 04/12/2011, 19:13   #7
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,381
if (Items.Count() == Times || Items.Count() >= Times)

can just be

if (Items.Count() >= Times)

You're already checking == in that section.


But yes, Linq is a fantastic tool for all sorts of applications including this one.

Looks like a very nice solution to this.
pro4never is offline  
Thanks
1 User
Old 04/12/2011, 21:06   #8
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
hmm... i see

tkx guys ^^
12tails is offline  
Reply


Similar Threads Similar Threads
Weird Lag problem
12/26/2009 - Dekaron - 0 Replies
i have 2 2moons copies, one orginal another one with csv editen for ego spawn. I run orginal with ReXIGNation v1.54a to login my nub char. And again with ReXIGNation v1.54a i run my csv edited client, CRC bybass checked. , before logging in i turn on CE hacks. well, My pc is good enough intell quad q660 4gb ddr2 ram HD4870 Video
Weird problem
12/21/2009 - Dekaron Private Server - 1 Replies
Hmm ive searcged forum but no such topic,ive tried everything but still no succes. It seems i cant login my server because there is no Channel to login into . Im using difference client and diffrence server files that silkbotter posted. I got it running on a virtual machine xp sp3 1 gb of ram,40gb hdd. Server is running fine launches etc,and register works. Im using W7 with 2gb -1gb to vm.
[help]weird problem
07/30/2009 - CO2 Private Server - 5 Replies
i've tryed using like 20 different register pages there all setup right says that the account has been successfully created but when i look in phpmyadmin there is no account there so its not inserting it into the db can anyone help me with this i've been at it for 3 days now. using lotf source
a weird problem
03/23/2009 - Silkroad Online - 4 Replies
ok i have a cyber cafe... master pc: vga card: ati radeon xpress 1250 processor: amd athlon 64 x2 dual core processor 4000+ ram: 2 gb cyber pc's: vga card: ati radeon hd3200 processor: amd athlon 64 x2 dual core processor 5000+
Effect Removal w/Sound Removal
03/13/2008 - CO2 Exploits, Hacks & Tools - 16 Replies
Well since Mr.Teenies Effect Removal came out and i had been using it..I decided to make my own for the fact that when i enter TG my client will sometimes hang, and the Sounds get really loud and carry out..it's gay.SO i've made this tool to remove the sound as well as the effects, SILENT TG ^^. It may take a minute to run the Sound Remover..but not very long at all ^^. This Tool Greatly help's me in TG i run a good 280-314 Ping without ever Disconnecting unless they have Server Mait. I...



All times are GMT +1. The time now is 10:20.


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

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