adding npcs

07/23/2014 03:25 NonStopCoding#1
Hello all sorry for the post but i have been reading through the comments on redux and i found code for cp admin but i cant get him to load for some reason

i went into Redux -> npcs -> created a new file [2071]CPAdmin.cs

copied the code

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Redux.Packets.Game;

namespace Redux.Npcs
{

    /// <summary>
    /// Handles NPC usage for [4450] Market Controller
    /// </summary>
    public class NPC_2071 : INpc
    {

        public NPC_2071(Game_Server.Player _client)
            : base(_client)
        {
            ID = 2071;
            Face = 54;
        }

        public override void Run(Game_Server.Player _client, ushort _linkback)
        {
            Responses = new List<NpcDialogPacket>();
            AddAvatar();
            switch (_linkback)
            {
                case 0:
                    AddText("Hello, need to exchange those DragonBalls(220 CPs) or DBScrolls(2200) to CPs to save some space?");
                    AddText("Witch would you like to exchange?");
                    AddOption("An DragonBall only .", 1);
                    AddOption("An DBScroll.", 2);
                    AddOption("No. I shall stay here.", 255);
                    break;
                case 1:
                    if (_client.HasItem(1088000))
                    {
                        _client.DeleteItem(1088000);
                        _client.CP += 220;
                      AddText("There you go.Check out in your inventory!");
                      AddOption("Thanks!", 255);

                    }
                    else
                    {
                        AddText("You don't have any DragonBalls.");
                        AddOption("Ok! .", 255);


                    }
                    break;
                case 2:
                    if (_client.HasItem(720028))
                    {
                        _client.DeleteItem(720028);
                        _client.CP += 2200;
                        AddText("There you go.Check out in your inventory!");
                        AddOption("Thanks!", 255);

                    }
                    else
                    {
                        AddText("You don't have any DBScrolls.");
                        AddOption("Ok! .", 255);


                    }
                    break;

            }
            AddFinish();
            Send();

        }
    }
}
but it comes up could not load npc script for npc ID: 2071

is there something i am missing?
07/23/2014 09:55 InsomniacPro#2
Code:
    /// <summary>
    /// Handles NPC usage for [4450] Market Controller
    /// </summary>
Gotta change the name and the ID there.
07/23/2014 12:29 Aceking#3
Quote:
Originally Posted by InsomniacPro View Post
Code:
    /// <summary>
    /// Handles NPC usage for [4450] Market Controller
    /// </summary>
Gotta change the name and the ID there.
Yeah but that won't make the NPC work any differently.

Honestly you need to breakpoint gameserver.cs where it handles the NpcInitial packet and follow that through.

The code itself looks ok, have you re-compiled with the new npc added?
07/23/2014 12:32 NonStopCoding#4
Quote:
Originally Posted by InsomniacPro View Post
Code:
    /// <summary>
    /// Handles NPC usage for [4450] Market Controller
    /// </summary>
Gotta change the name and the ID there.
thanks for the reply i went ahead and changed it still nothing there must be something else i have missed

Quote:
Originally Posted by Aceking View Post
Yeah but that won't make the NPC work any differently.

Honestly you need to breakpoint gameserver.cs where it handles the NpcInitial packet and follow that through.

The code itself looks ok, have you re-compiled with the new npc added?
The only thing its letting me do is debug it via f5 wont let me release it comes up with 52 errors for some reason

also tried build -> build solution

[Only registered and activated users can see links. Click Here To Register...]
07/23/2014 15:55 Aceking#5
Quote:
Originally Posted by NonStopCoding View Post
thanks for the reply i went ahead and changed it still nothing there must be something else i have missed



The only thing its letting me do is debug it via f5 wont let me release it comes up with 52 errors for some reason

also tried build -> build solution

[Only registered and activated users can see links. Click Here To Register...]
you dont need to release it, building it with f5 will work just fine.

As I said, you need to learn how to breakpoint.
07/23/2014 17:33 NonStopCoding#6
doing some research on breakpoints for c#
07/23/2014 17:43 Aceking#7
Out of curiosity, did you just create the file inside the Redux->Npcs folder?

Or did you create the file in Visual Studio?

Just putting the file into the folder will not add it to your project.
To do that, you need to go into VS. Find the NPCs folder in the Solution Explorer on the right. Right click on the NPCs fold and then go to Add Existing Item. Then find your NPC and add it.

If you can't see it in VS, then that is what you are doing wrong.

This is using Visual Studio Professional 2012. If you use something different than it might be slightly different but those instructions should get you there.
07/23/2014 17:59 NonStopCoding#8
Quote:
Originally Posted by Aceking View Post
Out of curiosity, did you just create the file inside the Redux->Npcs folder?

Or did you create the file in Visual Studio?

Just putting the file into the folder will not add it to your project.
To do that, you need to go into VS. Find the NPCs folder in the Solution Explorer on the right. Right click on the NPCs fold and then go to Add Existing Item. Then find your NPC and add it.

If you can't see it in VS, then that is what you are doing wrong.

This is using Visual Studio Professional 2012. If you use something different than it might be slightly different but those instructions should get you there.
yes i just did add the file into the npcs folder in the market folder i will try what you stated above and see if it helps i tried the code in the tokenawarder in tc and its working fine so yea i think its what you said also i am using visual studio 2013

Ok your way worked took me a while to work it out but eventually got there haha cp admin is working in market now :) Thanks alot
07/23/2014 20:41 atef201080#9
Quote:
Originally Posted by NonStopCoding View Post
thanks for the reply i went ahead and changed it still nothing there must be something else i have missed



The only thing its letting me do is debug it via f5 wont let me release it comes up with 52 errors for some reason

also tried build -> build solution

[Only registered and activated users can see links. Click Here To Register...]
you need to allow unsafe codes in project settings
07/23/2014 21:08 NonStopCoding#10
Quote:
Originally Posted by atef201080 View Post
you need to allow unsafe codes in project settings
noted thanks i did not need to release it anyways was doing it wrong
07/23/2014 22:29 InsomniacPro#11
Quote:
Originally Posted by Aceking View Post
Yeah but that won't make the NPC work any differently.

Honestly you need to breakpoint gameserver.cs where it handles the NpcInitial packet and follow that through.

The code itself looks ok, have you re-compiled with the new npc added?
/sarcasm
07/23/2014 23:13 NonStopCoding#12
So i created a quest to play around with the npcs a little nothing fancy but when you complete the quest and hand over the item it rewards you 2500 silvers and some experience . I have noticed that the experience does not seem to add to your account until you have re logged is this there a way to do it there and then?

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Redux.Packets.Game;

namespace Redux.Npcs
{
    /// <summary>
    /// Handles NPC usage for [1989] Princess
    /// </summary>
    public class NPC_1989 : INpc
    {

        public NPC_1989(Game_Server.Player _client)
            :base (_client)
    	{
    		ID = 1989;	
			Face = 20;    
    	}

        public override void Run(Game_Server.Player _client, ushort _linkback)
        {
            Responses = new List<NpcDialogPacket>();
            AddAvatar();
            switch (_linkback)
            {
                case 0:
                    AddText("Hello there i am in need of some help?");
                    AddText(" Kill the DarkSpirit's and retrive my RoyalSword The monster who");
		    AddText(" Stole it has a chance of dropping some pretty good items which can be usefull");
		    AddText(" There will also be a cash reward in it from me for doing this task.");
                    AddOption("hmm, i need more info.", 1);
                    AddOption("No, thanks.", 255);
                    AddOption("I have the item.", 3);
                    break;
                case 1:
                    AddText("Ok well my solider that i sent out on a special errand");
                    AddText(" and has not returned so i sent out a scout ");
                    AddText("the scout located a  bunch of monsters called DarkSpirt");
                    AddOption("ok, i am interested where can i find these monsters.", 2);
                    AddOption("No, Thanks Fuck that.", 255);
                    break;
                case 2:
                    AddText("The Monster can be located at the Twin City");
                    AddText(", Around 430 097");
                    AddText(" becarefull the monster is not a push over.");
                    AddText(" Kill it and bring me my Heaven Sword");
                    AddText(" The monster has a chance of dropping good rewards.");
                    AddOption("ok, I am going to slay this monster now", 255);
                    break;
                case 3:
                    if (_client.HasItem(722514))
                    {
                        _client.DeleteItem(722514);
                        _client.Money += 2500;
                        _client.Experience += 20;
                        AddText("Thank you so much for my Royal Sword Back");
                        AddText(" Here is your reward of 2500 silvers and some experience.");
                        AddOption("Thanks", 255);
                    }
                    else
                    {
                        AddText("You don't have a RoyalSword.");
                        AddOption("Ok! ill go get one.", 255);
                    }
                    break;
            }
            AddFinish();
            Send();
        }
    }
}
07/23/2014 23:51 InsomniacPro#13
Quote:
Originally Posted by NonStopCoding View Post
So i created a quest to play around with the npcs a little nothing fancy but when you complete the quest and hand over the item it rewards you 2500 silvers and some experience . I have noticed that the experience does not seem to add to your account until you have re logged is this there a way to do it there and then?

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Redux.Packets.Game;

namespace Redux.Npcs
{
    /// <summary>
    /// Handles NPC usage for [1989] Princess
    /// </summary>
    public class NPC_1989 : INpc
    {

        public NPC_1989(Game_Server.Player _client)
            :base (_client)
    	{
    		ID = 1989;	
			Face = 20;    
    	}

        public override void Run(Game_Server.Player _client, ushort _linkback)
        {
            Responses = new List<NpcDialogPacket>();
            AddAvatar();
            switch (_linkback)
            {
                case 0:
                    AddText("Hello there i am in need of some help?");
                    AddText(" Kill the DarkSpirit's and retrive my RoyalSword The monster who");
		    AddText(" Stole it has a chance of dropping some pretty good items which can be usefull");
		    AddText(" There will also be a cash reward in it from me for doing this task.");
                    AddOption("hmm, i need more info.", 1);
                    AddOption("No, thanks.", 255);
                    AddOption("I have the item.", 3);
                    break;
                case 1:
                    AddText("Ok well my solider that i sent out on a special errand");
                    AddText(" and has not returned so i sent out a scout ");
                    AddText("the scout located a  bunch of monsters called DarkSpirt");
                    AddOption("ok, i am interested where can i find these monsters.", 2);
                    AddOption("No, Thanks Fuck that.", 255);
                    break;
                case 2:
                    AddText("The Monster can be located at the Twin City");
                    AddText(", Around 430 097");
                    AddText(" becarefull the monster is not a push over.");
                    AddText(" Kill it and bring me my Heaven Sword");
                    AddText(" The monster has a chance of dropping good rewards.");
                    AddOption("ok, I am going to slay this monster now", 255);
                    break;
                case 3:
                    if (_client.HasItem(722514))
                    {
                        _client.DeleteItem(722514);
                        _client.Money += 2500;
                        _client.Experience += 20;
                        AddText("Thank you so much for my Royal Sword Back");
                        AddText(" Here is your reward of 2500 silvers and some experience.");
                        AddOption("Thanks", 255);
                    }
                    else
                    {
                        AddText("You don't have a RoyalSword.");
                        AddOption("Ok! ill go get one.", 255);
                    }
                    break;
            }
            AddFinish();
            Send();
        }
    }
}
That won't do anything. I believe there is a method in the Player class called AwardExperience or something of that nature. You'd have to use that.
07/24/2014 15:35 NonStopCoding#14
Quote:
Originally Posted by InsomniacPro View Post
That won't do anything. I believe there is a method in the Player class called AwardExperience or something of that nature. You'd have to use that.
ok thanks will look into that