Register for your free account! | Forgot your password?

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

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

Advertisement



Trying to add an NPC but...

Discussion on Trying to add an NPC but... within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
Trying to add an NPC but...

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 >.<
denominator is offline  
Old 08/27/2019, 08:25   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,192
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);
Spirited is offline  
Old 08/27/2019, 10:48   #3
 
pintinho12's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
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,
        ...
}
pintinho12 is offline  
Old 08/27/2019, 11:56   #4
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
It's actually code from NCOS, I just tried implementing it into the server lol
denominator is offline  
Old 08/27/2019, 14:08   #5
 
pintinho12's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
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.
pintinho12 is offline  
Thanks
1 User
Old 08/28/2019, 19:38   #6
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
I actually don't even need it lol
denominator is offline  
Old 08/28/2019, 20:19   #7
 
pintinho12's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
Since TQ Binaries times I never changed my mind. NPCs to clear the inventory are useless.
pintinho12 is offline  
Old 08/28/2019, 20:29   #8
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
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
denominator is offline  
Old 08/30/2019, 18:47   #9
 
pintinho12's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
Or send the merchant with packet 10017 and value 255
where Merchant = 38 and false is broadcast

Quote:
user.UpdateClient(ClientUpdateType.Merchant, 255, false);
pintinho12 is offline  
Reply


Similar Threads Similar Threads
HELP GUYS im trying to add fastjobchange but something error
04/22/2018 - Flyff Private Server - 3 Replies
Neuz error C2039: 'UpdateJob' : is not a member of 'CDPClient' how to fix this ?? i compare this to the other files but its the same nothing change when i compile i got this error sorry for my bad english
looking for coder to add soul item npc and dmg- add npc
07/09/2011 - CO2 Private Server - 0 Replies
hey im looking for a coder that could add a npc which sells full dragon soul sets +12 -7 255 hp 2 soc for specific classes e.g. for a tro you would buy a soul set which has weapons armor coro necky boots armor and so on also i need a npc where you can buy dmg - to your equips for tortoise gems



All times are GMT +1. The time now is 19:43.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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