[Release] Change Name NPC

09/06/2008 07:07 kinshi88#1
This is everything you need to Code a Name Changing NPC in LOTF source.

Why Release it?
- It is fairly easy to figure out, and if you have decent knowledge of C# and of the source you use, then you can figure it out.
- Also, I believe that open source coding for servers is a lot more efficient, and produces better/more advanced results.

What does this NPC do?
- Changes your characters name for 1 Dragonball.

What will I need?
- Brain w/ common sense
- LOTF source [Link: [Only registered and activated users can see links. Click Here To Register...]]



How to Code a Name Changing NPC

Database:

- To access the database: [Only registered and activated users can see links. Click Here To Register...]

- Create the NPC where ever you want, I'm sure you know how. (UID = 9534)

Source:

- In Client.cs under case 2031: where all the other NPCs are =P:
Code:
                            if (CurrentNPC == 9534)
                            {
                                SendPacket(General.MyPackets.NPCSay("You can change you name in exchange for a Dragonball. Would you like to change your name?"));
                                SendPacket(General.MyPackets.NPCLink("Yes please.", 1));
                                SendPacket(General.MyPackets.NPCLink("No thanks.", 255));
                                SendPacket(General.MyPackets.NPCSetFace(30));
                                SendPacket(General.MyPackets.NPCFinish());
                            }
- Now, under case 2032:, add this:
Code:
                            if (CurrentNPC == 9534)
                            {
                                if (Control == 1)
                                {
                                    if (MyChar.InventoryContains(1088000, 1))
                                    {
                                        SendPacket(General.MyPackets.NPCSay("Enter your new name."));
                                        SendPacket(General.MyPackets.NPCLink2("Name:", 2));
                                        SendPacket(General.MyPackets.NPCLink("Cancel.", 255));
                                        SendPacket(General.MyPackets.NPCSetFace(30));
                                        SendPacket(General.MyPackets.NPCFinish());
                                    }
                                    else
                                    {
                                        SendPacket(General.MyPackets.NPCSay("You don't have a Dragonball."));
                                        SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                        SendPacket(General.MyPackets.NPCSetFace(30));
                                        SendPacket(General.MyPackets.NPCFinish());
                                    }
                                }
                                if (Control == 2)
                                {
                                    string OldName = MyChar.Name;
                                    string NewName = "";
                                    bool ValidName = true;
                                    for (int i = 14; i < 14 + Data[13]; i++)
                                    {
                                        NewName += Convert.ToChar(Data[i]);
                                    }
                                    if (NewName.IndexOfAny(new char[3] { ' ', '[', ']' }) > -1)
                                    {
                                        ValidName = false;
                                    }

                                    foreach (string name in DataBase.ForbiddenNames)
                                    {
                                        if (name == NewName)
                                        {
                                            ValidName = false;
                                            break;
                                        }
                                    }

                                    try
                                    {
                                        if (ValidName)
                                        {
                                            MyChar.RemoveItem(MyChar.ItemNext(1088000));

                                            MyChar.Name = NewName;

                                            World.SendMsgToAll(OldName + " changed his/her name to " + NewName + ".", "SYSTEM", 2005);

                                            SendPacket(General.MyPackets.CharacterInfo(MyChar));
                                            World.SpawnMeToOthers(MyChar, false);
                                            MyChar.SendEquips(false);
                                        }
                                        else
                                        {
                                            SendPacket(General.MyPackets.NPCSay("That name is not valid!"));
                                            SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                            SendPacket(General.MyPackets.NPCSetFace(30));
                                            SendPacket(General.MyPackets.NPCFinish());
                                        }
                                    }
                                    catch (Exception Exc) { General.WriteLine(Exc.ToString()); }


                                    break;
                                }
                            }
I think thats everything! Enjoy your new Name Changing NPC!


Press Thanks if this helped!
09/06/2008 07:25 taguro#2
Quote:
Originally Posted by kinshi88 View Post
This is everything you need to Code a Name Changing NPC in LOTF source.

Why Release it?
- It is fairly easy to figure out, and if you have decent knowledge of C# and of the source you use, then you can figure it out.
- Also, I believe that open source coding for servers is a lot more efficient, and produces better/more advanced results.

What does this NPC do?
- Changes your characters name for 1 Dragonball.

What will I need?
- Brain w/ common sense
- LOTF source [Link: [Only registered and activated users can see links. Click Here To Register...]]



How to Code a Name Changing NPC

Database:

- To access the database: [Only registered and activated users can see links. Click Here To Register...]

- Create the NPC where ever you want, I'm sure you know how. (UID = 9534)

Source:

- In Client.cs under case 2031: where all the other NPCs are =P:
Code:
                            if (CurrentNPC == 9534)
                            {
                                SendPacket(General.MyPackets.NPCSay("You can change you name in exchange for a Dragonball. Would you like to change your name?"));
                                SendPacket(General.MyPackets.NPCLink("Yes please.", 1));
                                SendPacket(General.MyPackets.NPCLink("No thanks.", 255));
                                SendPacket(General.MyPackets.NPCSetFace(30));
                                SendPacket(General.MyPackets.NPCFinish());
                            }
- Now, under case 2032:, add this:
Code:
                            if (CurrentNPC == 9534)
                            {
                                if (Control == 1)
                                {
                                    if (MyChar.InventoryContains(1088000, 1))
                                    {
                                        SendPacket(General.MyPackets.NPCSay("Enter your new name."));
                                        SendPacket(General.MyPackets.NPCLink2("Name:", 2));
                                        SendPacket(General.MyPackets.NPCLink("Cancel.", 255));
                                        SendPacket(General.MyPackets.NPCSetFace(30));
                                        SendPacket(General.MyPackets.NPCFinish());
                                    }
                                    else
                                    {
                                        SendPacket(General.MyPackets.NPCSay("You don't have a Dragonball."));
                                        SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                        SendPacket(General.MyPackets.NPCSetFace(30));
                                        SendPacket(General.MyPackets.NPCFinish());
                                    }
                                }
                                if (Control == 2)
                                {
                                    string OldName = MyChar.Name;
                                    string NewName = "";
                                    bool ValidName = true;
                                    for (int i = 14; i < 14 + Data[13]; i++)
                                    {
                                        NewName += Convert.ToChar(Data[i]);
                                    }
                                    if (NewName.IndexOfAny(new char[3] { ' ', '[', ']' }) > -1)
                                    {
                                        ValidName = false;
                                    }

                                    foreach (string name in DataBase.ForbiddenNames)
                                    {
                                        if (name == NewName)
                                        {
                                            ValidName = false;
                                            break;
                                        }
                                    }

                                    try
                                    {
                                        if (ValidName)
                                        {
                                            MyChar.RemoveItem(MyChar.ItemNext(1088000));

                                            MyChar.Name = NewName;

                                            World.SendMsgToAll(OldName + " changed his/her name to " + NewName + ".", "SYSTEM", 2005);

                                            SendPacket(General.MyPackets.CharacterInfo(MyChar));
                                            World.SpawnMeToOthers(MyChar, false);
                                            MyChar.SendEquips(false);
                                        }
                                        else
                                        {
                                            SendPacket(General.MyPackets.NPCSay("That name is not valid!"));
                                            SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                            SendPacket(General.MyPackets.NPCSetFace(30));
                                            SendPacket(General.MyPackets.NPCFinish());
                                        }
                                    }
                                    catch (Exception Exc) { General.WriteLine(Exc.ToString()); }


                                    break;
                                }
                            }
I think thats everything! Enjoy your new Name Changing NPC!


Press Thanks if this helped!
your on fire bro... keep up the good work =)
09/06/2008 13:37 _Emme_#3
Seems like you got ur comp working again? Hope so,if so,great,then we can start coding,gotta talk to u though :P
Cya

Emme
09/06/2008 21:01 ~Yuki~#4
Nice^^
09/06/2008 22:49 konkizta#5
thanks:D
09/07/2008 02:17 elragal_30#6
thanks i'll try it
by the way : how i can make NPC do some command
i mean there r "/Changename" command how i can make nbc do this command
09/07/2008 02:47 konkizta#7
Quote:
Originally Posted by elragal_30 View Post
thanks i'll try it
by the way : how i can make NPC do some command
i mean there r "/Changename" command how i can make nbc do this command
Code:
if (Splitter[0] == "/nombre")
                                            {
                                                string newname = Splitter[1];
                                                MyChar.Name = newname;
                                                SendPacket(General.MyPackets.CharacterInfo(MyChar));
                                                World.SpawnMeToOthers(MyChar, false);
                                                MyChar.SendEquips(false);
                                            }
09/07/2008 10:40 ~Yuki~#8
Quote:
Originally Posted by konkizta View Post
Code:
if (Splitter[0] == "/nombre")
                                            {
                                                string newname = Splitter[1];
                                                MyChar.Name = newname;
                                                SendPacket(General.MyPackets.CharacterInfo(MyChar));
                                                World.SpawnMeToOthers(MyChar, false);
                                                MyChar.SendEquips(false);
                                            }

Yow online translater sux balls he dont wanna know a command 4 namechangeing
He wanna know how to make NPCs usin commands^^
09/07/2008 11:42 _Emme_#9
Not possible on loft source if u aint gonna rewrite it all. The only server I know who got that,is hybrid co / acid co
09/07/2008 11:52 ~Yuki~#10
Crap-.-
09/07/2008 17:17 konkizta#11
Quote:
Originally Posted by lolmaster123 View Post
Yow online translater sux balls he dont wanna know a command 4 namechangeing
He wanna know how to make NPCs usin commands^^
ahhh xD is that translators are a shit.

or writing people xD :rolleyes:
09/07/2008 22:28 Mouse>Pro#12
nice
09/08/2008 00:44 taguro#13
Quote:
Originally Posted by Mouse>Pro View Post
nice
Changing NPC names is actually pretty easy, the unfortunate part is this: the only way to change the NPC name server wide is to send everyone an edited client. Even if you coded an NPC Changing name command in your script, it still wouldn't effect the individual clients on other peoples computer.
09/08/2008 11:31 _Emme_#14
Quote:
Originally Posted by taguro View Post
Changing NPC names is actually pretty easy, the unfortunate part is this: the only way to change the NPC name server wide is to send everyone an edited client. Even if you coded an NPC Changing name command in your script, it still wouldn't effect the individual clients on other peoples computer.

Its acually ChangeName-NPC, the npc changes your name,not how to change an npc's name. lol
09/14/2008 00:26 © Haydz#15
Quote:
Originally Posted by emildayan1 View Post
Not possible on loft source if u aint gonna rewrite it all. The only server I know who got that,is hybrid co / acid co
hmm... :| i've had that for ages lul