[Help]CoEmu 5095 source InventoryContains

05/28/2009 20:52 koio#1
hi
someone know how to use this in coEmu source:

Code:
if (MyChar.InventoryContains(721259, 1))
or how to add something that i can check if the char haa one wanted item?
05/28/2009 22:41 YukiXian#2
May this:
Code:
if(CSocket.Client.Inventory.ContainsKey(UID HERE))
{
//Code here...
}
05/28/2009 22:57 $HaDoW#3
and what for remove and add item ?
05/29/2009 06:25 koio#4
Quote:
Originally Posted by YukiXian View Post
May this:
Code:
if(CSocket.Client.Inventory.ContainsKey(UID HERE))
{
//Code here...
}
but at UID i can use only the item UID not the item ID or?
and i need to check it item id
05/29/2009 13:43 Zanzibar#5
Quote:
Originally Posted by koio View Post
but at UID i can use only the item UID not the item ID or?
and i need to check it item id
I think you can use the ID.
05/29/2009 14:57 $HaDoW#6
I did it :)
heres an exmp :) only thing I need to know where the hell do I get the UID of the item !
Code:
else if (LinkBack == 3)
                        {
                            if(CSocket.Client.Inventory.ContainsKey(720028))
                            {
                                CSocket.Client.Inventory.Remove(720028);
                                CPs (+500, CSocket);
                            }
                            else
                            {
                                Text("How dare you try to rip me off! Get lost, Or get my DBScroll!", CSocket);
                                Link("I'm sorry, I didn't realize.", 255, CSocket);
                                End(CSocket);
                            }
                        }
05/29/2009 15:22 koio#7
then i try it it didnīt work for me with the item id
Code:
              else if (LinkBack == 2)
                        {
                            if (CSocket.Client.Inventory.ContainsKey(1088000))
                            {
                                
                                CPs(+5000, CSocket);
                            }
                            else
                            {
                                Text("You don't have a dragon ball!", CSocket);
                                Link("I'm sorry, I didn't realize.", 255, CSocket);
                                End(CSocket);
                            }
                        }
with the uid it works but not every itemid have the same uid
05/29/2009 15:48 nTL3fTy#8
You need to iterate through the whole dictionary:

Code:
foreach (KeyValuePair<int, Struct.ItemInfo> pair in Inventory)
{
    if (pair.Value.ItemID == [param_name_for_item_id]) return true;
}
return false;
05/29/2009 16:26 $HaDoW#9
nTL3fTy wtf do you mean ? :D xD more info what to do where !