Trying to add an NPC but...

08/27/2019 01:33 denominator#1
Code:
#region Escort Chief
                    case 30165:
                        {
                            switch (npcRequest.OptionID)
                            {
                                case 0:
                                    {

                                        dialog.Text("Do you want to clear your inventory? It's free.");
                                        dialog.Option("Yes, actually i do.", 1);
                                        dialog.Option("Just passing by.", 255);
                                        dialog.Send();
                                        break;
                                    }
                                case 1:
                                    {
                                        dialog.Text("Are you sure?");
                                        dialog.Option("Yes, i am.", 2);
                                        dialog.Option("No, i don't know what i was thinking.", 255);
                                        dialog.Send();
                                        break;
                                    }
                                case 2:
                                    {
                                        foreach (Game.Item I in GC.MyChar.Inventory)
                                        GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
                                        GC.MyChar.Inventory = new ArrayList(40);
                                        dialog.Text("Well it's done.");
                                        dialog.Option("Thanks.", 255);
                                        dialog.Send();
                                        break;
                                    }
                                    
                            }
                            break;
                        }
                            #endregion
I'm trying to add this except I'm unsure as to what these lines should be

Code:
foreach (Game.Item I in GC.MyChar.Inventory)
                                        GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
                                        GC.MyChar.Inventory = new ArrayList(40);
I know it isn't GC.MyChar.Inventory or GC.AddSend but not really sure what it should be >.<
08/27/2019 08:25 Spirited#2
Unsure without the actual source code. I'd recommend looking at the Inventory class(?) and see what methods it exposes for clearing the list, and if deleting items also sends those packets to the client automatically. You reinitializing it as an ArrayList is odd to me. If you're not saving that to the database, then your characters are going to overflow items. Also, just some advice on coding indentation, I recommend indenting code in your foreach body so it's clear what's being repeated. For example:

Code:
foreach (Game.Item I in GC.MyChar.Inventory)
    GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
GC.MyChar.Inventory = new ArrayList(40);
08/27/2019 10:48 pintinho12#3
Quote:
Originally Posted by Spirited View Post
Unsure without the actual source code. I'd recommend looking at the Inventory class(?) and see what methods it exposes for clearing the list, and if deleting items also sends those packets to the client automatically. You reinitializing it as an ArrayList is odd to me. If you're not saving that to the database, then your characters are going to overflow items. Also, just some advice on coding indentation, I recommend indenting code in your foreach body so it's clear what's being repeated. For example:

Code:
foreach (Game.Item I in GC.MyChar.Inventory)
    GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
GC.MyChar.Inventory = new ArrayList(40);
Well, it's cleaning the inventory but isn't saving (deleting btw) on the database. It's just sending the remove subtype and creating the inventory list again.

Code:
public enum ItemAction : uint
{
        None = 0,
        Buy = 1,
        Sell = 2,
        Remove = 3,
        ...
}
08/27/2019 11:56 denominator#4
It's actually code from NCOS, I just tried implementing it into the server lol
08/27/2019 14:08 pintinho12#5
Quote:
Originally Posted by denominator View Post
It's actually code from NCOS, I just tried implementing it into the server lol
If you're cleaning the inventory you must delete the items from the database too, or you'll be loading them on the next login.

Code:
foreach (Game.Item I in GC.MyChar.Inventory)
{
    GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
    I.Delete();
}
GC.MyChar.Inventory = new ArrayList(40);
Or whichever code you have there.
08/28/2019 19:38 denominator#6
I actually don't even need it lol
08/28/2019 20:19 pintinho12#7
Since TQ Binaries times I never changed my mind. NPCs to clear the inventory are useless.
08/28/2019 20:29 denominator#8
I was just confused as to why I couldn't drop certain items, turns out I need to be wearing better quality gears to drop gears in my inventory lol
08/30/2019 18:47 pintinho12#9
Or send the merchant with packet 10017 and value 255
where Merchant = 38 and false is broadcast

Quote:
user.UpdateClient(ClientUpdateType.Merchant, 255, false);