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:
- Now, under case 2032:, add this:
I think thats everything! Enjoy your new Name Changing NPC!
Press Thanks if this helped!
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());
}
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;
}
}
Press Thanks if this helped!