Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

NPC Locations

Newbie Spellweaver
Joined
May 4, 2007
Messages
41
Reaction score
0
Ok, I'm new to the whole C# programming language, but if someone can point me in the right direction, I would be grateful. How would I go about scripting NPC Locations, functions, etc... For example, I would like an NPC to stand in the middle of the city and offer people a nice piece of gear (such as +3 super armor... something of that sort.) Thanks in advance for any help. You can message me @ kenneth.wallace@hotmail.com with and advice. Thanks again.

***By the way, I'm using the LOFT source.
 
Last edited:
Newbie Spellweaver
Joined
Jun 23, 2008
Messages
36
Reaction score
0
NPC locations are all coded in the database. To access the database, go into your browser and type localhost/phpmyadmin.
After that, open up coproj sql server, and go to NPCs.

The UID is the number that the database looks for in your source to see what the NPC says.
Ex: UID is 3000, the NPC would start with: if (CurrentNPC == 3000), then what the npc says, etc.

Type is the NPC Mech ID (what the NPC looks like)

Name is obvious lol

Direction is what way the NPC is facing, default, use 2 =P

X is the first coordinate number in the game (find this when playing in the server)
Y is the second coordinate number in the game
(for center of tc: X = 438, Y = 377)

Map is the map ID where the NPC will be located (EX: 1002 for Twin City)

Dont worry about SobType, you wont need this anytime soon, just use 0.

And there! you have your NPC placed!


Now you gotta code what it says. Heres an example of a code that would give an item:

Code:
                            if (CurrentNPC == 3000)
                            {
                                SendPacket(General.MyPackets.NPCSay("Want a free awesome Item???"));
                                SendPacket(General.MyPackets.NPCLink("Yes!!!!!!!", 1));
                                SendPacket(General.MyPackets.NPCLink("No.", 255));
                                SendPacket(General.MyPackets.NPCSetFace(30));
                                SendPacket(General.MyPackets.NPCFinish());
                            }

Code:
                            if (CurrentNPC == 3000)
                            {
                                if (Control == 1)
                                {
                                    MyChar.AddItem("130209-12-7-255-13-13", 0, (uint)General.Rand.Next(36457836));
                                    SendPacket(General.MyPackets.NPCSay("Theres your awesome freakin Item baby!"));
                                    SendPacket(General.MyPackets.NPCLink("Holy crap! Thank you lots dude!", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());

                                }
                            }

Btw, I just did this real quick =P
 
Rival Gamers Owner
Loyal Member
Joined
Jul 7, 2007
Messages
962
Reaction score
161
my LOTF source u fukin noob
how long did it take you to code it can i see the frame of "your work"

- good luck to you on programmingm
- danny if u dont stop your flaming ur going to get banned
 
Experienced Elementalist
Joined
Jul 11, 2008
Messages
281
Reaction score
1
ok, its not MY source, but i did all the updates and poop to it, even you did some to it so wth u noob poop sthu :s
 
Newbie Spellweaver
Joined
May 4, 2007
Messages
41
Reaction score
0
Thanks Super.Pvper for your quick response. One more question... say I only wanted the NPC to give the item once per account, how would I code this?
 
Newbie Spellweaver
Joined
Jun 23, 2008
Messages
36
Reaction score
0
Thanks Super.Pvper for your quick response. One more question... say I only wanted the NPC to give the item once per account, how would I code this?

Well, there would be several ways to do this, ill show you the simplest.:jester:
(this definitally isnt the more efficient way)

Create a new table in Characters in teh database called something like ItemGet

Now, define it in your Character.cs file: public byte ItemGet = 0;

now, at the code wehre it gives the item, make MyChar.ItemGet = 1.

you must also modify the save code and more in database.cs

Code:
                            if (CurrentNPC == 3000)
                            {
                                if (MyChar.ItemGet = 1)
                                {
                                    SendPacket(General.MyPackets.NPCSay("You already got your kick butt item!"));
                                    SendPacket(General.MyPackets.NPCLink("Oh yeah, and it effin rulez!", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());
                                }
                                else
                                {
                                    SendPacket(General.MyPackets.NPCSay("Want a free awesome Item???"));
                                    SendPacket(General.MyPackets.NPCLink("Yes!!!!!!!", 1));
                                    SendPacket(General.MyPackets.NPCLink("No.", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());
                                }
                            }

Code:
                            if (CurrentNPC == 3000)
                            {
                                if (Control == 1)
                                {
                                    MyChar.AddItem("130209-12-7-255-13-13", 0, (uint)General.Rand.Next(36457836));
                                    SendPacket(General.MyPackets.NPCSay("Theres your awesome freakin Item baby!"));
                                    SendPacket(General.MyPackets.NPCLink("Holy crap! Thank you lots dude!", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());

                                }
                            }

In database.cs

Code:
Charr.ItemGet =Convert.ToByte((byte)DR["ItemGet"]);

Add this to MySqlCommand Command = new MySqlCommand("UPDATE `Characters`...
Code:
`ItemGet` = '" + Charr.ItemGet + "'


Edit: add me on MSN if you wanna discuss this. super.pvper@hotmail.com
 
Newbie Spellweaver
Joined
May 4, 2007
Messages
41
Reaction score
0
Awesome bro, thank you. I've added you to msn.

What do I do about this error?

Error 1 Cannot implicitly convert type 'byte' to 'bool'
 
Back
Top