[HowTo] Custom NPCs

12/02/2011 14:08 Xijezu#1
Hello,

After I saw this question alot, I thaught about thinkin' to write some BEGINNING, this will be NOT a Copy'n'Paste Tutorial, you have to do those things ON YOUR OWN!

But now to my tut:

What we need:
  • A program to edit .lua's
  • Databaseaccess
  • Brain.exe (Note: If you can't find it: Give up.)

Part 1: Database
- If you don't want to use disabled NPC's, then skip this step.

Well, I know, it's the wrong beginning, but I said it before: This is not a Copy'n'Paste-Tut.

First of all search for a disabled NPC (select * from npcresource where local_flag IS NOT '0')
Here you have to edit x, y, contact_script and local_flag.
X & Y should be clear, local_flag, too. If you don't know, what you have to replace here, give up. :3
Now contact_script:
Think about some good name, for our example we'll take "NPC_DarknessFight".
Here you have to insert "NPC_DarknessFight()" - "(" & ")" are important!

Part 2: Lua-Files
Now you have the choise:
Use a existing .lua, or create a new one.

If you want to create a new one, you have to put this at the beginning:
Code:
function get_module_name()
             return "DESCRIPTION"
             -- Example:
             -- return "DarknessFight"
end
Now we gonna create the Display for the NPC.

First of all, you must remember the Databasename, in this case "NPC_DarknessFight".

This will be our beginning

Code:
-- Initalize Script
function get_module_name()
return "DarknessFight"
end

-- Start NPC
function NPC_DarknessFight() -- ( & ), again important, else it wont work!
-- ToDo: Function
end
Now we have the base, this part is the function of when you double-click on your NPC.
But we want that awesome window, how can we get this?

Code:
dlg_title( "Xijezu" )
dlg_text( "Hello, nice to meet you. And now GTFO." )
dlg_menu( "Menu 1", 'open_market("lalalalala")' )
dlg_menu( "Uhuh, close this shit! :D", '' )
Selfexplaining?

So the full code would be this:

Code:
-- Initalize Script
function get_module_name()
return "DarknessFight"
end

-- Start NPC
function NPC_DarknessFight() -- ( & ), again important, else it wont work!
dlg_title( "Xijezu" )
dlg_text( "Hello, nice to meet you. And now GTFO." )
dlg_menu( "Menu", 'open_market("lalalalala")' )
dlg_menu( "Uhuh, close this shit! :D", '' )
end
Now you got a new NPC.
If you want a custom function, like add state or insert item, then you have to write a new function

Code:
function test_function()
warp(99999, 99999) -- This will warp you into CV
end
You can use this with this little change:
Code:
dlg_menu( "Menu", 'test_function()' )
Understood?
Good.

Questions?
Yes? Then use search. ;)

Greets,

Xijezu
12/02/2011 14:15 TheOnlyOneRaskim#2
Wasted Time, i bet 1.000.000$ in the Next 2 week´s, some noob`s will ask, "How add NPC???!!".


But for the People who really want to learn, it`s good.
12/02/2011 14:16 ILoveShyla<3#3
Xijezu can you send me your skype in pm?
12/02/2011 14:17 Xijezu#4
Quote:
Originally Posted by TheOnlyOneRaskim View Post
Wasted Time, i bet 1.000.000$ in the Next 2 week´s, some noob`s will ask, "How add NPC???!!".
I know -.-

Quote:
Originally Posted by TheOnlyOneRaskim View Post
But for the People who really want to learn, it`s good.
Thats the reason why I wrote this tut. ^_^
12/02/2011 14:23 mahmoudnasser#5
Xijezu ok thats good but )=== ineed how add sql in Data Base Screenshost*
12/02/2011 14:29 Xijezu#6
Quote:
After I saw this question alot, I thaught about thinkin' to write some BEGINNING, this will be NOT a Copy'n'Paste Tutorial, you have to do those things ON YOUR OWN!
Quote:
First of all search for a disabled NPC (select * from npcresource where local_flag IS NOT '0')
Here you have to edit x, y, contact_script and local_flag.
X & Y should be clear, local_flag, too. If you don't know, what you have to replace here, give up. :3
Selfexplaining.^_^
12/02/2011 14:45 Xijezu#7
Quote:
Originally Posted by speedy-nl View Post
Brain.exe (Note: If you can't find it: Give up.)

where can i find this ?
speedy, I lol'd. :D
But then I saw your username... Bad joke :(

Just like raskim said:
This is just for people who won't copy'n'paste, also for people which wanna learn a bit. :3
12/02/2011 15:44 qaaah#8
You are the best man !
12/03/2011 05:56 Xijezu#9
Who was successful to create a custom NPC after this little tut? :p
12/03/2011 07:10 Saelt#10
I have enable the npc, set X, Y, but when i double-click on, nothing happen :0 x) got an idea ?
12/03/2011 07:17 Xijezu#11
Quote:
Now contact_script:
Think about some good name, for our example we'll take "NPC_DarknessFight".
Here you have to insert "NPC_DarknessFight()" - "(" & ")" are important!
You forgot this.
12/03/2011 08:08 Strange2010#12
how add npc plez tell me i want add npc my server

(another noob asking :p)

Thanks for the tut but as raskim said there will be noobs asking
12/03/2011 10:08 Saelt#13
Quote:
Originally Posted by Xijezu View Post
You forgot this.
No thats the problem. :) I've got an idea, i'm testing it :).
Thx for this.
12/03/2011 13:39 Saelt#14
Thx it is working :)
12/07/2011 14:49 haxti#15
you have to put in the correct script in the db. Furthermore the script itself needs to be correct