this is for both lotf and coemu
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Some stuff needed for some of the npc's

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin


Posts : 56
Join date : 2009-08-20

PostSubject: Some stuff needed for some of the npc's   Tue Aug 25, 2009 10:38 am

add this to the bottom of npctalk.cs

Code:
public static void AddItem(int itemid, int bless, int dura, int enchant, int plus,int Progress, int position, int soc1, int soc2, int color, ClientSocket CSocket,byte Count)
        {
            for (byte t = 0; t < Count; t++)
            {
                Struct.ItemInfo Item = new Struct.ItemInfo();
                if (dura == 255)
                {
                    Item.Dura = Item.MaxDura;
                }
                else
                {
                    Item.Dura = dura;
                }
                Item.Bless = bless;
                Item.Enchant = enchant;
                Item.ItemID = itemid;
                Item.Plus = plus;
                Item.Progress = Progress;
                Item.Position = position;
                Item.Soc1 = soc1;
                Item.Soc2 = soc2;
                Item.Color = color;
                Item.UID = Nano.Rand.Next(1, 9999999);
                bool created = Database.Database.NewItem(Item, CSocket);
                while (!created)
                {
                    Item.UID = Nano.Rand.Next(1, 9999999);
                    created = Database.Database.NewItem(Item, CSocket);
                }

                CSocket.Client.Inventory.Add(Item.UID, Item);
                CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Item.Plus, Item.Progress, Item.Bless, Item.Enchant, Item.Soc1, Item.Soc2, Item.Dura, Item.MaxDura, Item.Position, Item.Color,0,0));
            }
        }
        public static bool HasItem(int ItemId, byte Count, ClientSocket CSocket)
        {
            //720027 MeteorScroll ,720028 DBScroll, 1088001 Meteor, 1088000 DragonBall, 1080001 Emerald
            byte ItemsFound = 0;
            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
            {
                if (ItemsFound < Count)
                {
                    if (Item.ItemID == ItemId) ItemsFound++;
                }
                else break;
            }
            if (ItemsFound >= Count) return true;
            return false;
        }
        public static void DeleteItem(int ItemID, byte Count, ClientSocket CSocket)
        {
            int[] Uids = new int[Count]; byte ItemsFound = 0;
            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
            {

                if (Item.ItemID == ItemID)
                {
                    Uids[ItemsFound] = Item.UID; ItemsFound++;
                }
                if (ItemsFound == Count) break;

            }
            for (byte t = 0; t < Count; t++)
            {
                CSocket.Client.Inventory.Remove(Uids[t]);
                CSocket.Send(ConquerPacket.ItemUsage(Uids[t], 255, Struct.ItemUsage.RemoveItem));
                Database.Database.DeleteItem(Uids[t]);
            }

        }
Back to top Go down
View user profile http://openprojects.forumotions.net
 
Some stuff needed for some of the npc's
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Sizes for a fortress, Measurements and stuff needed for 28mm
» Advertisers needed!
» Stickers 'n stuff
» Government Regulation is needed
» Crackle effect paint without buying extra stuff!

Permissions in this forum:You cannot reply to topics in this forum
lotf/coemu project :: Codes-
Jump to: